15 lines
186 B
NASM
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
|