-
Notifications
You must be signed in to change notification settings - Fork 1
Control flow instructions
Guillaume DERAMCHI edited this page Feb 20, 2024
·
8 revisions
Control flow instructions in the virtual processor's assembly language guide the program's execution flow.
-
Syntax:
goto label1 -
Binary code:
0000 1000 0101 0110(Op code:0 0001) - Usage: Unconditionally jumps to the specified label.
- Error check: Confirm label existence.
-
Syntax:
call label1 -
Binary code:
0001 0000 0101 0110(Op code:00010) -
Usage: Calls a subroutine at
label1. - Error check: Verify label existence.
-
Syntax:
ret -
Binary code:
1011 0000 0000 0000(Op code:1 0110) - Usage: Returns from a subroutine.
-
Error check: Use only after a
callinstruction.
-
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