Instruction Set
Here is a list of all the instructions supported by the simulator. Each instruction includes a brief description and a table showing the flags it modifies. If there is a "0" or "1," it means the flag is set to 0
or 1
respectively. If there is an "X," it means the flag is modified accordingly. If there is nothing, the flag is not modified.
Data Transfer Instructions
Instruction | Description | CF | ZF | SF | IF | OF |
---|---|---|---|---|---|---|
MOV dest, source | Copies source to dest | -- | -- | -- | -- | -- |
PUSH source | Pushes source onto the stack | -- | -- | -- | -- | -- |
POP dest | Pops the top of the stack and loads it into dest | -- | -- | -- | -- | -- |
PUSHF | Pushes FLAGS onto the stack | -- | -- | -- | -- | -- |
POPF | Pops FLAGS from the stack | X | X | X | X | X |
IN dest, source | Loads the value from port source into dest | -- | -- | -- | -- | -- |
OUT dest, source | Loads the value from source into port dest | -- | -- | -- | -- | -- |
Arithmetic Instructions
Instruction | Description | CF | ZF | SF | IF | OF |
---|---|---|---|---|---|---|
ADD dest, source | Adds source to dest | X | X | X | -- | X |
ADC dest, source | Adds source and CF to dest | X | X | X | -- | X |
SUB dest, source | Subtracts source from dest | X | X | X | -- | X |
SBB dest, source | Subtracts source and CF from dest | X | X | X | -- | X |
CMP dest, source | Compares source with dest | X | X | X | -- | X |
NEG dest | Negates dest | X | X | X | -- | X |
INC dest | Increments dest | X | X | X | -- | X |
DEC dest | Decrements dest | X | X | X | -- | X |
Logical Instructions
Instruction | Description | CF | ZF | SF | IF | OF |
---|---|---|---|---|---|---|
AND dest, source | Performs bitwise AND between dest and source | 0 | X | X | -- | 0 |
OR dest, source | Performs bitwise OR between dest and source | 0 | X | X | -- | 0 |
XOR dest, source | Performs bitwise XOR between dest and source | 0 | X | X | -- | 0 |
TEST dest, fuente | Performs bitwise AND between dest and source, only flags | 0 | X | X | -- | 0 |
NOT dest | Performs bitwise NOT on dest | 0 | X | X | -- | 0 |
Control Transfer Instructions
Instruction | Description | CF | ZF | SF | IF | OF |
---|---|---|---|---|---|---|
CALL label | Calls a subroutine starting at label | -- | -- | -- | -- | -- |
RET | Returns from the subroutine | -- | -- | -- | -- | -- |
JC label | Jumps to label if CF=1 | -- | -- | -- | -- | -- |
JNC label | Jumps to label if CF=0 | -- | -- | -- | -- | -- |
JZ label | Jumps to label if ZF=1 | -- | -- | -- | -- | -- |
JNZ label | Jumps to label if ZF=0 | -- | -- | -- | -- | -- |
JS label | Jumps to label if SF=1 | -- | -- | -- | -- | -- |
JNS label | Jumps to label if SF=0 | -- | -- | -- | -- | -- |
JO label | Jumps to label if OF=1 | -- | -- | -- | -- | -- |
JNO label | Jumps to label if OF=0 | -- | -- | -- | -- | -- |
JMP label | Unconditionally jumps to label | -- | -- | -- | -- | -- |
Interrupt Handling Instructions
Instruction | Description | CF | ZF | SF | IF | OF |
---|---|---|---|---|---|---|
INT N | Executes software interrupt N | -- | -- | -- | 0 | -- |
IRET | Returns from the interrupt routine | X | X | X | X | X |
CLI | Disables maskable interrupts | -- | -- | -- | 0 | -- |
STI | Enables maskable interrupts | -- | -- | -- | 1 | -- |
Control Instructions
Instruction | Description | CF | ZF | SF | IF | OF |
---|---|---|---|---|---|---|
NOP | Does nothing | -- | -- | -- | -- | -- |
HLT | Halts execution | -- | -- | -- | -- | -- |