0 Members and 1 Guest are viewing this topic.
Note that I'm not asking for code but some help to create them myself and then optimization because I'm not Runer/ThePenguin/Calc84maniac and I want to learn.
di ld a, 244 ;dividend high byte ld bc, 9216 ;dividend low word (244*2^16+9216=16000000) ld de, 47288 ;divisor ld hl, 0 exx ld b, 24LOOP: exx slia c ; unroll 24 times rl b ; ... rla ; ... adc hl,hl ; ... sbc hl,de ; ... jr nc,$+4 ; ... add hl,de ; ... dec c ; ... exx djnz LOOP exx ;load the values of a, bc and hl to the first five bytes of appBackupScreen ei
You only have one exx in the loop, so every time through the loop uses different registers. It should work if you add an exx at the beginning of the loop.
jr nc,$+7 or a sbc hl,de jr $+7
div32_16: ld de,0 ; 10 ld a,32 ; 7div32_16loop: add ix,ix ; 15 adc hl,hl ; 15 ex de,hl ; 4 adc hl,hl ; 15 or a ; 4 sbc hl,bc ; 15 inc ix ; 10 jr nc,cansub ; 12/7 add hl,bc ; 11 dec ix ; 10cansub: ex de,hl ; 4 dec a ; 4 jr nz,div32_16loop ; 12/7 ret ; 10