Message-Id: <3.0.6.32.20000413223445.007be930@pop.crosswinds.net> X-Sender: shinelight AT pop DOT crosswinds DOT net X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Thu, 13 Apr 2000 22:34:45 -0500 To: djgpp AT delorie DOT com From: "Thomas J. Hruska" Subject: Help with Inline ASM... Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com Hello, I got the following code to work (new to AT&T ASM, somewhat familiar with Intel): #include #include int main(void) { int x, y = 32; x = 0; x++; printf("%i\n", x); // Form __asm__ __volatile__ ("Code" : outputs : inputs : registers-modified); // Allowed to destroy eax, ecx, edx, fs, gs, and eflags (although pushing/popping them // is a whole lot safer __asm__ __volatile__(" push %%eax movl %0, %%eax rol $32, %%eax movl %%eax, %0 pop %%eax" : : "g" (x), "g" (y) : "ax", "cx", "memory" ); printf("%i\n", x); } 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). Thanks in advance! Thomas J. Hruska -- shinelight AT crosswinds DOT net Shining Light Productions -- "Meeting the needs of fellow programmers" http://www.shininglightpro.com/