Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 243

Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 246

Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 243

Notice: Trying to access array offset on value of type bool in /mnt/cpcwiki-httpdocs/includes/libs/IPSet.php on line 246
Changes - CPCWiki

Changes

Programming:Square Root

337 bytes added, 13:33, 10 March 2007
Square Root of 16bit value by Ricardo Bittencourt

<pre>
;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
</pre>
12,273
edits