log2: implement using left rotate through carry

This commit is contained in:
Nero 2019-10-19 12:51:11 +00:00
parent 6c23ec2fed
commit 6f7fc05171

View File

@ -3,12 +3,13 @@
; OUT AX dual logarithm
log2:
push cx
mov cx, 16
mov cx, 15
.loop:
sar ax, 1
loopnz .loop
xchg ax, cx
rcl ax, 1
jc .ret
loop .loop
.ret:
cmc
mov ax, cx
pop cx
neg ax
add ax, 15
ret