Contents|Index|Next

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, the GNU assembler becomes 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.

What follows is an example of input to give the flavor of 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

The previous input to GASP generates the following 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