#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
|
enum | {
RARMovInstruction = 0,
RARCmpInstruction = 1,
RARAddInstruction = 2,
RARSubInstruction = 3,
RARJzInstruction = 4,
RARJnzInstruction = 5,
RARIncInstruction = 6,
RARDecInstruction = 7,
RARJmpInstruction = 8,
RARXorInstruction = 9,
RARAndInstruction = 10,
RAROrInstruction = 11,
RARTestInstruction = 12,
RARJsInstruction = 13,
RARJnsInstruction = 14,
RARJbInstruction = 15,
RARJbeInstruction = 16,
RARJaInstruction = 17,
RARJaeInstruction = 18,
RARPushInstruction = 19,
RARPopInstruction = 20,
RARCallInstruction = 21,
RARRetInstruction = 22,
RARNotInstruction = 23,
RARShlInstruction = 24,
RARShrInstruction = 25,
RARSarInstruction = 26,
RARNegInstruction = 27,
RARPushaInstruction = 28,
RARPopaInstruction = 29,
RARPushfInstruction = 30,
RARPopfInstruction = 31,
RARMovzxInstruction = 32,
RARMovsxInstruction = 33,
RARXchgInstruction = 34,
RARMulInstruction = 35,
RARDivInstruction = 36,
RARAdcInstruction = 37,
RARSbbInstruction = 38,
RARPrintInstruction = 39,
RARNumberOfInstructions = 40
} |
|
|
RARProgram * | RARCreateProgram (void) |
|
void | RARDeleteProgram (RARProgram *prog) |
|
bool | RARProgramAddInstr (RARProgram *prog, uint8_t instruction, bool bytemode) |
|
bool | RARSetLastInstrOperands (RARProgram *prog, uint8_t addressingmode1, uint32_t value1, uint8_t addressingmode2, uint32_t value2) |
|
bool | RARIsProgramTerminated (RARProgram *prog) |
|
bool | RARExecuteProgram (RARVirtualMachine *vm, RARProgram *prog) |
|
void | RARSetVirtualMachineRegisters (RARVirtualMachine *vm, uint32_t registers[8]) |
|
uint32_t | RARVirtualMachineRead32 (RARVirtualMachine *vm, uint32_t address) |
|
void | RARVirtualMachineWrite32 (RARVirtualMachine *vm, uint32_t address, uint32_t val) |
|
uint8_t | RARVirtualMachineRead8 (RARVirtualMachine *vm, uint32_t address) |
|
void | RARVirtualMachineWrite8 (RARVirtualMachine *vm, uint32_t address, uint8_t val) |
|
int | NumberOfRARInstructionOperands (uint8_t instruction) |
|
bool | RARInstructionHasByteMode (uint8_t instruction) |
|
bool | RARInstructionIsUnconditionalJump (uint8_t instruction) |
|
bool | RARInstructionIsRelativeJump (uint8_t instruction) |
|
bool | RARInstructionWritesFirstOperand (uint8_t instruction) |
|
bool | RARInstructionWritesSecondOperand (uint8_t instruction) |
|
void | RARPrintProgram (RARProgram *prog) |
|
#define RARAbsoluteAddressingMode 24 |
#define RARImmediateAddressingMode 25 |
#define RARIndexedAbsoluteAddressingMode |
( |
|
n) | |
(16 + (n)) |
#define RARNumberOfAddressingModes 26 |
#define RARProgramGlobalSize 0x2000 |
#define RARProgramMemorySize 0x40000 |
#define RARProgramSystemGlobalSize 64 |
#define RARProgramWorkSize 0x3c000 |
#define RARRegisterAddressingMode |
( |
|
n) | |
(0 + (n)) |
#define RARRegisterIndirectAddressingMode |
( |
|
n) | |
(8 + (n)) |
#define RARRuntimeMaxInstructions 250000000 |
Enumerator |
---|
RARMovInstruction |
|
RARCmpInstruction |
|
RARAddInstruction |
|
RARSubInstruction |
|
RARJzInstruction |
|
RARJnzInstruction |
|
RARIncInstruction |
|
RARDecInstruction |
|
RARJmpInstruction |
|
RARXorInstruction |
|
RARAndInstruction |
|
RAROrInstruction |
|
RARTestInstruction |
|
RARJsInstruction |
|
RARJnsInstruction |
|
RARJbInstruction |
|
RARJbeInstruction |
|
RARJaInstruction |
|
RARJaeInstruction |
|
RARPushInstruction |
|
RARPopInstruction |
|
RARCallInstruction |
|
RARRetInstruction |
|
RARNotInstruction |
|
RARShlInstruction |
|
RARShrInstruction |
|
RARSarInstruction |
|
RARNegInstruction |
|
RARPushaInstruction |
|
RARPopaInstruction |
|
RARPushfInstruction |
|
RARPopfInstruction |
|
RARMovzxInstruction |
|
RARMovsxInstruction |
|
RARXchgInstruction |
|
RARMulInstruction |
|
RARDivInstruction |
|
RARAdcInstruction |
|
RARSbbInstruction |
|
RARPrintInstruction |
|
RARNumberOfInstructions |
|
Definition at line 40 of file rarvm.h.
int NumberOfRARInstructionOperands |
( |
uint8_t |
instruction) | |
|
Definition at line 140 of file rarvm.c.
144 uint32_t op1, op2, carry, i;
145 uint32_t counter = 0;
185 if (!(flags & ZeroFlag))
228 if (!(flags & SignFlag))
238 if ((flags & (CarryFlag | ZeroFlag)))
243 if (!(flags & (CarryFlag | ZeroFlag)))
248 if (!(flags & CarryFlag))
302 for (i = 0; i < 8; i++)
307 for (i = 0; i < 8; i++)
bool RARInstructionHasByteMode |
( |
uint8_t |
instruction) | |
|
bool RARInstructionIsRelativeJump |
( |
uint8_t |
instruction) | |
|
bool RARInstructionIsUnconditionalJump |
( |
uint8_t |
instruction) | |
|
bool RARInstructionWritesFirstOperand |
( |
uint8_t |
instruction) | |
|
bool RARInstructionWritesSecondOperand |
( |
uint8_t |
instruction) | |
|
Definition at line 589 of file rarvm.c.
592 "Mov",
"Cmp",
"Add",
"Sub",
"Jz",
"Jnz",
"Inc",
"Dec",
"Jmp",
"Xor",
593 "And",
"Or",
"Test",
"Js",
"Jns",
"Jb",
"Jbe",
"Ja",
"Jae",
"Push",
594 "Pop",
"Call",
"Ret",
"Not",
"Shl",
"Shr",
"Sar",
"Neg",
"Pusha",
"Popa",
595 "Pushf",
"Popf",
"Movzx",
"Movsx",
"Xchg",
"Mul",
"Div",
"Adc",
"Sbb",
"Print",
599 for (i = 0; i < prog->
length; i++) {
602 printf(
" %02x: %s", i, instructionNames[opcode->
instruction]);
605 if (numoperands >= 1) {
609 if (numoperands == 2) {
bool RARProgramAddInstr |
( |
RARProgram * |
prog, |
|
|
uint8_t |
instruction, |
|
|
bool |
bytemode |
|
) |
| |
bool RARSetLastInstrOperands |
( |
RARProgram * |
prog, |
|
|
uint8_t |
addressingmode1, |
|
|
uint32_t |
value1, |
|
|
uint8_t |
addressingmode2, |
|
|
uint32_t |
value2 |
|
) |
| |
Definition at line 72 of file rarvm.c.
91 if (numoperands == 2) {
void RARVirtualMachineWrite32 |
( |
RARVirtualMachine * |
vm, |
|
|
uint32_t |
address, |
|
|
uint32_t |
val |
|
) |
| |
void RARVirtualMachineWrite8 |
( |
RARVirtualMachine * |
vm, |
|
|
uint32_t |
address, |
|
|
uint8_t |
val |
|
) |
| |