Re: [cc65] printf for ca65

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2005-03-24 11:29:52
On Wed, Mar 23, 2005 at 11:27:56AM +0100, MagerValp wrote:
> Thanks! I don't suppose 2.10.2 or 2.11 is on the horizon?

Actually, 3.0 has been on the horizon for quite some time now:-) I'm waiting
for myself to make some final changes to the preprocessor, but it seems I'm
too lazy. Seriously: There's not much left, and once I hit the road it should
be done in a weekend or so. There are also contributions, which are not quite
finished.

> What about using .define:s? Or can't they be redefined inside macros?

No, unfortunately not. Even if they could, they could not be redefined twice,
and something like this would be needed.

> There are a number of solutions for this (longbranch, change
> @error to the non-local checkgeomerror, and so on), but some way of
> saying "any @error, I don't care which one" (%error? #error? :) would
> make the source prettier, and generate shorter code.
>
> Crazy idea?

How about adding a new opcode

    BAA - BRANCH AS APPROPRIATE

in the style of

    http://www.geocities.com/HotSprings/Spa/8672/light/gflops.htm

:-)

IMHO it is a dangerous feature. Adding new code could break independent old
code, and this is usually a very good reason against a new feature. Assume
that you don't touch your code for a year or so, and then need to add new
code. You add another subroutine, but forget that there are some "branch to
the nearest XXX" instructions in the existing code. Unfortunately, your new
code uses the same label names ("@error" is a quite common label name) and
*boom* - the old code stops working.

When using real scopes instead of cheap local labels, you can access the error
labels within such a scope:

  .proc checkgeom
        ...
        clc
        rts

  error:
        sec
        rts

  .endproc

  .proc findrootdir
        lda vol_fatsize
        cmp #32
        beq findroot32

  findroot16:
        asl io_buf + $16        ; multiply fatsize by two
        rol io_buf + $17        ; possible overflow?
->      bcs checkgeom::error    ; Because findrootdir::error is out of reach

        ...

  .endproc

It would be possible to make @-labels accessible the same way. I've considered
that when extending the scoping rules some time ago, but decided against it,
because it breaks the meaning of "cheap local symbols" somehow. If @-labels
have the same features as other scoped symbols, the question why they're
necessary is unavoidable:-) If there is a really good reason, the feature
could be added without much hazzle, so your error labels could be accessed
like this:

        bcs checkgeom::@error

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 Thu Mar 24 11:29:55 2005

This archive was generated by hypermail 2.1.8 : 2005-03-24 11:30:12 CET