I want to know how would you find the square root in the EASy68k assembler.
I know it's a function but I don't know the code for it.
I want to find the Square root of 72.
The answer should be an integer so 8 in this case.
I found this algorithm:
value-->c1
loop:
value/c1-->c2
(c1+c2)/2-->c1
until c1=c2
c1-->result
I converted this into 68k code:
move.w #72,d2 ; value = 64
move.l d2,d5 ; c1 = 64
move.l d5,d3 ; hold d3 = 64
LOOP
divs d2,d3 ; value/c1
move.l d3,d6 ; move answer above to c2 = d6
add.l d5,d6 ; add c1+c2
divs #2,d6
move.l d6,d5 ; move the answer above it do d4 = c1
cmp.l d6,d5
beq loop
move.l d5,d7 ; d7 will have the result
And it doesn't work for some reason.