Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The GNU Assembler Preprocessor - <b>what is gasp?</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
What is GASP?
*************

   The primary purpose of the GNU assembler is to assemble the output of
other programs--notably compilers.  When you have to hand-code
specialized routines in assembly, that means the GNU assembler is an
unfriendly processor: it has no directives for macros, conditionals, or
many other conveniences that you might expect.

   In some cases you can simply use the C preprocessor, or a generalized
preprocessor like M4; but this can be awkward, since none of these
things are designed with assembly in mind.

   GASP fills this need.  It is expressly designed to provide the
facilities you need with hand-coded assembly code.  Implementing it as a
preprocessor, rather than part of the assembler, allows the maximum
flexibility: you can use it with hand-coded assembly, without paying a
penalty of added complexity in the assembler you use for compiler
output.

   Here is a small example to give the flavor of GASP.  This input to
GASP

             .MACRO  saveregs from=8 to=14
     count   .ASSIGNA \from
             ! save r\from..r\to
             .AWHILE  \&count LE \to
             mov     r\&count,@-sp
     count   .ASSIGNA  \&count + 1
             .AENDW
             .ENDM
     
             saveregs from=12
     
     bar:    mov     #H'dead+10,r0
     foo     .SDATAC "hello"<10>
             .END

generates this assembly program:

             ! save r12..r14
             mov     r12,@-sp
             mov     r13,@-sp
             mov     r14,@-sp
     
     bar:    mov     #57005+10,r0
     foo:    .byte   6,104,101,108,108,111,10


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson