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
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user