Re: Best way to emulate BSR?
- From: <spamtrap@xxxxxxxxxx>
- Date: Thu, 31 Aug 2006 10:50:05 +0100
Assuming you are using 16 bit (you did say the processor didn't support BSR), the following is the simplest I could think of.
Lookup tables might be faster but with an old processor you probably are trying to conserve memory as well.
This is equivalent to BSR dx, ax
test ax, ax
jz ____Finish
push ax
push cx
push bx
clear dx
mov cx, 8
mov bx, 0FF00h
jmp ____Beg
LoopTop:
shr bx, cl
____Beg:
test ax, bx
jz ____Next
shr ax, cl
add dx, cx
____Next:
shr cl, 1
jnz LoopTop
test bx, bx ; just to clear the z flag
pop bx
pop cx
pop ax
____Finish:
Cassandra
.
- Prev by Date: Re: C++
- Next by Date: Re: C++
- Previous by thread: Re: Best way to emulate BSR?
- Next by thread: Is there any forum for [BIOS] ?
- Index(es):