Re: [cc65] Register variables

Date view Thread view Subject view

From: Marko Mäkelä (msmakela_at_cc.hut.fi)
Date: 1999-07-19 08:14:50


On Fri, 16 Jul 1999, Ullrich von Bassewitz wrote:

> Variable c is assigned to the first byte in the register space. When calling
> f(), a pointer to this location is passed. Unfortunately the variable i will
> occupy the same space as c: The old value is saved and the storage is reused.

Couldn't you forbid the & operator for register variables?  Or save the
register calls on the stack before the function call and pass the address
of the stack location?  Note that for the latter, you must handle nested
function calls properly, e.g. f(g(&x)) must store x on stack before
calling g and restore it after calling x.  And I think the standard would
allow you to do f(g(&x),x) in the same way: even if g() modifies x, it is
implementation-defined whether f() gets the modified x as its second
parameter.

Remember that you will have to store register variables on stack every
time you call a function that has register variables or that calls a
function that has register variables.  I guess it's easiest to always
store the register variables before every function call.  Some life-time
analysis could be useful: if a variable is only used in the beginning of
a function, you can discard it when doing a function call at the end of
the function.

> But the current compiler implementation does not generate explicit
> parse trees, and adding it is a real lot of work

How does it work then?  What kind of a parser is it?  Hand-written
top-down or what?

	Marko

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:44 CET