[Coco] Assembly language question: The stack
lost at l-w.ca
Thu Oct 25 13:17:47 EDT 2018
The code in the interpreter is a little less straight forward than that,
but the resulting behaviour is equivalent to a JSR to your program so
that is a reasonable mental model to work with. I only mention this in
case anyone starts looking at the disassembly of the EXEC command in the
Unravelled series and is confused by it.
On 2018-10-25 10:55 AM, tim franklinlabs.com wrote:
> The BASIC "EXEC" command has a command in it; JSR (address of your
> program). After the JSR command, there's more code which is the
> continuation of the BASIC interpreter. When you type EXEC $1234, the
> CPU will get to the JSR mnemonic and call your program. In doing so,
> it puts the address of the next byte (plus the data bytes) after the
> JSR command on the stack. This is the return address. Once pushed, the
> Program counter gets loaded with the entry point of your binary code
> and runs it. Your code should end with either an RTS or a PULS PC (same
> as RTS). This will pull the return address off the stack and put it in
> the program counter. This address is the point after the original JSR.
> Basic then continues from that point.
> Simple, no?
> On October 25, 2018 at 11:03 AM Luis Fern?ndez
> <luis46coco at hotmail.com> wrote:
> >So the mnemonic would be RTB?
> No, RTS Normal
> It depends on how the call to the Asembler started, normally the
> stack retains the return address to the basic and when doing an RTS,
> it returns to the basic after the call
> Coco mailing list
> Coco at maltedmedia.com
> 1. mailto:luis46coco at hotmail.com
> 2. mailto:Coco at maltedmedia.com
> 3. https://pairlist5.pair.net/mailman/listinfo/coco
More information about the Coco