SGDK\ ASM with Motorola syntax

SGDK only sub forum

Moderator: Stef

Post Reply
Nainain
Interested
Posts: 14
Joined: Sat Oct 11, 2014 3:34 pm

SGDK\ ASM with Motorola syntax

Post by Nainain » Fri May 13, 2016 10:37 am

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

User avatar
Stef
Very interested
Posts: 2801
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: SGDK\ ASM with Motorola syntax

Post by Stef » Fri May 13, 2016 12:40 pm

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

Nainain
Interested
Posts: 14
Joined: Sat Oct 11, 2014 3:34 pm

Re: SGDK\ ASM with Motorola syntax

Post by Nainain » Fri May 13, 2016 1:13 pm

Hello Stef,

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

0x1A is $1A with Motorola syntax

User avatar
Stef
Very interested
Posts: 2801
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: SGDK\ ASM with Motorola syntax

Post by Stef » Fri May 13, 2016 4:30 pm

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.

Mask of Destiny
Very interested
Posts: 575
Joined: Thu Nov 30, 2006 6:30 am

Re: SGDK\ ASM with Motorola syntax

Post by Mask of Destiny » Fri May 13, 2016 6:44 pm

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.

User avatar
Sik
Very interested
Posts: 736
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: SGDK\ ASM with Motorola syntax

Post by Sik » Sat May 14, 2016 3:50 am

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.
Sik is pronounced as "seek", not as "sick".

plee
Very interested
Posts: 65
Joined: Wed Nov 29, 2006 11:32 am
Location: Houston, Texas

Re: SGDK\ ASM with Motorola syntax

Post by plee » Sun Jul 24, 2016 3:21 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest