Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

MetaWrap Virtual Machine Instructions


Data Structures

struct  mvm_codeblock_s
 a structure that represents a stack More...
struct  mvm_i_mnemonic_and_implementation_and_implementationname_s
 An association table of the instruction mnemonic and its implementation and the name of its implementation function in C. More...

Defines

#define X(n, m, c)   c,
 Array of pointers to the implementation function.
#define X(n, m, c)   {m,c,#c, n},
 Array of pointers to the implementation function.
#define MVM_INSTRUCTIONS_X
 Our X macro - used to store everything you ever wanted to know about the instructions... in one place..
#define X(n, m, c)   n,
 What instructions do we have in the VM?

Typedefs

typedef const void *(* MVM_Instruction_f )(struct mvm_process_s *p_process, const void *p_pc)
 the form that all native instruction implementations take

Enumerations

enum  mvm_i_instructions_e {
  mvm_i_HALT, mvm_i_NOOP, mvm_i_COMMENT, mvm_i_SRCREF,
  mvm_i_BEGIN_BLOCK, mvm_i_END_BLOCK, mvm_i_BEGIN_USE, mvm_i_END_USE,
  mvm_i_REG_I4, mvm_i_REG_F, mvm_i_REG_STRING, mvm_i_INSTRUCTIONS_TOTAL
}

Functions

const MVM_Instruction_f mvm_DECODE_MNEMONIC_2_IMPLEMENTATION (const char *p_mnemonic)
 takes an instruction mnemonic and returns a pointer to its implementation function
enum mvm_i_instructions_e mvm_DECODE_MNEMONIC_2_OPCODE (const char *p_mnemonic)
 takes an instruction mnemonic and returns a pointer to its implementation function
const char * mvm_DECODE_MNEMONIC_2_IMPLEMENTATIONNAME (const char *p_mnemonic)
 takes an instruction mnemonic and returns a pointer to its implementation function name
const void * mvm_i_RUN_HALT (struct mvm_process_s *p_process, const void *p_pc)
const void * mvm_i_RUN_NOOP (struct mvm_process_s *p_process, const void *p_pc)
const void * mvm_i_RUN_COMMENT (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'COMMENT' instruction.
const void * mvm_i_RUN_SRCREF (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'SRCREF' instruction.
const void * mvm_i_RUN_BEGIN_BLOCK (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'BEGIN_BLOCK' instruction.
const void * mvm_i_RUN_END_BLOCK (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'END_BLOCK' instruction.
const void * mvm_i_RUN_BEGIN_USE (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'BEGIN_USE' instruction.
const void * mvm_i_RUN_END_USE (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'END_USE' instruction.
const void * mvm_i_RUN_REG_I4 (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'REG_I4' instruction.
const void * mvm_i_RUN_REG_F (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'REG_F' instruction.
const void * mvm_i_RUN_REG_STRING (struct mvm_process_s *p_process, const void *p_pc)
 Performs the 'REG_STRING' instruction.

Variables

static MVM_Instruction_f mvm_i_implementations []
mvm_i_mnemonic_and_implementation_and_implementationname_s mvm_i_mnemonic_to_implementations [mvm_i_INSTRUCTIONS_TOTAL+1]
mvm_i_mnemonic_and_implementation_and_implementationname_s mvm_i_mnemonic_to_implementations [mvm_i_INSTRUCTIONS_TOTAL+1]

Define Documentation

#define MVM_INSTRUCTIONS_X
 

Value:

X( mvm_i_HALT           ,"halt",        mvm_i_RUN_HALT          ) /*!< Do nothing*/ \
X( mvm_i_NOOP           ,"noop",        mvm_i_RUN_NOOP          ) /*!< Do nothing*/ \
X( mvm_i_COMMENT        ,"comment",     mvm_i_RUN_COMMENT       ) /*!< This is a comment in the code*/ \
X( mvm_i_SRCREF     ,    "srcref",      mvm_i_RUN_SRCREF        ) /*!< This is a reference to the original source code*/ \
X( mvm_i_BEGIN_BLOCK    ,"begin_block", mvm_i_RUN_BEGIN_BLOCK   ) /*!< remembers the state of the stack */ \
X( mvm_i_END_BLOCK      ,"end_block",   mvm_i_RUN_END_BLOCK     ) /*!< push the stack back to what it was before the  BEGIN_BLOCK */ \
X( mvm_i_BEGIN_USE      ,"begin_use",   mvm_i_RUN_BEGIN_USE     ) /*!< Remember an environment namespace */ \
X( mvm_i_END_USE        ,"end_use",     mvm_i_RUN_END_USE       ) /*!< Forget an environment namespace*/ \
X( mvm_i_REG_I4         ,"reg_i4",      mvm_i_RUN_REG_I4        ) /*!< Create an integer register inside the current block*/ \
X( mvm_i_REG_F          ,"reg_f",       mvm_i_RUN_REG_F         ) /*!< Create a float register inside the current block*/ \
X( mvm_i_REG_STRING     ,"reg_string",  mvm_i_RUN_REG_STRING    )
Our X macro - used to store everything you ever wanted to know about the instructions... in one place..

Create a string register inside the current block

Definition at line 158 of file mvm_instructions.h.

#define X n,
m,
 )     n,
 

What instructions do we have in the VM?

Definition at line 175 of file mvm_instructions.h.

#define X n,
m,
 )     {m,c,#c, n},
 

Array of pointers to the implementation function.

Definition at line 359 of file mvm_instructions.c.

#define X n,
m,
 )     c,
 

Array of pointers to the implementation function.

Definition at line 359 of file mvm_instructions.c.


Typedef Documentation

MVM_Instruction_f
 

the form that all native instruction implementations take

Definition at line 135 of file mvm_instructions.h.


Enumeration Type Documentation

enum mvm_i_instructions_e
 

Enumeration values:
mvm_i_HALT  Do nothing
mvm_i_NOOP  Do nothing
mvm_i_COMMENT  This is a comment in the code
mvm_i_SRCREF  This is a reference to the original source code
mvm_i_BEGIN_BLOCK  remembers the state of the stack
mvm_i_END_BLOCK  push the stack back to what it was before the BEGIN_BLOCK
mvm_i_BEGIN_USE  Remember an environment namespace
mvm_i_END_USE  Forget an environment namespace
mvm_i_REG_I4  Create an integer register inside the current block
mvm_i_REG_F  Create a float register inside the current block
mvm_i_REG_STRING  Create a string register inside the current block
mvm_i_INSTRUCTIONS_TOTAL 

Definition at line 176 of file mvm_instructions.h.


Function Documentation

const MVM_Instruction_f mvm_DECODE_MNEMONIC_2_IMPLEMENTATION const char *  p_mnemonic  ) 
 

takes an instruction mnemonic and returns a pointer to its implementation function

A function to take a VM assembly mnemonic and returns a pointer to the C function we need to execute it

Definition at line 376 of file mvm_instructions.c.

References mvm_i_mnemonic_and_implementation_and_implementationname_s::m_implementation, and mvm_i_mnemonic_and_implementation_and_implementationname_s::m_mnemonic.

const char * mvm_DECODE_MNEMONIC_2_IMPLEMENTATIONNAME const char *  p_mnemonic  ) 
 

takes an instruction mnemonic and returns a pointer to its implementation function name

A function to take a VM assembly mnemonic and returns a pointer to a string version of the the C function we need to execute it

Definition at line 430 of file mvm_instructions.c.

References mvm_i_mnemonic_and_implementation_and_implementationname_s::m_implementationname, and mvm_i_mnemonic_and_implementation_and_implementationname_s::m_mnemonic.

enum mvm_i_instructions_e mvm_DECODE_MNEMONIC_2_OPCODE const char *  p_mnemonic  ) 
 

takes an instruction mnemonic and returns a pointer to its implementation function

A function to take a VM assembly mnemonic and returns in opcode id for this instruction

Definition at line 403 of file mvm_instructions.c.

References mvm_i_mnemonic_and_implementation_and_implementationname_s::m_mnemonic, and mvm_i_mnemonic_and_implementation_and_implementationname_s::m_opcode.

const void * mvm_i_RUN_BEGIN_BLOCK struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'BEGIN_BLOCK' instruction.

Parameters:
p_process a pointer to our process control block
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 149 of file mvm_instructions_begin_block.c.

References mvm_stack_s::m_blocks, mvm_stack_s::m_blocks_tos, mvm_stack_s::m_objects_tos, mvm_block_s::m_objects_tos, and mvm_process_s::m_stack.

const void * mvm_i_RUN_BEGIN_USE struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'BEGIN_USE' instruction.

Parameters:
p_process a pointer to our process control use
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 148 of file mvm_instructions_begin_use.c.

const void * mvm_i_RUN_COMMENT struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'COMMENT' instruction.

Parameters:
p_process a pointer to our process control block
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 142 of file mvm_instructions_comment.c.

const void * mvm_i_RUN_END_BLOCK struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'END_BLOCK' instruction.

Parameters:
p_process a pointer to our process control block
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 154 of file mvm_instructions_end_block.c.

References mvm_stack_s::m_blocks, mvm_stack_s::m_blocks_tos, mvm_block_s::m_objects_tos, mvm_stack_s::m_objects_tos, and mvm_process_s::m_stack.

const void * mvm_i_RUN_END_USE struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'END_USE' instruction.

Parameters:
p_process a pointer to our process control use
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 147 of file mvm_instructions_end_use.c.

References mvm_process_s::m_stack, mvm_stack_s::m_uses, and mvm_stack_s::m_uses_tos.

const void * mvm_i_RUN_HALT struct mvm_process_s p_process,
const void *  p_pc
 

Definition at line 151 of file mvm_instructions_halt.c.

References mvm_i_RUN_NOOP().

Here is the call graph for this function:

const void * mvm_i_RUN_NOOP struct mvm_process_s p_process,
const void *  p_pc
 

Definition at line 166 of file mvm_instructions_noop.c.

Referenced by mvm_i_RUN_HALT().

const void * mvm_i_RUN_REG_F struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'REG_F' instruction.

Parameters:
p_process a pointer to our process control use
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 145 of file mvm_instructions_reg_f.c.

const void * mvm_i_RUN_REG_I4 struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'REG_I4' instruction.

Parameters:
p_process a pointer to our process control use
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 176 of file mvm_instructions_reg_i4.c.

const void * mvm_i_RUN_REG_STRING struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'REG_STRING' instruction.

Parameters:
p_process a pointer to our process control use
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 146 of file mvm_instructions_reg_string.c.

const void * mvm_i_RUN_SRCREF struct mvm_process_s p_process,
const void *  p_pc
 

Performs the 'SRCREF' instruction.

Parameters:
p_process a pointer to our process control block
p_pc current program counter
Returns:
void
Author:
James Mc Parlane
Date:
04 September 2001

Definition at line 151 of file mvm_instructions_srcref.c.


Variable Documentation

MVM_Instruction_f mvm_i_implementations[] [static]
 

Initial value:

Definition at line 349 of file mvm_instructions.c.

struct mvm_i_mnemonic_and_implementation_and_implementationname_s mvm_i_mnemonic_to_implementations[mvm_i_INSTRUCTIONS_TOTAL+1]
 

Definition at line 360 of file mvm_instructions.c.

struct mvm_i_mnemonic_and_implementation_and_implementationname_s mvm_i_mnemonic_to_implementations[mvm_i_INSTRUCTIONS_TOTAL+1]
 

Initial value:

{
     { "halt" , mvm_i_RUN_HALT ,"mvm_i_RUN_HALT",  mvm_i_HALT },   { "noop" , mvm_i_RUN_NOOP ,"mvm_i_RUN_NOOP",  mvm_i_NOOP },   { "comment" , mvm_i_RUN_COMMENT ,"mvm_i_RUN_COMMENT",  mvm_i_COMMENT },   { "srcref" , mvm_i_RUN_SRCREF ,"mvm_i_RUN_SRCREF",  mvm_i_SRCREF },   { "begin_block" , mvm_i_RUN_BEGIN_BLOCK ,"mvm_i_RUN_BEGIN_BLOCK",  mvm_i_BEGIN_BLOCK },   { "end_block" , mvm_i_RUN_END_BLOCK ,"mvm_i_RUN_END_BLOCK",  mvm_i_END_BLOCK },   { "begin_use" , mvm_i_RUN_BEGIN_USE ,"mvm_i_RUN_BEGIN_USE",  mvm_i_BEGIN_USE },   { "end_use" , mvm_i_RUN_END_USE ,"mvm_i_RUN_END_USE",  mvm_i_END_USE },   { "reg_i4" , mvm_i_RUN_REG_I4 ,"mvm_i_RUN_REG_I4",  mvm_i_REG_I4 },   { "reg_f" , mvm_i_RUN_REG_F ,"mvm_i_RUN_REG_F",  mvm_i_REG_F },   { "reg_string" , mvm_i_RUN_REG_STRING ,"mvm_i_RUN_REG_STRING",  mvm_i_REG_STRING },  
    {0,(MVM_Instruction_f)NULL,0,0}
}

Definition at line 360 of file mvm_instructions.c.