Re: [cc65] ldax macro

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2004-09-30 13:48:13
On Thu, Sep 30, 2004 at 01:29:26PM +0200, MagerValp wrote:
> I'm using the ldax macro from the ca65 docs:
[...]
> and it dies with a weird error if you use an arg with parenthesis,
> like so:
[...]

From ca65.sgml:

------------------------------------------------------------------------------
<tscreen><verb>
        .macro  ldax    arg
                .if (.match (.left (1, {arg}), #))
                    ; immediate mode
                    lda     #<(.right (.tcount ({arg})-1, {arg}))
                    ldx     #>(.right (.tcount ({arg})-1, {arg}))
                .else
                    ; assume absolute or zero page
                    lda     arg
                    ldx     1+({arg})
                .endif
        .endmacro
</verb></tscreen>

Using the <tt/<ref id=".MATCH" name=".MATCH">/ function, the macro is able to
check if its argument begins with a hash mark. If so, two immediate loads are
emitted, Otherwise a load from an absolute zero page memory location is
assumed. Please note how the curly braces are used to enclose parameters to
pseudo functions handling token lists. This is necessary, because the token
lists may include commas or parens, which would be treated by the assembler
as end-of-list.
------------------------------------------------------------------------------

The problem is that (13) is passed to the macro and inserted as is into the
.left, .right and .tcount commands. These treat parens and commas special. The
introduction of curly braces to terminate token lists is new in the
development version. The current stable version should work without problems
for parens (as in your case), but would treat the comma special. So I assume
you're using the development version from where the paragraph above was taken.

Regards


        Uz
  

P.S.: I'm out of town until tomorrow evening. I will comment on the floating
point issue when I'm back.

-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu, 30 Sep 2004 13:48:13 +0200

This archive was generated by hypermail 2.1.8 : 2004-09-30 13:48:26 CEST