[Coco] lbsr and rts

Darren A mechacoco at gmail.com
Wed Sep 16 15:13:22 EDT 2009


On 9/16/09, Wayne Campbell <asa.rand at yahoo.com> wrote:
> I may be missing something, but I thought calls to subroutines required a
> rts instruction. In Basic09, there has to be a RETURN statement for any
> given GOSUB, but not necessarily one-for-one.

---

In 6809 assembly language you will often see a PULS instruction rather
than an RTS to return from a subroutine.  This is often the case when
registers have been preserved by the routine's prolog:

L1  PSHS  B,X
    ...
    PULS  B,X,PC

In some cases the subroutine may pull the return address from the
stack into an index register and then jump to it:

    PULS  X
    ...
    JMP   ,X

Less often, the return address may simply be purged from the stack in
order to eliminate the subroutine "call":

    LEAS  2,S

In a nutshell, there are no hard and fast rules as to how assembly
code must be structured.

Darren



More information about the Coco mailing list