Changes

Jump to: navigation, search

Programming:Logarithm

207 bytes added, 20:45, 18 April 2011
added logarithm
== Log of base 2 ==

<pre>
; input: hl (unsigned)
; output: a = log2(hl) (rounded down and from -1 to 15) (8-bit integer signed)
log2:
ld a, 16
scf
log2loop:
adc hl, hl
dec a
jr nc, log2loop
ret
</pre>
1,165
edits