0 Members and 4 Guests are viewing this topic.
.B5->{L1}GetCalc("L1",1)->A{L1}->{A}
Text(0,52,C^213*256▸Dec)Text(0,58,C^213*256/213▸Dec)
ld hl,25600 ld a,213
push bc ld c,a sub a ld b,16loop: add hl,hl rla cp c jr c,skip sub c inc lskip: djnz loop pop bc
That's bizarre... the routine isn't mine though it's TI's! I'm using BCALL(_DivHLByA) and the disassembly is showing the executable is setting up the inputs correctly so it must be something wrong with their routine. I'm going to investigate.Most interesting! With the following input:Code: [Select] ld hl,25600 ld a,213I disassembled the exact routine the OS uses. Running the input through this exact routine:Code: [Select] push bc ld c,a sub a ld b,16loop: add hl,hl rla cp c jr c,skip sub c inc lskip: djnz loop pop bcDoes indeed return the result "0" in HL instead of "120" like it should. Am I misusing something here? This is a 16-bit / 8-bit division right? Why is it failing?
ld c,a xor a ld b,16loop: add hl,hl rla jr c,overflow cp c jr c,skipoverflow: sub c inc lskip: djnz loop