m68k-atari-mint-as: string literals in opcodes

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

m68k-atari-mint-as: string literals in opcodes

Postby simonsunnyboy » Wed Apr 16, 2014 6:42 pm

While assembling some files with GNu as, I noticed that the classic Motorola/DEVPAC syntax for string literals inside opcodes does not work:

Code: Select all

cmp.l #'_MCH',d0


Is there a way with GNU as to do the same WITHOUT having to make an .equ which resolves the value by hand (like I have to do below)?

Code: Select all

.equ    MCH,0x5f4d4348
...
cmp.l #MCH,d0
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
mfro
Atari Super Hero
Atari Super Hero
Posts: 791
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: m68k-atari-mint-as: string literals in opcodes

Postby mfro » Wed Apr 16, 2014 7:11 pm

No, I don't think so. The closest I could get when facing the same problem was this:

Code: Select all

        .macro mchar  st,a,b,c,d,tgt
            \st #\a << 24|\b<<16|\c<<8|\d,\tgt
        .endm


You can then use it like

Code: Select all

        mchar    move.l, 'T,'E,'S,'T,-(SP)


Not nice, but at least somewhat readable. If anybody has a better solution, I'd be interested also.

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3474
Joined: Sat Jun 30, 2012 9:33 am

Re: m68k-atari-mint-as: string literals in opcodes

Postby dml » Wed Apr 16, 2014 8:35 pm

GNU AS is a bit painful if you're used to Devpac syntax. It's pretty important to get used to it if you want to use inline assembly with C, but otherwise it might be more comfortable to just use VASM for standalone sourcefiles, which is much closer to Devpac and accepts most/all of that syntax.

VASM accepts the -Faout argument which emits GCC-friendly object files (which is great!)

Code: Select all

vasm -Faout -m68000 -o test.o test.s


There are some cross-platform advantages to the vanilla GNU toolchain but if you're aiming primarily at Atari then VASM is the easier option.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5080
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: m68k-atari-mint-as: string literals in opcodes

Postby simonsunnyboy » Thu Apr 17, 2014 10:02 am

Hmm, my m68k routines are normally rather short so I think I can live with .equ thing. Many routines can be written in C itself where that is no more an issue. I need it mostly to port existing routines over to gcc.

Even with its syntax awkwardness, I begin to like crosscompiling with gcc and a reduced startup file. The code quality is very very good and my former rants are fading away ;)
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

BlankVector
Captain Atari
Captain Atari
Posts: 472
Joined: Wed Oct 24, 2007 7:52 pm
Location: France
Contact:

Re: m68k-atari-mint-as: string literals in opcodes

Postby BlankVector » Thu Apr 17, 2014 10:27 am

simonsunnyboy wrote:While assembling some files with GNu as, I noticed that the classic Motorola/DEVPAC syntax for string literals inside opcodes does not work:

Code: Select all

cmp.l #'_MCH',d0

Is there a way with GNU as to do the same WITHOUT having to make an .equ which resolves the value by hand (like I have to do below)?

I don't think so.
However, you can have a look to the official gas documentation to discover other interesting stuff.
Subscribe to my Vretrocomputing channel on YouTube and Facebook. Latest video: Emulators.


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 3 guests