Re: [cc65] New .IDENT function

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2005-05-10 21:07:44
On Tue, May 10, 2005 at 08:34:49AM +0200, 42Bastian Schick wrote:
> With a small change in FuncString:
[...]
> following works:

I'm no fan of special purpose solutions. If possible, I try to find more
generic solutions that can be used for a broader set of problems. Therefore
I've added a new .SPRINTF function that takes a format string and an argument
list, and returns a string. Most features of C printf are available, missing
ones are some specifiers (floats, pointers, ...) and variable width specifiers
(*).

Using .sprintf, your example can be implemened as

        q = 10
        .ident (.sprintf ("a%d", q)):
                .byte   .sprintf ("%d", q)
                .byte   .string (q)
                .byte   .sprintf ("%d", q+10)

but you can also do things like:

        q = 346
        .ident (.sprintf ("L%04X", q)):         ; Generates L015A:

        .macro  pad     str
                .byte   .sprintf ("%-10s", str)
        .endmacro

and similar.

The changes are already on the ftp server.

> BTW: Sorry for putting hands on the sources, but they are simply inviting

They are available for exactly this purpose:-)

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 Tue May 10 21:07:56 2005

This archive was generated by hypermail 2.1.8 : 2005-05-10 21:07:58 CEST