MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
instruct.hpp File Reference

Instruction set enum, operand/instruction structs, variable types, and Variable/Variable_Value definitions. More...

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
Include dependency graph for instruct.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mxvm::Operand
 A single instruction operand (constant value or variable reference). More...
struct  mxvm::Instruction
 A complete MXVM instruction with opcode, operands, and optional label. More...
struct  mxvm::Variable_Value
 Runtime value storage for a variable. More...
struct  mxvm::Variable
 A named variable with type, value, and optional object association. More...

Namespaces

namespace  mxvm

Enumerations

enum  Inc {
  NULL_INC = 0 , MOV , LOAD , STORE ,
  ADD , SUB , MUL , DIV ,
  OR , AND , XOR , NOT ,
  MOD , CMP , JMP , JE ,
  JNE , JL , JLE , JG ,
  JGE , JZ , JNZ , JA ,
  JB , PRINT , EXIT , ALLOC ,
  FREE , GETLINE , PUSH , POP ,
  STACK_LOAD , STACK_STORE , STACK_SUB , CALL ,
  RET , STRING_PRINT , DONE , TO_INT ,
  TO_FLOAT , INVOKE , RETURN , NEG ,
  FCMP , JAE , JBE , JC ,
  JNC , JP , JNP , JO ,
  JNO , JS , JNS , LEA ,
  REALLOC
}
 MXVM instruction set opcodes. More...
enum class  mxvm::OperandType { mxvm::OP_CONSTANT , mxvm::OP_VARIABLE }
 Discriminates whether an operand is a compile-time constant or a variable reference. More...
enum class  mxvm::VarType {
  mxvm::VAR_NULL = 0 , mxvm::VAR_INTEGER , mxvm::VAR_FLOAT , mxvm::VAR_STRING ,
  mxvm::VAR_POINTER , mxvm::VAR_LABEL , mxvm::VAR_ARRAY , mxvm::VAR_EXTERN ,
  mxvm::VAR_BYTE
}
 MXVM variable type discriminator. More...
enum class  mxvm::Keywords {
  mxvm::KEY_PROGRAM , mxvm::KEY_OBJECT , mxvm::KEY_MODULE , mxvm::KEY_DATA ,
  mxvm::KEY_CODE , mxvm::KEY_SECTION
}
 MXVM language keywords. More...

Functions

std::ostream & operator<< (std::ostream &out, const enum Inc &i)
 Stream insertion operator for Inc opcodes.
std::ostream & operator<< (std::ostream &out, const mxvm::Instruction &inc)
 Stream insertion operator for Instruction.
std::ostream & operator<< (std::ostream &out, const mxvm::VarType &type)
 Stream insertion operator for VarType.
std::ostream & operator<< (std::ostream &out, const mxvm::Keywords &key)
 Stream insertion operator for Keywords.

Variables

std::vector< std::string > IncType
 String representations of Inc opcodes, indexed by enum value.
std::vector< std::string > mxvm::keywords {"program", "object", "module", "data", "code", "section"}
 String representations of Keywords enum values.

Detailed Description

Instruction set enum, operand/instruction structs, variable types, and Variable/Variable_Value definitions.

Author
Jared Bruni

Definition in file instruct.hpp.

Enumeration Type Documentation

◆ Inc

enum Inc

MXVM instruction set opcodes.

Enumerates all supported virtual machine instructions including data movement, arithmetic, logic, control flow, stack operations, memory management, I/O, and type conversion.

Enumerator
NULL_INC 
MOV 
LOAD 
STORE 
ADD 
SUB 
MUL 
DIV 
OR 
AND 
XOR 
NOT 
MOD 
CMP 
JMP 
JE 
JNE 
JL 
JLE 
JG 
JGE 
JZ 
JNZ 
JA 
JB 
PRINT 
EXIT 
ALLOC 
FREE 
GETLINE 
PUSH 
POP 
STACK_LOAD 
STACK_STORE 
STACK_SUB 
CALL 
RET 
STRING_PRINT 
DONE 
TO_INT 
TO_FLOAT 
INVOKE 
RETURN 
NEG 
FCMP 
JAE 
JBE 
JC 
JNC 
JP 
JNP 
JO 
JNO 
JS 
JNS 
LEA 
REALLOC 

Reallocate a dynamic memory block: realloc dest, elemSize, count.

Definition at line 21 of file instruct.hpp.

Function Documentation

◆ operator<<() [1/4]

std::ostream & operator<< ( std::ostream & out,
const enum Inc & i )

Stream insertion operator for Inc opcodes.

Parameters
outOutput stream
iOpcode to print
Returns
Reference to the output stream

Definition at line 23 of file instruct.cpp.

References IncType, and pos().

◆ operator<<() [2/4]

std::ostream & operator<< ( std::ostream & out,
const mxvm::Instruction & inc )

Stream insertion operator for Instruction.

Parameters
outOutput stream
incInstruction to format and print
Returns
Reference to the output stream

Definition at line 32 of file instruct.cpp.

References mxvm::Instruction::instruction, mxvm::Operand::op, mxvm::Instruction::op1, mxvm::Instruction::op2, mxvm::Instruction::op3, and mxvm::Instruction::vop.

◆ operator<<() [3/4]

std::ostream & operator<< ( std::ostream & out,
const mxvm::Keywords & key )

Stream insertion operator for Keywords.

Parameters
outOutput stream
keyKeyword to print
Returns
Reference to the output stream

Definition at line 14 of file instruct.cpp.

References mxvm::keywords.

◆ operator<<() [4/4]

std::ostream & operator<< ( std::ostream & out,
const mxvm::VarType & type )

Stream insertion operator for VarType.

Parameters
outOutput stream
typeVariable type to print
Returns
Reference to the output stream

Definition at line 54 of file instruct.cpp.

References mxvm::VAR_BYTE, mxvm::VAR_EXTERN, mxvm::VAR_FLOAT, mxvm::VAR_INTEGER, mxvm::VAR_POINTER, and mxvm::VAR_STRING.

Variable Documentation

◆ IncType

std::vector<std::string> IncType
inline

String representations of Inc opcodes, indexed by enum value.

Definition at line 82 of file instruct.hpp.

Referenced by mxvm::buildInstructionSet(), operator<<(), mxvm::Program::print(), and mxvm::Validator::validate().