Calculator Community > ASM

[z80] 32 bit by 16 bits division and 32 bit square root

<< < (2/7) > >>

Streetwalrus:
Xeda helped me optimize my primality checker a bit. I think I have an idea for arbitrary precision division though and jacobly linked me an arbitrary precision sqrt routine. I will see what I can do with that. And everyone is not in the contest. :P Also :

--- Quote from: Streetwalker on April 10, 2013, 03:50:37 pm ---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. :P

--- End quote ---

Thanks for the link Runer.

Xeda112358:
I did? I don't remember that D: Or were you talking about the BASIC code/trial division stuff?

Streetwalrus:
Yeah that's what I was talking about but since I use the exact same thing in Axe... :P

Streetwalrus:
I can't get the 24/16 routine from z80 bits to work. :s
Here's what I'm running :

--- Code: ---    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, 24
LOOP:
    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
--- End code ---
What am I doing wrong ? ??? I tried it several times and I always get wrong results.

jacobly:
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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version