[Coco] Assembly language question: The stack

tim franklinlabs.com tim at franklinlabs.com
Thu Oct 25 12:55:18 EDT 2018


   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
     <[1]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
     [2]Coco at maltedmedia.com
     [3]https://pairlist5.pair.net/mailman/listinfo/coco

References

   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 mailing list