I didn't know! investigation about to lunch.Chilly Willy wrote: Thu Apr 23, 2020 6:30 pm Very true - the C preprocessor can be run on gas files (use .S instead of .s for automatically doing so). Pragmas and defines and stuff can be used. This does make a gas assembler specific file very flexible compared to more traditional assemblers.
I'm not sure this is what you want, but with defines/macros you can do something like this:MrD wrote: Thu Apr 23, 2020 6:53 pm Define would be nice, since I can't see any support for register lists (for movem) in asmx and no way to fake it with macros.
speedX = d7
speedY = d3
accX = a0
accY = d5
addq.w #1, speedX
movem.w speedX/speedY/accX/accY, -(sp)
With macros you can do something like this:Stef wrote: Fri Apr 24, 2020 8:36 am Also it doesn't support local label or macro for instance... Something i like to use when possible.
.macro SetSpeed direction, speedX
tst.w \direction
blt backwards\@
addq.w #1, \speedX
bra end\@
backwards\@:
addq.w #-1, \speedX
end\@:
.endm
where the symbol "\@" is a value unique for every instance of any macro.
Also labels with only numbers are special since can be reused unlimited times. Then when there is a jump it references to the closest one, which can be very dangerous if there are macros in between.
In the next example:
1:
nop
1:
jne 1b
1:
nop
1:
the second "1:" is the one referenced. While in this one:
1:
nop
1:
jne 1f
1:
nop
1:
is the 3rd one.
You can use macros to simplify and create structures in a C fashion too. Or even a C++ parental structure, do is more complex.Chilly Willy wrote: Fri Apr 24, 2020 12:02 pm It doesn't require using .S, but if you don't, you'll have to invoke the preprocessor manually from the makefile. It's easier to just use the .S extension and then go to town with #define and whatnot. That's what the .S does - signal gcc that it should automatically invoke the preprocessor before invoking the assembler.
Perhaps the handiest thing about being able to use the preprocessor is defining structures in the regular C manner. Defining structs in assembly is always more of a hassle.