-
Notifications
You must be signed in to change notification settings - Fork 0
Registers
The MVM (Micro Virtual Machine) uses registers to store data actively being processed. Registers provide fast access to data during program execution. The MVM uses several types of registers, each serving a specific purpose. All registers are 64 bits wide unless otherwise noted.
These registers are used for general computations, data storage, and calculations. They can be used as operands in all instructions.
lit G1 10 // Load the literal value 10 into register G1These registers are used for system calls. S1 holds the system call ID; S2, S3, and S4 pass arguments to the
system call.
lit S1 24 // Load system call 24 (writeIo) into S1
mov G1 S2 // Pass string address to S2
syscall // Make system callThese registers typically hold the results of operations (arithmetic, comparison, bitwise) and system calls
-
R1is usually returned by standard library operations -
R2is conventionally used for system call return values. -
R3typically holds results from bitwise operations. -
R4conventionally holds results from arithmetic, comparison, and string operations. -
R5conventionally holds results from floating-point operations. NoteR5By default is a FLOAT Register type so this is recommended. -
R6conventionally holds results fromINRinstructions.
add G1 G2 R4 // Result of addition is in R4These registers are used exclusively for passing arguments to functions (subroutines). Arguments are placed in these registers before the function call.
lit F1 10 // Load argument 1 into F1
call maths.sq // Call the square function
prints // Print the result on the stack, 100. 10 * 10 These registers are used for floating-point arithmetic operations. By defult these are Floats. Not Doubles
xlit X1 3.14159 // Load a floating-point literalThese registers hold status flags and other metadata. They are set implicitly by various instructions and are not directly modified by most instructions.
-
I1Set if the last operation resulted in zero. -
I2Set if the last arithmetic operation's result was negative. -
I3Set according to the lastGTorLTcomparison. -
I4Set if the lastEQcomparison was true. -
I5Indicates system call success. -
I6Indicates a general error. -
I7Holds a code specifying the error type. -
I8Holds the address of the next instruction to execute. -
I9Set when a signal is received. -
I10Stores the ID for inter-process communication.
see for more information -> Informational Registers
All registers are 64 bits wide, capable of storing 64-bit integer values, or a floating point number of any type,
depending on the register data type assigned using the SETTYPE instruction.
The options are BYTE, SHORT, INT, LONG, FLOAT, and DOUBLE.
Registers are accessed by name (e.g., G1, S2, R4, X1, I8) in MVM assembly instructions.
Registers are initialised to 0 when a process is created.
lit F1 5 // Load argument 1 into F1
lit F2 1 // Load argument 2 into F2
call test // Call the test function
pop R1 // Get the return value from the stackRegisters offer faster access than memory. Store frequently accessed data in registers. Use memory for larger data
structures or data not requiring constant access. STORE and LOAD instructions transfer data between registers and
memory.
Refer to the Instruction Set documentation for more examples of register usage.
Built with ❤️ & Kotlin
Getting Started
Assembly Language
Standard Library
- Standard Library Overview
- String Functions
- Array Functions
- Maths Functions
- Clean Functions
- I/O Functions
- System Functions
- Conversion Functions
System Calls
- System Call Overview
- File System Calls
- Process Management Calls
- IPC Calls
- Host OS Calls
- Other System Calls
Kernel + OS
Error Handling
Advanced Topics
Appendix
Project Information