log2: implement using left rotate through carry
This commit is contained in:
parent
6c23ec2fed
commit
6f7fc05171
13
lib/log2.asm
13
lib/log2.asm
@ -3,12 +3,13 @@
|
|||||||
; OUT AX dual logarithm
|
; OUT AX dual logarithm
|
||||||
log2:
|
log2:
|
||||||
push cx
|
push cx
|
||||||
mov cx, 16
|
mov cx, 15
|
||||||
.loop:
|
.loop:
|
||||||
sar ax, 1
|
rcl ax, 1
|
||||||
loopnz .loop
|
jc .ret
|
||||||
xchg ax, cx
|
loop .loop
|
||||||
|
.ret:
|
||||||
|
cmc
|
||||||
|
mov ax, cx
|
||||||
pop cx
|
pop cx
|
||||||
neg ax
|
|
||||||
add ax, 15
|
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user