delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/14/08:34:46

From: dontmailme AT iname DOT com (Steamer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help with Inline ASM...
Date: Fri, 14 Apr 2000 11:59:43 GMT
Organization: always disorganized
Lines: 28
Message-ID: <38f707f1.14335375@news.freeserve.net>
References: <3 DOT 0 DOT 6 DOT 32 DOT 20000413223445 DOT 007be930 AT pop DOT crosswinds DOT net>
NNTP-Posting-Host: modem-55.dwarf-lion-fish.dialup.pol.co.uk
X-Trace: news6.svr.pol.co.uk 955713583 3587 62.137.4.55 (14 Apr 2000 11:59:43 GMT)
NNTP-Posting-Date: 14 Apr 2000 11:59:43 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019