rdos/lib/log2.asm

15 lines
186 B
NASM
Raw Normal View History

2019-10-08 19:54:39 +02:00
; Calculate dual logarithm (int)
; IN AX number
; OUT AX dual logarithm
log2:
push cx
mov cx, 16
.loop:
sar ax, 1
loopnz .loop
xchg ax, cx
pop cx
neg ax
add ax, 15
ret