Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Square root routine
- This is a faster square root routine than the one that was previously here, test results say that it’s 26% faster. It is written by Ricardo Bittencourt, so many thanks to him :).
- ;
- ;Square root of 16-bit value
- ;In: HL = value
- ;Out: D = result (rounded down)
- ;
- Sqr16: ld de,#0040
- ld a,l
- ld l,h
- ld h,d
- or a
- ld b,8
- Sqr16_Loop:
- sbc hl,de
- jr nc,Sqr16_Skip
- add hl,de
- Sqr16_Skip:
- ccf
- rl d
- add a,a
- adc hl,hl
- add a,a
- adc hl,hl
- djnz Sqr16_Loop
- ret
Advertisement
Add Comment
Please, Sign In to add comment