Re: [cc65] macro woes

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2005-03-16 18:43:44
On Wed, Mar 16, 2005 at 06:15:58PM +0100, MagerValp wrote:
> ca65 macros just don't like me. How do I check if an argument is a
> string?

Using .match, as you did.

> '"' never matches, " and \" gives me syntax errors instead. In
> printfargs I have the same problem when I try to match '$'...

You're thinking too complicated:-) The following checks if str is a string
token:

        .if (.match(str, ""))

If str is a string and "" is a string, the pseudo function will return true.
Since "" is obviously a string, the only condition to meet is that str is also
a string. .match doesn't care for the contents of the strings. The content of
a string is it's attribute (similar as the value for a number token). So if
you need to check for the string "foobar" you can use the .xmatch function,
which will do the same as .match, but will also compare token attributes:

        .if (.xmatch(str, "foobar"))

If you don't plan to pass an argument consisting of multiple tokens (like

        label + 3

), there's no need to extract the first one using .left. If you want to allow
mutiple tokens, the expression is

        .if (.match(.left (1, str), ""))

In your case, I would say that you don't need .left, because if str is not a
single string token, the 

        .addr   str

code will be assembled, and the assembler will reject things like

        "foo" + 3

or similar.

> Also, would it be possible for ca65 to spit out the expanded macro
> when an error occurs inside it? It would also help if listings had the
> expanded macro code.

I see your point, but macros aren't stored as a textual representation. It
would be possible to translate them back, but they won't look identical and
therefore it is not possible to pinpoint the error in the original code
location. Maybe I can come up with something clever, but currently I have no
real idea how to do it (without anyone complaining about the result, that
is:-).

Regards


        Uz


-- 
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 Wed Mar 16 18:43:48 2005

This archive was generated by hypermail 2.1.8 : 2005-03-16 18:43:54 CET