-
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 are crucial in the assembly language for the Virtual Processor, directing the flow of execution within the program.
-
Syntax:
goto label1 - Function: Unconditionally jumps to the specified label.
-
Binary code:
0000 1000 0101 0110(label id) - Error check: Ensure the label exists.
-
Syntax:
call label1 -
Function: Calls a subroutine located at
label1. -
Binary code:
0001 0000 0101 0110(label id) - Error check: Verify the existence of the label.
-
Syntax:
ret - Function: Returns from a subroutine to the calling point.
-
Binary code:
1011 0000 0000 0000 -
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