From: Spiro Trikaliotis (Trik-news_at_gmx.de)
Date: 2003-01-20 10:06:53
Hello Uz, you wrote on Sunday, January 19, 2003 12:24 PM: > 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. For other machines, it may be possible to > keep values in registers as long as possible, but the 6502 needs any register > it has for actual arithmetics and memory access. Hm, looking at the example of Christian: unsigned char x = 10; func1(x); // actual no need to save and restore func2(x); // accu and x (reuse) wouldn't it be possible to make it as follows, if x were declared as const unsigned char x = 10; this could be made to GET(x) PUSH() ; pushes X on stack PUSH() ; pushes X again on stack CALL FUNC1 CALL FUNC2 This would allow not to get x again, which would be a benefit, won't it? Unfortunately, I don't know how much work it would be to integrate some logic like this. BTW: What does the standard say about aliasing? I think of something like void func( const unsigned, unsigned * ); unsigned x = 1; unsigned *px = &x; func( x, &x ) Although x is a const parameter, it might be changed by func. Is a compiler allowed treat x as unchanged? One should remember that this case is obvious, but you can construct cases of wanted complexity where this use is not as obvious as here. Just curious, Spiro. ---------------------------------------------------------------------- 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-20 11:18:37 CET