From: Christian Krüger (christian.krueger_at_pace.de)
Date: 2003-01-22 14:18:38
Hi,
>So if I need it, but don't fetch it again, how do I get the value?
>Values don't come from nowhere, so I would have to remember the value
>somewhere. And since the 6502 doesn't have many registers, there is no
>place, where a value can be remembered effectively. Which in turn means
>that the optimization does not work on the 6502 architecture.
what I tried to explain was, that especially in conjunction with
fastcall 'const' can be used to save some code & cycles.
Last try to show that out: ;-)
The following C sample code...
--8<------------------------
void __fastcall__ SetForeground(const unsigned char value);
void __fastcall__ SetBackground(const unsigned char value);
void
func(void)
{
unsigned char color = 42;
SetForeground(color);
SetBackground(color);
}
--8<------------------------
...will be translated to...
--8<------------------------
...(header skipped)...
; ---------------------------------------------------------------
; void func (void)
; ---------------------------------------------------------------
.segment "CODE"
.proc _func
.segment "CODE"
lda #$2A
jsr pusha
ldy #$00
lda (sp),y
jsr _SetForeground
ldy #$00 ; NO NEED TO DO THAT!!!
lda (sp),y ; " " " " "
jsr _SetBackground
jsr incsp1
rts
.endproc
--8<------------------------
When 'const' mean, that no change to the given value
is allowed, and the given value is in accu/x, then
cc65 can rely on, that accu/x won't change inside the
function!
To go further, I mentioned, that the optimizer may can
proof if inside of any function are register *writes*
to avoid useless save and restore cycles of registers
- independent from 'const'.
But to come back to the floor ;^), when somebody ask
me what I like to see first, I would grab my old wish
out of the box: inline functions (even when I have worse
assumptions, which problems are tied to that feature...)
Anyhow, after a long, long idle time, my Lynx contribution
takes (slowly) shape...
Thx for listening
chrisker
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-01-22 14:21:02 CET