Alternative to Vasm assembler?

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Alternative to Vasm assembler?

Post by Miquel » Sat Apr 25, 2020 6:35 pm

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 didn't know! investigation about to lunch.
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.
I'm not sure this is what you want, but with defines/macros you can do something like this:

speedX = d7
speedY = d3
accX = a0
accY = d5

addq.w #1, speedX
movem.w speedX/speedY/accX/accY, -(sp)
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.
With macros you can do something like this:

.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.
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.
You can use macros to simplify and create structures in a C fashion too. Or even a C++ parental structure, do is more complex.
HELP. Spanish TVs are brain washing people to be hostile to me.

MrD
Very interested
Posts: 70
Joined: Sun Jan 26, 2014 4:29 pm

Re: Alternative to Vasm assembler?

Post by MrD » Thu Apr 30, 2020 12:52 am

I'm not sure this is what you want, but with defines/macros you can do something like this:

speedX = d7
speedY = d3
accX = a0
accY = d5

addq.w #1, speedX
movem.w speedX/speedY/accX/accY, -(sp)
Similar, but what I want to do is this:

Code: Select all

complicated_maths:
   movem.l complicated_maths_regs,-(a7)
   ; code
   movem.l (a7)+,complicated_maths_regs
   rts
   
complicated_maths_regs reg d0/d1/a0-a3/a6

Miquel
Very interested
Posts: 514
Joined: Sat Jul 30, 2016 12:33 am

Re: Alternative to Vasm assembler?

Post by Miquel » Thu Apr 30, 2020 9:21 pm

As far as I know that can’t be done: the problem is that symbols '/' and '-' are interpreted as division and minus.
HELP. Spanish TVs are brain washing people to be hostile to me.

MrD
Very interested
Posts: 70
Joined: Sun Jan 26, 2014 4:29 pm

Re: Alternative to Vasm assembler?

Post by MrD » Sun May 03, 2020 9:27 am

Looks like asmx let 'lsl.l #2,a0' through emitting no opcodes without an error, gotta look into that.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Alternative to Vasm assembler?

Post by Sik » Mon May 04, 2020 4:43 am

Make sure to enable errors. For some reason asmx has error reporting disabled by default… (why is that even a setting?!)
Sik is pronounced as "seek", not as "sick".

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Alternative to Vasm assembler?

Post by Chilly Willy » Mon May 04, 2020 3:12 pm

Sik wrote:
Mon May 04, 2020 4:43 am
Make sure to enable errors. For some reason asmx has error reporting disabled by default… (why is that even a setting?!)
Yeah, I can see making ignore WARNINGS default, but not errors. That's just crazy! :lol:

Might be because the guy who originally wrote it used to assembler batches of files and hated that it stopped every time it hit a single error and wanted it to go through ALL files so he could compile a list of all errors at once.

MrD
Very interested
Posts: 70
Joined: Sun Jan 26, 2014 4:29 pm

Re: Alternative to Vasm assembler?

Post by MrD » Mon May 04, 2020 7:29 pm

Sik wrote:
Mon May 04, 2020 4:43 am
Make sure to enable errors. For some reason asmx has error reporting disabled by default… (why is that even a setting?!)
I might be half asleep, but I'm not that asleep. :)

You can test it yourself by assembling

Code: Select all

 lsl.l  #2,a0
 lsl.l  #2,d0
with

Code: Select all

asm68kt.exe -C 68K -b 0 -e -w test.asm -o test.bin
The output is 2 bytes long.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Alternative to Vasm assembler?

Post by Chilly Willy » Mon May 04, 2020 8:19 pm

It's a bug in o_Shift in asm68k.c.

Code: Select all

                reg1 = GetReg(data_regs);
                if (reg1 >= 0)
There's no else part that throws an error on the register not being found from the list passed.

MrD
Very interested
Posts: 70
Joined: Sun Jan 26, 2014 4:29 pm

Re: Alternative to Vasm assembler?

Post by MrD » Tue May 05, 2020 7:44 am

Chilly Willy wrote:
Mon May 04, 2020 8:19 pm
It's a bug in o_Shift in asm68k.c.

Code: Select all

                reg1 = GetReg(data_regs);
                if (reg1 >= 0)
There's no else part that throws an error on the register not being found from the list passed.
Oh hey thanks! :D (if it wasn't clear, when I said 'gotta look into that' I meant it as a note to myself to be curious, not at you or Bruce or anyone :) )

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Alternative to Vasm assembler?

Post by Chilly Willy » Tue May 05, 2020 8:44 pm

Well, the code is really straightforward, and the bug was pretty easy to spot. Took me maybe two minutes to figure it out. :lol:

MrD
Very interested
Posts: 70
Joined: Sun Jan 26, 2014 4:29 pm

Re: Alternative to Vasm assembler?

Post by MrD » Thu May 28, 2020 10:08 pm

Does anyone know if asmx supports anonymous temporary labels like some C64 assemblers do, using multiple + and - to refer to the Nth most recent use of those symbols as a label?

My personal coding style results in long subroutine and variable names, and all my branch labels right now are prefixed with the name of the containing subroutine, leading to things like 'regeneration_screen_regeneration_termination_event_clear_old_title_next_tegel' for tiny loops..
Last edited by MrD on Thu May 28, 2020 10:41 pm, edited 1 time in total.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Alternative to Vasm assembler?

Post by Chilly Willy » Thu May 28, 2020 10:22 pm

Asmx use @whatever or .whatever for local labels. They're usable until you pass a non-local label. This is pretty standard for many assemblers. So it's like this

Code: Select all

first_label:
    code
    more code
.1
    even more code
.2
    check something
    bmi.b .1
    bne.b .2
    rts

next_label:

MrD
Very interested
Posts: 70
Joined: Sun Jan 26, 2014 4:29 pm

Re: Alternative to Vasm assembler?

Post by MrD » Thu May 28, 2020 10:36 pm

Awesome, thanks. I didn't understand that part of the docs.

Post Reply