rdos/lib/log2.asm
2019-10-08 17:54:39 +00:00

15 lines
186 B
NASM

; 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