This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

ASM6 Macros

ASM6 Macros
by on (#75863)
Right now I'm trying to convert some source code to ASM6. I'm having problems trying to figure out a macro in ASM6 that will work and mesh in properly with the code without having to rewrite a good portion of it. Which i don't want to do without causing it not to run.

The simple macros I know. Such as;

MACRO NAME
code....
ENDM


MACRO setAXY x,y,z
LDA #x
LDX #y
LDY #z
ENDM


I wonder if there are any other configurations? The source code that I'm dealing with is from the old PDS 6502 assembler with different macro syntax and supports some "expressions" or operators specifically for macros.


Code:
VRSET   $2000 ; called macro in code

MACRO   VRSET
   LDA   #>@1
   STA   $2006
   LDA   #<@1
   STA   $2006
   ENDM


What this does is pretty obvious but what makes it different is the @ character. That means which operand is going to be used. You can have 1-9 of them and there are a few in this code that use many.

For example.

Code:

EXAMPLE $2000,4*4,$85 ; from code.

MACRO EXAMPLE
            LDA #>@1
            STA $2006
            LDA #<@1
            STA $2006
            LDA #@2
            STA $2007
            LDA #@3
            STA $2007
            ENDM


Is there a way to do this in ASM6? That is what I want to know.


EDIT: I think I just figured it out. I'll keep you posted.
Re: ASM6 Macros
by on (#75885)
Gil-Galad wrote:
Is there a way to do this in ASM6? That is what I want to know.


Isn't it just:

MACRO name arg1, arg2, arg3
LDA arg1
LDX arg2
LDY arg3
ENDM

name 10, 20, 30

I must be missing something but it doesn't look like you need to do any complicated translations.
Gil-Galad wrote:
EDIT: I think I just figured it out. I'll keep you posted.


Ok.