Mail Archives: djgpp/2000/04/14/08:34:46
Thomas J. Hruska wrote:
>Basically, the ASM code does nothing, but I want to be able to self-modify
>the code during run-time and replace the number $32 with the value in y.
>The assembler complains whenever I try replacing the $32 with a variable
>and I think that the only way that I am going to get that number to change
>is to self-modify. If someone knows of a better solution, let me know.
>Otherwise, how do I self-modify ASM code in 32-bit PM (if such a thing is
>even allowed).
Instead of
rol $32, %%eax
you can use
rol %%cl, %%eax
after copying the value of y into ECX.
Unless you have a good reason to do this inline, you're probably
better off writing the assembly code in a separate file and using
NASM, since inline assembler can be difficult to get right. (Also,
the use of CL can cause a partial register stall on current Intel
processors. This can easily be avoided if the whole procedure is
coded in asm, but might be tricky to avoid with inline asm.)
S.
- Raw text -