Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Programming:Logarithm: Difference between revisions

From CPCWiki - THE Amstrad CPC encyclopedia!
Octoate (talk | contribs)
added logarithm
 
Octoate (talk | contribs)
m forgot the category :(
 
Line 13: Line 13:
ret
ret
</pre>
</pre>
[[Category:Programming]]

Latest revision as of 20:46, 18 April 2011

Log of base 2

; 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