register variables allocation in Pyramids

Chris Torek chris at umcp-cs.UUCP
Sat Jul 6 09:14:49 AEST 1985


Close, but the temporary registers become the called procedure's
parameter registers, not vice versa.  I.e., after

_main:
	tr0 = 4		# put 4 in temp reg 0
	tr1 = 32
	call _foo

(I'm not going to use real Pyramid assembly) in foo, pr0 is 4 and
pr1 is 32.  foo's pr0 has the same address as main's tr0, of course,
so after foo does

	pr0 = 0
	ret

main has tr0 = 0.  This is how "return(expr);" works (if expr fits
in registers).  (There is also a bug in the compiler that is related
to this.)

Incidentally, although there are 16 of each type of register (global,
parameter, local, and temporary/transfer [transfer is my personal
name for 'em just before a call]), only 12 of each can be used,
since the others are "special".  (Or at least the compiler only
uses 12.  I don't know what the extra pr's, lr's, and tr's do; but
the gr's are stack & frame & so forth, I think.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list