Page 2 of 2

Re: Alternative to Vasm assembler?

Posted: Sat Apr 25, 2020 6:35 pm
by Miquel
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.

Re: Alternative to Vasm assembler?

Posted: Thu Apr 30, 2020 12:52 am
by MrD
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

Re: Alternative to Vasm assembler?

Posted: Thu Apr 30, 2020 9:21 pm
by Miquel
As far as I know that can’t be done: the problem is that symbols '/' and '-' are interpreted as division and minus.

Re: Alternative to Vasm assembler?

Posted: Sun May 03, 2020 9:27 am
by MrD
Looks like asmx let 'lsl.l #2,a0' through emitting no opcodes without an error, gotta look into that.

Re: Alternative to Vasm assembler?

Posted: Mon May 04, 2020 4:43 am
by Sik
Make sure to enable errors. For some reason asmx has error reporting disabled by default… (why is that even a setting?!)

Re: Alternative to Vasm assembler?

Posted: Mon May 04, 2020 3:12 pm
by Chilly Willy
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.

Re: Alternative to Vasm assembler?

Posted: Mon May 04, 2020 7:29 pm
by MrD
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.

Re: Alternative to Vasm assembler?

Posted: Mon May 04, 2020 8:19 pm
by Chilly Willy
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.

Re: Alternative to Vasm assembler?

Posted: Tue May 05, 2020 7:44 am
by MrD
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 :) )

Re: Alternative to Vasm assembler?

Posted: Tue May 05, 2020 8:44 pm
by Chilly Willy
Well, the code is really straightforward, and the bug was pretty easy to spot. Took me maybe two minutes to figure it out. :lol:

Re: Alternative to Vasm assembler?

Posted: Thu May 28, 2020 10:08 pm
by MrD
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..

Re: Alternative to Vasm assembler?

Posted: Thu May 28, 2020 10:22 pm
by Chilly Willy
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:

Re: Alternative to Vasm assembler?

Posted: Thu May 28, 2020 10:36 pm
by MrD
Awesome, thanks. I didn't understand that part of the docs.