Re: [cc65] printf for ca65

From: MagerValp <MagerValp1cling.gu.se>
Date: 2005-03-23 11:27:56
>>>>> "UvB" == Ullrich von Bassewitz <uz@musoftware.de> writes:

UvB> I broke it when I changed the scanner to return different tokens
UvB> for normal and cheap local identifiers. Here is the necessary
UvB> patch:

Thanks! I don't suppose 2.10.2 or 2.11 is on the horizon?

UvB> This is interesting and stimulates my play instinct:-) A cool
UvB> extension would be to preparse the format string in the macro
UvB> itself saving some code in the console_printf subroutine. I'm not
UvB> sure if this is possible, or even useful, but it would be fun.

Glad you like it :)

UvB> Thinking twice about it, variables would be needed, so it's
UvB> probably impossible without more features in the assembler. What
UvB> a pity:-)

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


I also got an idea right now for something one could call equivalent
labels. That is, I end up with a bunch of labels looking like this:

  @error:
	sec
	rts

With branches being limited to 7-bit, the error routine isn't always
within reach in long routines. The longbranch macpack solves the
problem, but more often than not an @error from the previous or
following subroutine is in reach, but can't be addressed due to label
scoping. Like so:

  checkgeom:
	lda io_buf + $0b	; make sure sector size is 512
	bne @error
	lda io_buf + $0c
	cmp #2
	bne @error

	lda io_buf + $10	; make sure there are 2 FATs
	cmp #2
	bne @error

	lda io_buf + $0d	; number of sectors per cluster
	sta vol_secperclus
	clc
	rts

  @error:
	sec
	rts

  findrootdir:
	lda vol_fatsize
	cmp #32
	beq @findroot32

  @findroot16:
	asl io_buf + $16	; multiply fatsize by two
	rol io_buf + $17	; possible overflow?
	bcs @error

That last bcs @error is out of range of the error routine in
findrootdir, but could be redirected to the error routine in checkgeom
instead. 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?

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp@cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
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 23 11:27:58 2005

This archive was generated by hypermail 2.1.8 : 2005-03-23 11:28:04 CET