Welcome, Guest. Please login or register.

Author Topic: I don't think I can learn C....  (Read 10459 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Crumpster

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 215
  • Country: gb
    • Show only replies by Crumpster
Re: I don't think I can learn C....
« Reply #14 on: April 02, 2003, 12:24:52 PM »
@ Karlos

yep 14 ish Kb sorry finger slipped on the decimal point
(I obviously can't count, did I cover it ok?  :-P )

Thanks fo the correction.

@ Athiest

Not on an A1 yet I'm afraid, crappy works P2 233Mhz with redhat 7.3 on it.

Cheers

Crumpy
A1-XE - G4 800MHz, 1GB RAM, 80GB HDD, Radeon 9250, OS 4.1
A1200T - PPC603 240MHz / 68040 50MHz, 128MB RAM, Mediator, OS 3.9 / 4.1
A1200 (No. 2) - M-TEC 68030 50MHz, 4GB CF, KS 3.0, OS 3.0
A500 - ACA500 with ACA1232.
CDTV - in Progress: SCSI, 9 pin joy/mouse connectors, KS switcher.

Non-CBM - Atari STe, Atari Falcon, Apple ][e, ZX Spectrum, CPC6128.
Gone but not forgotten (and slowly getting them back): CPC464, C64, Vic-20.

I may have a problem
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: I don't think I can learn C....
« Reply #15 on: April 02, 2003, 12:44:51 PM »
Compiled with GCC for the Win32 console the exe is 23,468 bytes.
Playstation Network ID: xeron6
 

Offline Crumpster

  • Full Member
  • ***
  • Join Date: Mar 2002
  • Posts: 215
  • Country: gb
    • Show only replies by Crumpster
Re: I don't think I can learn C....
« Reply #16 on: April 02, 2003, 12:54:51 PM »
Tickly Wrote Thus:

Quote
Compiled with GCC for the Win32 console the exe is 23,468 bytes.



Good old Windows Bloat!!  :-D
A1-XE - G4 800MHz, 1GB RAM, 80GB HDD, Radeon 9250, OS 4.1
A1200T - PPC603 240MHz / 68040 50MHz, 128MB RAM, Mediator, OS 3.9 / 4.1
A1200 (No. 2) - M-TEC 68030 50MHz, 4GB CF, KS 3.0, OS 3.0
A500 - ACA500 with ACA1232.
CDTV - in Progress: SCSI, 9 pin joy/mouse connectors, KS switcher.

Non-CBM - Atari STe, Atari Falcon, Apple ][e, ZX Spectrum, CPC6128.
Gone but not forgotten (and slowly getting them back): CPC464, C64, Vic-20.

I may have a problem
 

Offline AtheistTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 820
    • Show only replies by Atheist
Re: I don't think I can learn C....
« Reply #17 on: April 02, 2003, 01:16:13 PM »
Quote

Crumpster wrote:

Good old Windows Bloat!!  :-D


Is it just me not understanding how these things work, or is that somwhat excessive? I wonder if it still relies on a DLL being present?

Also, as I wondered out loud in another thread, how would going to a 64 bit CPU instruction set affect the size?

AmigaOne! "What the DLL you talkin' 'bout, fool?", Mr. T?
\\"Which would you buy? The Crappy A1200, 15 years out of date... or the Mobile Phone that I have?\\" -- bloodline
So I guess that A500, 600, 1000, 2000, CDTV, CD32, are pure garbage then? Thanks for posting here.
 

Offline takemehomegrandma

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2990
    • Show only replies by takemehomegrandma
Re: I don't think I can learn C....
« Reply #18 on: April 02, 2003, 01:50:09 PM »
That's very cool!  :-o
MorphOS is Amiga done right! :)
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: I don't think I can learn C....
« Reply #19 on: April 02, 2003, 02:04:18 PM »
Quote

Atheist wrote:

Also, as I wondered out loud in another thread, how would going to a 64 bit CPU instruction set affect the size?

AmigaOne! "What the DLL you talkin' 'bout, fool?", Mr. T?


Here
int p; // A
 

Offline Aragorn

  • Newbie
  • *
  • Join Date: May 2002
  • Posts: 25
    • Show only replies by Aragorn
Re: I don't think I can learn C....
« Reply #20 on: April 02, 2003, 02:44:50 PM »
 4788 bytes on sparc if the -s switch is used :)
 

Offline pVC

Re: I don't think I can learn C....
« Reply #21 on: April 02, 2003, 04:13:32 PM »
6216 bytes with SAS/C with default options on 68k AmigaOS :)
Daily MorphOS user and Amiga active.
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: I don't think I can learn C....
« Reply #22 on: April 02, 2003, 07:30:43 PM »
I get the same size with SAS/C, however if I size optimize it and turn off some other things I can get it down to 5k, but it then gurus 8000 0004 after running :( Oh well, 6k's still not bad ;)
Playstation Network ID: xeron6
 

Offline danamania

  • Jr. Member
  • **
  • Join Date: Jan 2003
  • Posts: 84
    • Show only replies by danamania
    • http://www.danaquarium.com/
Re: I don't think I can learn C....
« Reply #23 on: April 02, 2003, 08:02:56 PM »
3968 bytes on 68k linux. 3 cheers for 680x0 :).

3.875Kb sounds even better!

-rwxr-xr-x    1 dana     dana         3968 Apr  3 04:44 a.out
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: I don't think I can learn C....
« Reply #24 on: April 02, 2003, 08:07:30 PM »
Ok everbody,

How big is the pure object file generated on your systems?

The size of the stdio / startup stuff has a lot of impact on some systems.

To see the true code generation size, just look at the unlinked object file. Should be interesting :-)
int p; // A
 

Offline pVC

Re: I don't think I can learn C....
« Reply #25 on: April 02, 2003, 08:48:55 PM »
Object file is 1128 bytes with SAS/C. :)
Daily MorphOS user and Amiga active.
 

Offline danamania

  • Jr. Member
  • **
  • Join Date: Jan 2003
  • Posts: 84
    • Show only replies by danamania
    • http://www.danaquarium.com/
Re: I don't think I can learn C....
« Reply #26 on: April 02, 2003, 08:51:51 PM »
mine comes out to:

-rw-r--r--    1 dana     dana         2060 Apr  3 05:34 xmas.o

2060 bytes. I know little about gcc and any optimisations, but that's with 2.95 on debian woody on a 68040.

dana
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: I don't think I can learn C....
« Reply #27 on: April 02, 2003, 08:54:27 PM »
Compiled under Watcom 11.0c as a Win32 character mode executable (speed rather than space opts)


02/04/2003  20:32                  881 mystery.c
02/04/2003  20:36               31,232 mystery.exe
02/04/2003  20:36              113,664 mystery.ilk
02/04/2003  20:36                   19 mystery.lk1
02/04/2003  20:36               22,729 mystery.map
02/04/2003  20:36                   89 mystery.mk
02/04/2003  20:36                  669 mystery.mk1
02/04/2003  20:36                1,496 mystery.obj
02/04/2003  20:36               16,599 mystery.sym


As you can see, the object file is only 1.4kB :-)

-edit-

Check out the winbloat! 30kb of sh*t linked just to make the exe :-D

-edit-

My guess is

1) the original text is compressed with something like LZ or dynamic huffman style compression, encoded into the big string in the middle

Quote

"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+\
,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/\
+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){n\
l]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/"


2) The binary lookup for the encoding is stored in the smaller string

Quote

"!ek;dc \
i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"


3) main() is defined as a recursive extraction algorithm (similar to some huffman decoders) and character output.

4) This is an oversimplification since main() is called internally several times and tested conditionally with operator ? :...

Anybody else got any ideas?

This thing is cool :-)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: I don't think I can learn C....
« Reply #28 on: April 02, 2003, 08:59:27 PM »
Quote

danamania wrote:
mine comes out to:

-rw-r--r--    1 dana     dana         2060 Apr  3 05:34 xmas.o

2060 bytes. I know little about gcc and any optimisations, but that's with 2.95 on debian woody on a 68040.

dana


Given that youre exe was only a kilibyte larger, you sure do have a good startup/stdio lib :-D
Probably just a stub that relies on OS calls deeper in?
int p; // A
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: I don't think I can learn C....
« Reply #29 from previous page: April 02, 2003, 09:47:28 PM »
Quote
The size of the stdio / startup stuff has a lot of impact on some systems.

Yes indeed. So why not skip stdio & startup?

Here is what I did:

#include
#include

#include
#include

#define putchar(x) FPutC(Output(),x)

struct DosLibrary *DOSBase;

void entry(void)
{
  struct ExecBase *SysBase = *(struct ExecBase **)4;
  DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37);
  if (DOSBase)
  {
    main(1,NULL,NULL);
    CloseLibrary((struct Library *) DOSBase);
  }
}

//#include
.... rest of the original code...

Then compile with size optimization, link without startup code, and strip resulting exe:

68000, AmigaOS (SAS/C 6.58):
mystery                           1048 ----rwed Today     23:32:37

PowerPC, MorphOS (gcc 2.95.3):
mystery                           2200 ----rwed Today     23:32:42

Next step: Optimize the generated asm code. :-)