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
1 changed files with 7 additions and 6 deletions

View File

@ -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