Z80 code size - roybaer/sdcc-wiki GitHub Wiki

Table of Contents

z80 (and related ports) code size

A history of code size in sdcc and a comparison to other compilers.

Note: these benchmarks are not representative. A long time ago, the files were originally chosen as examples of source for which SDCC generates particularly bad code for the Z80; the purpose of the table is mostly to see the progress of SDCC.

Z80 Code size comparison (bytes):

File z88dk 1.8 CROSS-C 2.57.02 HITECH-C 7.80PL2 ADC 5.02 IAR 4.06A hand asm sdcc 3.1.5 #7830¹ sdcc-lospre #8070¹² sdcc 3.5.5 #9383¹ sdcc 3.6.9 #10107¹
cvu_vinb.c 18 39 26 28 9 12 12 12 12
galois_lfsr.c 54 39 20 62 19 13 27 18 25 23
get_tile.c 202 190 159 171 124 109' 109 103 102
huffman_iterative.c fails / 385 fails / 278 222 441 131 89 241 215 206 241
huffman_recursive.c fails / 521 fails / 470 299 662 161 240 224 221 217
init_loop.c 74 52 45 fails 38 26 26 25 27
insertion_sort.c 301 155 581 199 133 138 147 134 139 132
memcpy_compression.c fails / 80 93 100 163 68 77 77 73 72
memtovmemcpy.c 118 82 86 fails 60 75 75 75 75
play_music.c fails / 821 708 581 1309 426 584 545 586 544
sdcc_mullong.c 340 265 268 fails 219 575 559 595 575
set_screen_mode.c fails / 95 65 57 151 50 49 50 50 50
set_sprite_x.c 130 128 108 232 77 60 110 98 93 93
z88dk-mktime.c 453 425 409 fails 294 561 561 482 502
total fails / 3592 fails / 2989 2961 fails 1809 2832 2703 2685 2665

Rabbit 2000 Code size comparison (bytes):

File Dynamic C 9.62 CROSS-C 2.18.01 sdcc 3.1.5 !#7830¹ sdcc-lospre !#8032¹² sdcc 3.6.9 #10107¹
cvu_vinb.c fails / 30 24 10 10 10
galois_lfsr.c fails / 76 33 27 18 18
get_tile.c fails / 225 fails / 161 101 101 94
huffman_iterative.c fails 214 209 193 197
huffman_recursive.c fails 371 219 209 194
init_loop.c fails / 109 55 26 26 26
insertion_sort.c 273 146 143 139 127
memcpy_compression.c fails 68 67 67 68
memtovmemcpy.c 103 68 53 53 53
play_music.c 585 579 494 472 442
sdcc_mullong.c 374 252 414 371 366
set_screen_mode.c fails / 110 66 49 50 50
set_sprite_x.c 148 98 97 87 82
z88dk-mktime.c fails 429 507 503 443
total fails fails / 2564 2416 2299 2170

Total code size and compilation time over revisions (1M means --max-allocs-per-node 1000000):

http://sdcc.sourceforge.net/wiki_images/graph-z80.png

The benchmark files can be found at http://colecovision.eu/stuff/testbench.tar.gz

Command line: sdcc -mz80 --opt-code-size --std-c89, zcc -O2, ZC -O. For z88dk, Dynamic C and CROSS-C slightly modified versions of the source have been used where the original didn't compile (still marked with "fails" though).

¹ --max-allocs-per-node 5000000, runtime approx. 13min.

² Experimental sdcc from lospre branch.

Code size vs. compilation time:

The --max-allocs-per-node parameter provides a code size vs. compilation speed trade-off:

http://sdcc.sourceforge.net/wiki_images/test.png

Philipp

⚠️ **GitHub.com Fallback** ⚠️