>If you notice at
> 8000e25d: f0 0f bc d2 lock bsf %edx,%edx
> The instruction is generated using the same register as source and
> destination. However,
> asm volatile("lock; bsfl %1, %0"
> : "=r" (bit)
> : "rm" (_libkernel_portmap) );
Nothing about this asm statement prevents the same register being used
for the source and destination.
>Obviously the code is incorrect since the %edx register is not correctly
>sourced afterwards. (Meaning, on entry to that instruction %edx
>contains the base address of the array, and afterwards its also expected
>to contain that value. (Consider the lea on 8000e264).
No, the %edx register is used correctly. The "lea" instruction is part of
the "port = (index<<5) + (bit);" statement in your code. This instruction
adds %edx ("bit") to %eax ("index << 5") and stores the result in %ebx
("port"). After the "lea" instruction your code breaks from the loop
and the value in %edx ("bit") is never used again.
The bug is in your code. You want to use "_libkernel_portmap[index]"
as the source operand in the asm statement quoted above.
l/ // Ross Ridge -- The Great HTMU
Get latest updates about Open Source Projects, Conferences and News.