Return To BASIC From Machine Language
I am a VIC computerist, proficient in BASIC and learning machine language. I have a question.
When I have a BASIC program with machine language subroutines and control is transferred between them, what ways are there to transfer back from the machine language routines besides using BRK?
The machine language instruction you want to use is RTS (ReTurn from Subroutine). The RTS command ($60 or decimal 96) is a single-byte instruction that will transfer control of a machine language program back to BASIC.
It works like this. When a SYS command (branch to machine language program) is issued from within a BASIC program, the operating system automatically pushes necessary information onto the stack that tells the computer which BASIC line is to be executed next. Control of the program is then transferred to the machine language subroutine.
When an RTS is encountered within a machine language program, this "return address" information is pulled off the stack, and control is transferred back to the BASIC program at the proper place.