From cc3982442e57aa2bf7fd197823c1f8aec2a3d3df Mon Sep 17 00:00:00 2001 From: Jason <154414066+bou-samra@users.noreply.github.com> Date: Mon, 8 Dec 2025 20:34:12 +1100 Subject: [PATCH] Update README.md --- README.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index aaab381..5c091ee 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,29 @@ PRINT "Returned value in R0 was 42" ## What Does This Thumb-2 Machine Code Do? -* The **first 32-bit word** (`00000000`) is the **entry point offset**, meaning execution starts at the first instruction. -* The **second 32-bit word** (`20420047`) encodes **two Thumb instructions**: +### `CSUB simple` +- Starts the definition of a machine-code subroutine named `simple`. +- Tells the BASIC runtime that the following hex words are compiled machine code to execute when `simple()` is called. - * `movs r0, #42` (load immediate value 42 into register R0), - * `bx lr` (branch to link register, i.e., return). -* When `test()` is called, it runs these two instructions: loads 42 into R0 (commonly used to return values) and then returns. -* The BASIC program then continues and prints `Returned value in R0 was 42`. +### `00000000` +- The entry point offset for the CSUB. +- A value of `0` indicates execution starts immediately at the next word. +- This word is metadata only; it is **not executed** as machine code. + +### `00004770` +- Encodes the Thumb instruction `BX LR` (Branch to Link Register). +- This instruction **returns immediately** from the subroutine to BASIC. + +### `END CSUB` +- Marks the end of the CSUB block. +- Signals that the machine code definition is complete, and BASIC execution continues normally. + +### `simple()` +- Calls the subroutine `simple`. +- Execution jumps to the CSUB, reads the entry point offset, executes the `BX LR` instruction, and immediately returns. + +### `PRINT " Returned successfully"` +- Prints a message to the BASIC console to indicate the subroutine returned successfully. ---