Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
|
#include "rarvm.h"
#include "../common/allocator.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | RAROpcode_s |
struct | RARProgram_s |
Macros | |
#define | EXTMACRO_BEGIN do { |
#define | EXTMACRO_END } while (0) |
#define | CarryFlag 1 |
#define | ZeroFlag 2 |
#define | SignFlag 0x80000000 |
#define | SignExtend(a) ((uint32_t)((int8_t)(a))) |
#define | GetOperand1() _RARGetOperand(vm, opcode->addressingmode1, opcode->value1, opcode->bytemode & 1) |
#define | GetOperand2() _RARGetOperand(vm, opcode->addressingmode2, opcode->value2, opcode->bytemode & 2) |
#define | SetOperand1(data) _RARSetOperand(vm, opcode->addressingmode1, opcode->value1, opcode->bytemode & 1, data) |
#define | SetOperand2(data) _RARSetOperand(vm, opcode->addressingmode2, opcode->value2, opcode->bytemode & 2, data) |
#define | SetFlagsWithCarry(res, carry) EXTMACRO_BEGIN uint32_t result = (res); flags = (result == 0 ? ZeroFlag : (result & SignFlag)) | ((carry) ? CarryFlag : 0); EXTMACRO_END |
#define | SetByteFlagsWithCarry(res, carry) EXTMACRO_BEGIN uint8_t result = (res); flags = (result == 0 ? ZeroFlag : (SignExtend(result) & SignFlag)) | ((carry) ? CarryFlag : 0); EXTMACRO_END |
#define | SetFlags(res) SetFlagsWithCarry(res, 0) |
#define | SetOperand1AndFlagsWithCarry(res, carry) EXTMACRO_BEGIN uint32_t r = (res); SetFlagsWithCarry(r, carry); SetOperand1(r); EXTMACRO_END |
#define | SetOperand1AndByteFlagsWithCarry(res, carry) EXTMACRO_BEGIN uint8_t r = (res); SetByteFlagsWithCarry(r, carry); SetOperand1(r); EXTMACRO_END |
#define | SetOperand1AndFlags(res) EXTMACRO_BEGIN uint32_t r = (res); SetFlags(r); SetOperand1(r); EXTMACRO_END |
#define | NextInstruction() { opcode++; continue; } |
#define | Jump(offs) { uint32_t o = (offs); if (o >= prog->length) return false; opcode = &prog->opcodes[o]; continue; } |
#define | RAR0OperandsFlag 0 |
#define | RAR1OperandFlag 1 |
#define | RAR2OperandsFlag 2 |
#define | RAROperandsFlag 3 |
#define | RARHasByteModeFlag 4 |
#define | RARIsUnconditionalJumpFlag 8 |
#define | RARIsRelativeJumpFlag 16 |
#define | RARWritesFirstOperandFlag 32 |
#define | RARWritesSecondOperandFlag 64 |
#define | RARReadsStatusFlag 128 |
#define | RARWritesStatusFlag 256 |
Typedefs | |
typedef struct RAROpcode_s | RAROpcode |
Functions | |
RARProgram * | RARCreateProgram () |
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) |
static uint32_t | _RARGetOperand (RARVirtualMachine *vm, uint8_t addressingmode, uint32_t value, bool bytemode) |
static void | _RARSetOperand (RARVirtualMachine *vm, uint8_t addressingmode, uint32_t value, bool bytemode, uint32_t data) |
bool | RARExecuteProgram (RARVirtualMachine *vm, RARProgram *prog) |
static uint32_t | _RARRead32 (const uint8_t *b) |
static void | _RARWrite32 (uint8_t *b, uint32_t n) |
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) |
static void | RARPrintOperand (uint8_t addressingmode, uint32_t value) |
void | RARPrintProgram (RARProgram *prog) |
Variables | |
static const int | InstructionFlags [RARNumberOfInstructions] |
#define GetOperand1 | ( | ) | _RARGetOperand(vm, opcode->addressingmode1, opcode->value1, opcode->bytemode & 1) |
#define GetOperand2 | ( | ) | _RARGetOperand(vm, opcode->addressingmode2, opcode->value2, opcode->bytemode & 2) |
#define Jump | ( | offs) | { uint32_t o = (offs); if (o >= prog->length) return false; opcode = &prog->opcodes[o]; continue; } |
#define SetByteFlagsWithCarry | ( | res, | |
carry | |||
) | EXTMACRO_BEGIN uint8_t result = (res); flags = (result == 0 ? ZeroFlag : (SignExtend(result) & SignFlag)) | ((carry) ? CarryFlag : 0); EXTMACRO_END |
#define SetFlags | ( | res) | SetFlagsWithCarry(res, 0) |
#define SetFlagsWithCarry | ( | res, | |
carry | |||
) | EXTMACRO_BEGIN uint32_t result = (res); flags = (result == 0 ? ZeroFlag : (result & SignFlag)) | ((carry) ? CarryFlag : 0); EXTMACRO_END |
#define SetOperand1 | ( | data) | _RARSetOperand(vm, opcode->addressingmode1, opcode->value1, opcode->bytemode & 1, data) |
#define SetOperand1AndByteFlagsWithCarry | ( | res, | |
carry | |||
) | EXTMACRO_BEGIN uint8_t r = (res); SetByteFlagsWithCarry(r, carry); SetOperand1(r); EXTMACRO_END |
#define SetOperand1AndFlags | ( | res) | EXTMACRO_BEGIN uint32_t r = (res); SetFlags(r); SetOperand1(r); EXTMACRO_END |
#define SetOperand1AndFlagsWithCarry | ( | res, | |
carry | |||
) | EXTMACRO_BEGIN uint32_t r = (res); SetFlagsWithCarry(r, carry); SetOperand1(r); EXTMACRO_END |
#define SetOperand2 | ( | data) | _RARSetOperand(vm, opcode->addressingmode2, opcode->value2, opcode->bytemode & 2, data) |
typedef struct RAROpcode_s RAROpcode |
|
static |
Definition at line 417 of file rarvm.c.
|
static |
|
static |
Definition at line 444 of file rarvm.c.
|
static |
int NumberOfRARInstructionOperands | ( | uint8_t | instruction) |
RARProgram* RARCreateProgram | ( | void | ) |
void RARDeleteProgram | ( | RARProgram * | prog) |
bool RARExecuteProgram | ( | RARVirtualMachine * | vm, |
RARProgram * | prog | ||
) |
Definition at line 140 of file rarvm.c.
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) |
bool RARIsProgramTerminated | ( | RARProgram * | prog) |
Definition at line 101 of file rarvm.c.
|
static |
Definition at line 575 of file rarvm.c.
void RARPrintProgram | ( | 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 | ||
) |
Definition at line 72 of file rarvm.c.
void RARSetVirtualMachineRegisters | ( | RARVirtualMachine * | vm, |
uint32_t | registers[8] | ||
) |
uint32_t RARVirtualMachineRead32 | ( | RARVirtualMachine * | vm, |
uint32_t | address | ||
) |
uint8_t RARVirtualMachineRead8 | ( | RARVirtualMachine * | vm, |
uint32_t | address | ||
) |
void RARVirtualMachineWrite32 | ( | RARVirtualMachine * | vm, |
uint32_t | address, | ||
uint32_t | val | ||
) |
void RARVirtualMachineWrite8 | ( | RARVirtualMachine * | vm, |
uint32_t | address, | ||
uint8_t | val | ||
) |
|
static |