-
Notifications
You must be signed in to change notification settings - Fork 1
Control flow instructions
Guillaume DERAMCHI edited this page Feb 22, 2024
·
8 revisions
Control flow instructions in the virtual processor's assembly language guide the program's execution flow.
| Instruction | Syntax | Binary Code | Usage | Error Check |
|---|---|---|---|---|
goto |
goto label1 |
0000 1000 0101 0110(Op code: 0 0001) |
Unconditionally jumps to the specified label. | Confirm label existence. |
call |
call label1 |
0001 0000 0101 0110(Op code: 00010) |
Calls a subroutine at label1. |
Verify label existence. |
ret |
ret |
1011 0000 0000 0000(Op code: 1 0110) |
Returns from a subroutine. | Use only after a call instruction. |
-
Using goto:
goto mainLoop ; Jumps to the label 'mainLoop'
-
Calling a subroutine:
call computeValue ; Calls the subroutine 'computeValue'
-
Returning from a subroutine:
ret ; Returns control to the point after the last call