[Accidentally posted to Google Groups first] I'm finally doing some work on Leo's PIR Z-machine interpreter. (I've added about 15 opcodes to the 10 or so he started with. Luckily, he did a lot of the infrastructure stuff that scared me as a PIR newbie. The tester I wrote while developing Plotz passes 85 tests. Mostly.)
The compiler translates Z-code into PIR, then compiles and runs it. The image of the Z-file (where the Z-machine stores its global variables and other useful things) is stored in a global called Image. So if you need to access one of the Z-machine's global variables, you emit code like: .local pmc image image = global 'Image' .GET_WORD($I181 , image, 692) where the last line is a macro that pulls the global variable out of the Z-machine memory. But Leo was smart and, while translating, says to only load image (i.e. to only output the first two lines) once per Z-code subroutine. Now here's the problem. My Z-code emitted code like this: if $I17 == 3 goto L1234 .local pmc image image = global 'Image' .GET_WORD($I181 , image, 692) L1234: print "yes, blah" .GET_WORD($I182 , image, 692) If $I17==3, then when we get to the second GET_WORD we exit with an error because we don't know what image is. So I think to avoid these problems I need to declare image at the top of every Z-code sub. My question is, is there any cost associated with always declaring this array holding 50-500K ints, other than having one P register always full? Since everything else in the translated code is integers & strings I'm not really worried about filling my P registers. The only other option I can think of is keeping track of how my scopes are nesting while translating, which sounds like a disaster. This is what I get for trying to develop in PIR after ignoring the mailing list for 6 months and not reading the basic docs. Thanks, -Amir Karger It's better to write me at [EMAIL PROTECTED] ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs