-
Notifications
You must be signed in to change notification settings - Fork 0
Instruction Table
Adam Mathlay edited this page Nov 25, 2024
·
9 revisions
| # | Instruction | Description | Argument 1 | Argument 2 | Argument 3 | Return Location | Notes |
|---|---|---|---|---|---|---|---|
| 1 | LIT |
Loads a literal Long value into a register. |
Destination (Register Literal) |
Value (Long Literal) |
- | Destination |
- |
| 2 | XLIT |
Loads a literal value into a register (flexible data type). |
Destination (Register Literal) |
Value (Double/Float Literal) |
- | Destination |
Data type is determined at runtime based on SETTYPE declaration for the destination register. |
| 3 | SETTYPE |
Sets the data type of a register. |
Target (Register Literal) |
DataType (Register Data Type) |
- | - | Data types: Byte, Short, Int, Long, Float, Double. Values are truncated if they exceed the target data type's range. |
| 4 | MOV |
Moves the value from one register to another. |
Source (Register Literal) |
Destination (Register Literal) |
- | Destination |
Creates a copy of the value in the source register and assigns it to the destination register. |
| 5 | SWP |
Swaps the values of two registers. |
Register 1 (Register Literal) |
Register 2 (Register Literal) |
- | - | The values in the two specified registers are exchanged. |
| 6 | STORE |
Stores a value from a register into memory. |
Source (Register Literal) |
Memory Address (Register Literal) |
- | - | The value from the source register is stored into the memory location specified by the address register. |
| 7 | LOAD |
Loads a value from memory into a register. |
Memory Address (Register Literal) |
Destination (Register Literal) |
- | Destination |
Loads a value from memory at the address specified by the address register to the specified destination register. |
| 8 | PUSH |
Pushes a register value onto the stack. |
Source (Register Literal) |
- | - | - | Pushes the value from the source register onto the stack. The stack grows downwards. |
| 9 | PUSHL |
Pushes a literal Long value onto the stack. |
Value (Long Literal) |
- | - | - | Pushes the specified long value onto the stack. |
| 10 | POP |
Pops a value from the stack into a register. |
Destination (Register Literal) |
- | - | Destination |
Pops a value from the top of the stack and assigns it to the destination register. Handles stack underflow. |
| 11 | PEEK |
Copies the top value from the stack into a register without removing it. |
Destination (Register Literal) |
- | - | Destination |
Copies the top value of the stack to the destination register without changing the stack. Handles stack underflow. |
| 12 | ADD |
Adds two values. |
Addend 1 (Register Type) |
Addend 2 (Register Type) |
Result Destination (Register Literal) |
Result Destination |
Performs addition on the two arguments and stores the result in the ResultDestination register. |
| 13 | SUB |
Subtracts two values. |
Minuend (Register Literal) |
Subtrahend (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs subtraction on the two arguments and stores the result in the ResultDestination register. |
| 14 | MUL |
Multiplies two values. |
Multiplier (Register Literal) |
Multiplicand (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs multiplication on the two arguments and stores the result in the ResultDestination register. |
| 15 | DIV |
Divides two values (integer division). |
Dividend (Register Literal) |
Divisor (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs integer division on the two arguments and stores the result in the ResultDestination register. Throws an exception if the divisor is zero. |
| 16 | MOD |
Calculates the modulo of two values. |
Dividend (Register Literal) |
Divisor (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs the modulo operation and stores the result in the ResultDestination register. Throws an exception if the divisor is zero. |
| 17 | POW |
Raises a number to a power (integer exponentiation). |
Base (Register Literal) |
Exponent (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs integer exponentiation and stores the result in the ResultDestination register. Handles potential overflow. |
| 18 | AND |
Performs bitwise AND. |
argument1 (Register Literal) |
argument2 (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs a bitwise AND operation and stores the result in the ResultDestination register. |
| 19 | OR |
Performs bitwise OR. |
argument1 (Register Literal) |
argument2 (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs a bitwise OR operation and stores the result in the ResultDestination register. |
| 20 | XOR |
Performs bitwise XOR. |
argument1 (Register Literal) |
argument2 (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs a bitwise XOR operation and stores the result in the ResultDestination register. |
| 21 | NOT |
Performs bitwise NOT. |
argument (Register Literal) |
Result Destination (Register Literal) |
- | Result Destination |
Performs a bitwise NOT operation on the argument and stores the result in the ResultDestination register. |
| 22 | SHL |
Shifts bits to the left. |
Value (Register Literal) |
Shift Amount (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs a left bit shift and stores the result in the ResultDestination register. |
| 23 | SHR |
Shifts bits to the right. |
Value (Register Literal) |
Shift Amount (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
Performs a right bit shift and stores the result in the ResultDestination register. |
| 24 | JMP |
Jumps to the specified line number. |
Line number (Long) |
- | - | - | Unconditional jump. |
| 25 | JZ |
Jumps to the specified line number if the (Zero Flag) I1 register is zero. |
Line number (Long) |
- | - | - | Conditional jump. |
| 26 | JNZ |
Jumps to the specified line number if the (Zero Flag) I1 register is not zero. |
Line number (Long) |
- | - | - | Conditional jump. |
| 27 | EQ |
Compares two values for equality. |
argument 1 (Register Literal) |
argument 2 (Register Literal) |
- |
I4 (Equal Flag) |
Stores 1 in the I4 (Equal Flag) register if the arguments are equal, otherwise stores 0. |
| 28 | GT |
Compares two values; stores 0 in I3 (Greater Than Flag) if argument 1 > argument 2, otherwise 1. |
argument 1 (Register Literal) |
argument 2 (Register Literal) |
- |
I3 (Greater Than Flag) |
- |
| 29 | LT |
Compares two values; stores 0 in I3 (Greater Than Flag) if argument 1 < argument 2, otherwise 1. |
argument 1 (Register Literal) |
argument 2 (Register Literal) |
- |
I3 (Greater Than Flag) |
- |
| 30 | PRINTS |
Prints the value at the top of the stack to the console. | - | - | - | - | - |
| 31 | PRINTR |
Prints the value of a register to the console. |
Register (Register Literal) |
- | - | - | Prints the value of the specified register to the console. |
| 32 | STR |
Stores a string literal in memory. |
Destination Address (Register Literal) |
String (String Literal) |
- | DestinationAddress |
Memory is allocated automatically. The string literal MUST be enclosed in double quotes. |
| 33 | SYSCALL |
Executes a system call. |
Syscall ID (Register Literal) |
Argument1 (Register Literal) |
Argument2 (Register Literal) |
R2 |
Arguments are passed in S registers; the system call ID is stored in S1. Results are pushed onto the stack. |
| 34 | CALL |
Calls a function. |
Function Name (String) |
- | - | stack |
Arguments are passed in F registers. The return value (if any) is pushed onto the stack. |
| 35 | RET |
Returns from a function. | - | - | - | - | The function's return value (if any) should have already been pushed onto the stack. |
| 36 | INR |
Checks if a register is null and stores 1 in R6 if it is, otherwise stores 0. |
Register To Check (Register Literal) |
- | - | R6 |
May get deprecated because of the new 0 = null registers |
| 37 | DEALLOC |
Deallocates the memory at the specified address. |
Address (Register Literal) |
- | - | - | - |
| 38 | HELP |
Displays help information for an instruction or standard library function. |
Topic (String) |
- | - | - | - |
| 39 | SLEEP |
Pauses execution for a specified number of milliseconds. |
Milliseconds (Register Literal) |
- | - | - | - |
| 40 | XADD |
Adds two floating-point values (Float or Double). |
Addend 1 (Register Literal) |
Addend 2 (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
arguments must be of the same type (Float or Double). The result is stored in the Result Destination register. |
| 41 | XSUB |
Subtracts two floating-point values (Float or Double). |
Minuend (Register Literal) |
Subtrahend (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
arguments must be of the same type (Float or Double). The result is stored in the Result Destination register. |
| 42 | XMUL |
Multiplies two floating-point values (Float or Double). |
Multiplier (Register Literal) |
Multiplicand (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
arguments must be of the same type (Float or Double). The result is stored in the Result Destination register. |
| 43 | XDIV |
Divides two floating-point values (Float or Double). |
Dividend (Register Literal) |
Divisor (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
arguments must be of the same type (Float or Double). The result is stored in the Result Destination register. Throws an exception if the divisor is zero. |
| 44 | XPOW |
Raises a floating-point value (Float or Double) to a power. |
Base (Register Literal) |
Exponent (Register Literal) |
Result Destination (Register Literal) |
Result Destination |
arguments must be of the same type (Float or Double). The result is stored in the Result Destination register. |
| 45 | ITOF |
Converts an Integer value to a Float/Double. |
Source (Register Literal) |
Destination (Register Literal) |
- | Destination |
The converted value is stored in the destination register. |
| 46 | FTOI |
Converts a Float/Double value to an Integer value. |
Source (Register Literal) |
Destination (Register Literal) |
- | Destination |
The converted value is stored in the destination register. Settype is factored in. |
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