Page 1 of 1

SGDK\ ASM with Motorola syntax

Posted: Fri May 13, 2016 10:37 am
by Nainain
Hello,

I start to experiment some ASM embedded in my SGDK projects ...
I use the default SGDK tool chain with GNU as ...

Can i tweak something for write my ASM with Motorola syntax, or maybe i must change the assembler in my makefile ?

Thank
Nainain

Re: SGDK\ ASM with Motorola syntax

Posted: Fri May 13, 2016 12:40 pm
by Stef
Hey Nainain :)

If you speak about the '%' register prefix, you can indeed disable it with the "--register-prefix-optional" switch, you just need to modify the makefile.gen

Re: SGDK\ ASM with Motorola syntax

Posted: Fri May 13, 2016 1:13 pm
by Nainain
Hello Stef,

But i dont know if it can works well with the hexa notation too

0x1A is $1A with Motorola syntax

Re: SGDK\ ASM with Motorola syntax

Posted: Fri May 13, 2016 4:30 pm
by Stef
No, i don't think you can do that, just remove the '%' prefix for register. '$' is used as a special character in GAS.
But now i'm thinking about it, there is a tool in SGDK, which, i believe, convert from motorola assembly syntax in GAS (tool is called mac68k).
If you write your assembly code inside a .asm file SGDK will assume it as motorola assembly where .s are taken as classic GAS assembly file.

Re: SGDK\ ASM with Motorola syntax

Posted: Fri May 13, 2016 6:44 pm
by Mask of Destiny
For what it's worth, vasm (which has a Motorola syntax module) supports ELF output that can theoretically be linked in with a gcc project.

Re: SGDK\ ASM with Motorola syntax

Posted: Sat May 14, 2016 3:50 am
by Sik
I do believe there's a command line argument that makes GAS take Motorola syntax (still not 100% compatible though, mostly directives). The problem is that if I recall correctly that makes it incompatible with GCC's output, so you can't use it for inline asm. I need to look into it again.

Re: SGDK\ ASM with Motorola syntax

Posted: Sun Jul 24, 2016 3:21 am
by plee
A bit late, but here is a snippet of code I converted from the Atari ST Star Raiders to the GCC .asm file. It was a pain at first but you start getting the idea after awhile... Hope this might help

*
* INITSTAFT Initializes AFT stars
*
* Given:
* STARLIST = address of list of stars X and Y
*
* Returns:
* all stars X and Y randomly initialized
*
* Register Usage:
* destroys a0 and d0-d6
*
* Externals:
* randu
*
initStarsAft:
movea.l #starAftlist,%a0
movea.l #startime,%a1
move #(nstarsaft-1),%d6 | FOR (all stars) DO
instarlp:
jsr random32 | get 24-bit random number
swap %d0
ori #2,%d0 | ensure non-zero
ext %d0
asr #1,%d0
swap %d0 | sign-extended to a 32-bit random
move.l %d0,(%a0)+ | Xpos = {-64 .. 63}

jsr random32 | get 24-bit random number
swap %d0
ori #4,%d0 | ensure non-zero
ext %d0
asr #2,%d0
swap %d0 | sign-extended to a 32-bit random
move.l %d0,(%a0)+ | Ypos = {-32 .. 31}

jsr random32
and #starlife,%d0
move %d0,(%a1)+ | Start Star Timer

dbra %d6,instarlp
rts


*
* DATA STORAGE
*

.bss

.globl starAftlist

starAftlist:
.ds.l nstarsaft | X-position (lo-word=fractional part)
.ds.l nstarsaft | Y-position (lo-word=fractional part)
startime:
.ds.w nstarsaft | Star Lifetime Counter