-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear Marco,
thanks for your help with Z80 multiplication. bodr...@mail.dm.unipi.it schrieb: > [...] > > Advantages of the new code: > - faster (most of the times), saving 14 T-states on average I don't think so. Unfortuantely I currently don't find a link to the study, but it has been shown, that small integer values are far more common than bigger ones. AFAIR values 0,1,2 combined are about as likely to occour as all other values combined in an 8 bit integer. > - does not mess with DE This could be an important advantage for builtin code generation. Currently the code often has to be wrapped into push de / pop de. > - can be easily modified to give its result on DE (or BC) Another aspect which could be good for builtin code generation. > Drawbacks: > - overwrites the accumulator A For builtin code generation this is bad, since A is used to backup B (when B is in use). > > Let me know if you find it interesting! If you do, I can try to optimise > also the "code generation" (but I'll need some hints) and maybe other > multiplication routines... > You might want to have a look at the 16 bit multiplication in mul.s or the division routines in div.s and divsigned.s. AFAIK these have not been optimized as much as the 8x8 bit multiplication yet. The code generation is in src/z80/gen.c in the genMultOneChar function. It currently generates the following code: ld l, #0 ld b, #8 1: add hl, hl jp NC, 2 add hl, de 2: djnz 1 Code size is 11 bytes, it takes 285+11b cycles. Your multiplication would be xor a ld b, #8 1: rr l jp NC, 2 add a, h 2: rra djnz 1 rr l ld h, a Code size is 15 bytes, it takes 298+4b̄ cycles. However depending on the operands and weather de and bc are in use your code could still be better. I wonder how these would compare at device/lib/_mulllong.c Philipp -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAknPgUEACgkQbtUV+xsoLpoKygCgjnEDDl03fIhuTIX9AkyyqtFd YEgAn0KwvorqMCktqZ9WhHtT6th1/3so =gXUj -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user