Access to GOSUB return address on BS2E
Martin_H
Posts: 4,051
In the Basic Stamp 1 W6 held the return address after a GOSUB.· I'm wondering if on the Basic Stamp 2E if there's a way to access the GOSUB return address?· What I would like to do is in my main module call a TaskDispatch
TaskDispatch:
· ' Store GOSUB return address in the Scratchpad
· PUT 0, Word·W6··· ' I know its not W6·on the BS2E
· PUT 2, TaskIndex
· RUN TaskBank
At the head of the main module I would see if there was a return address at 0 in the scratch pad and then load it into the location that holds the GOSUB return address. I would then execute a return so I could resume program execution where· I called TaskDispatch.
· Task = TaskReadLine
· GOSUB TaskDispatch
· ' More stuff after the GOSUB
If there's no way to access the GOSUB return address I have another way to do it using GOTO's and a BRANCH at the head of the module.· It would be much cooler with access to the return address.
TaskDispatch:
· ' Store GOSUB return address in the Scratchpad
· PUT 0, Word·W6··· ' I know its not W6·on the BS2E
· PUT 2, TaskIndex
· RUN TaskBank
At the head of the main module I would see if there was a return address at 0 in the scratch pad and then load it into the location that holds the GOSUB return address. I would then execute a return so I could resume program execution where· I called TaskDispatch.
· Task = TaskReadLine
· GOSUB TaskDispatch
· ' More stuff after the GOSUB
If there's no way to access the GOSUB return address I have another way to do it using GOTO's and a BRANCH at the head of the module.· It would be much cooler with access to the return address.
Comments
The Stamp2 uses an indexed stack scheme similar to the BS1. The stack does not hold the actual return address, rather, it holds an index into a table of return addresses that are stored at the top of the eeprom program memory.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com