delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/09/21:45:58

From: GAMMELJL AT SLU DOT EDU
Date: Sun, 09 Aug 1998 20:45:09 -0500 (CDT)
Subject: assembly language
To: djgpp AT delorie DOT com
Message-id: <01J0EUU0EKIY94EO0P@SLU.EDU>
Organization: SAINT LOUIS UNIVERSITY St. Louis, MO
MIME-version: 1.0

     When one compiles codename.cc with the -S -O2 switches, one gets
codename.cc in assembly language (codename.s).  codename.s is easily
readable and can be edited with the DOS editor, a very nice feature.
When codename.cc contains a subroutine named sub (which may be used in 
many programs) one sees that even though the optimizing switch -O2 has been
used there are small changes one can make in the assembly language for
sub (whose location in codename.s is clearly marked) which make the
executable a.exe produced by gxx codename.s run a little faster.
    Now, one would like to use the modified assembly language for sub
in all future programs.  That can be done in this way:  Compile any 
program.cc with gxx program.cc -S -O2, find sub in program.s, and 
replace it with the modified assembly language for sub (one uses the
DOS editor to do that).  Then gxx program.s.  a.exe is a little faster.
    But, it would be preferable to put the modified assembly language
for sub back in program.cc to start with (sub is contained in an include
file include file file.h so the programs requiring sub have #include 
"file.h".  One wants to put the assembly language in sub in file.h.
    Here is the problem:  the assembly language in sub.s is not exactly
like the AT&T assembly language conventions.  There are no "    ;"  \
on each line; there are only % symbols rather than %%; one has to
be cautious about the line numbers.  It is extremely tedious to take
the .s assembly language and translate it back to AT&T conventions and
it is easy to make a mistake.
     What one would really like is to hand the .s code for sub back
to file.h with a compiler directive #replace subs assembly language
with the assembly language found in the file modifiedsub, say
              #replace subasm modifiedsubasm
Maybe such a thing already exists and I just don't know about it.
I know it can be done: if I can do it with the DOS editor and compiler
can do it! ("and" in the line above ="the").  If the compiler can't
already do it, it would be a very small step forward if it were made
to.  It is really only a matter of editing codename.s after it is
produced:  I could almost do it myself if I knew what the hidden
end of line symbol in codename.s is, but the writers of the compiler
would know all of the tricks necessary to do it (how to read the
text file codename.s and replace subasm with modifiedsubasm.
    I hope so.  Best wishes to all.

- Raw text -


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