0 Members and 5 Guests are viewing this topic.
_DE_Times_L: xor a ld h,a ld a,l ld l,h_Loop: rra jr nc,_Skip add hl,de_Skip: sla e rl d or a jr nz,_Loop ret
div_hl_de: ; BC = HL/DE, HL = remainder xor a sub e ld e,a sbc a,a sub d ld d,a ld a,h ld b,l ld hl,0 ld c,8 div_loop_1: rla adc hl,hl add hl,de jr c,$+4 sbc hl,de dec c jr nz,div_loop_1 rla ld c,a ld a,b ld b,8 div_loop_2: rla adc hl,hl add hl,de jr c,$+4 sbc hl,de djnz div_loop_2 rla ld b,a ret
HL_div_DE: ld a,h ld c,l ld hl,0 ld b,16__DivLoop: sll c rla adc hl,hl sbc hl,de jr nc,__DivSkip add hl,de dec c__DivSkip: djnz __DivLoop ld h,a ld l,c ret
Thanks for that division routine, but I found this one and its a lot smaller.Code: [Select]HL_div_DE: ld a,h ld c,l ld hl,0 ld b,16__DivLoop: sll c rla adc hl,hl sbc hl,de jr nc,__DivSkip add hl,de dec c__DivSkip: djnz __DivLoop ld h,a ld l,c retI'm just a little bit worried about the use of the sll command, will that sacrifice compatibility with the Nspire?
ld hl,(var_a)ld d,hld e,ladd hl,hladd hl,hladd hl,hladd hl,de
Also, if you haven't done this already, I'd like to suggest that you auto-generate multiplication algorithms when multiplying by constants.
I am confused by what this means. Does it means it would be only possible to mutiply by 2, 4 and the like? It might become an issue for example if I did a small RPG where your max HP and attack power was like 101 x character LV
I think (but i'm not sure) is that when multiplying by any arbitrary number, it uses the general multiplication routine, but when multiplying by 2, you use the dedicated x2 routine?