MACRO on ASM6809

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

MACRO on ASM6809

Post by pser1 »

Hello,
I would like to create a macro that should use a long branch or a short branch
upon the distance to the target label.
Say something like this:
IF (a00100 - (*+2) > 127) ; a00100 is the label where execution should branch if condition satisfied
lbeq a00100
ELSE
beq a00100
ENDIF

How could I create a macro that would receive TWO parameters: the condition Type and the destination label (both as strings)
for instance used that way: CONDJMP beq a00100 ; macro - condition - destLabel

CONDJMP MACRO
IF (\2 - (*+2) > 127) ; adding two because pointer will be already past compare line
"l"\1 ; l in front of condition to create a long branch
ELSE
\1
ENDIF
ENDM
When I compile this, I get a double error message
syntax error: TESTSPEED.ASM:9: no positional variables on stack
syntax error: TESTSPEED.ASM:11: no positional variables on stack

Does anybody know the right way to declare and use a macro with 2 parameters?
Any hint would be highly appreciated
cheers
pere
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: MACRO on ASM6809

Post by pser1 »

Hi Ciaran,
using this definition
CONDJMP MACRO
IF ( (\{1}-(*+2)) > 127)
lbeq \{1}
ELSE
beq \{1}
ENDIF
ENDM

and using it this way CONDJMP "a00100"

This is the result I get in the .lst file
1BCD CONDJMP "a00100"
IF ( (\{1}-(*+2)) > 127)
1BCD 10270000 lbeq \{1}
ELSE
beq \{1}
ENDIF
No way to use the parameter I pass to the macro , see the parameter is used as a number with value zero ...
And I would like to use it as is: a Label that will be processed by ASM6809 accordingly ...
Any idea of how to solve that?
Thanks in advace
cheers
pere
sorchard
Posts: 530
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: MACRO on ASM6809

Post by sorchard »

Hi Pere,

To answer your second question, you can specify the jump destination without quotes to pass it by value:

CONDJMP a00100

Your first question is more difficult. I've tried before and failed to pass an instruction as a macro parameter. I think it's possible to supply a string to be used as part of a label, or to be placed inside another string for example in an FCC statement, but I've not had any success supplying an instruction as a parameter.
Stew
pser1
Posts: 1655
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: MACRO on ASM6809

Post by pser1 »

sorchard wrote:Hi Pere,
To answer your second question, you can specify the jump destination without quotes to pass it by value:
CONDJMP a00100
Your first question is more difficult. I've tried before and failed to pass an instruction as a macro parameter. I think it's possible to supply a string to be used as part of a label, or to be placed inside another string for example in an FCC statement, but I've not had any success supplying an instruction as a parameter.
Hi Stew,
you are right, Kees and me have been working on that macro idea and have ended with a 'solution' as you are proposing:
The label is passed as a number (no quotes) and then the instruction as a string, which is then used in a fcb statement to form the
conditional followed by a FCB or FDB upon short/long branch with the calculated (by ASM6809) distance LABEL - * (refined with -1 or -2)
and the numeric comparison using the label works well ...
Thanks a lot
cheers
pere
User avatar
Bosco
Posts: 330
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: MACRO on ASM6809

Post by Bosco »

LWASM has an`auto branch length' option which is kind of nice.

Maybe something for a future ASM6809 update? :)
Post Reply