Skip to content

Subroutine Execution

Chysn edited this page Jul 14, 2020 · 8 revisions

https://youtu.be/OpsAa4LsbCs

To execute a subroutine, first set your memory conditions with the Memory Editor, and your register conditions with the Register Editor, then execute the subroutine with

← addr

where addr is a valid 16-bit hexadecimal address.

Upon return from the subroutine with RTS, the register display will be shown.

If the code hits BRK instead of RTS, BRK will appear above the register display. In this case, you may continue code execution two bytes after the BRK with

Note: Use caution when using ← when the subroutine returns with RTS. A proper return address may not be on the stack, and the result is undefined.

Differences Between ← and SYS

← is designed to behave like you added a breakpoint to the RTS of a subroutine, without having to explicitly set the breakpoint. SYS behaves like SYS.

SYS allows a graceful exit, while ← shows the register display.

← enables wAx's BRK trapping, while SYS has no impact on the state of the BRK trapping system.

If you're generating unit tests with wAx in BASIC, you'll want to use SYS. If you want to immediately see the register and memory results of a subroutine, you may want to use ←.

SYS takes a decimal literal or variable address, while ← takes a hexadecimal address literal.