Generating address labels

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating address labels

ElliotW
I'm a little confused about how to create the return address labels for the 'call' and 'return' command.  
Firstly, how do we push the return-address in call? Is it simply @[label] and then pushing that value onto the stack?  
And to Goto the return address, wouldn't the argument passed in the translator be an integer, which is the wrong type when processing a Goto command?
Reply | Threaded
Open this post in threaded view
|

Re: Generating address labels

WBahn
Administrator
It's a bit hard to tell, but I think you have the right idea.

What do you mean with the square brackets when you say "@[label]"? That's not a notation I recall seeing in the text, so I'm not exactly sure what you have in mind. But, yes, you create a label at the line of code that you want to return to and then that label is now associated with that address (which is just an integer) and that's what you put on the stack and, eventually, it gets put in the A register and then an unconditional jump is executed.

As for the data types, all of the data types used by this computer (and all of the language types) are all intercompatible in that at the end of the day they are all 16-bit signed integers. That was done very deliberately so that type systems and type checking could be neatly sidestepped, which is important given the course's very broad scope -- depth had to be extremely limited pretty much across the board.