memory.h File Reference

Memory system of the pseudo-assembler. More...

#include "interpreter.h"

Include dependency graph for memory.h:

This graph shows which files directly or indirectly include this file:


Data Structures

struct  dynamicMemCell
 Dynamic memory cell. More...
struct  DynamicMemory
 Interface to the dynamic memory. More...
struct  StaticMemory
 Static memory. More...

Typedefs

typedef int32_t MemCell
 Virtual memory cell content.
typedef struct dynamicMemCell DynamicMemCell
 Dynamic memory cell.

Functions

void pasm_initMemory ()
 Initialize the memory system.
void pasm_resetMemory ()
 Reset the memory system.
void pasm_writeValue (uint32_t address, int32_t value)
 Write some value into some virtual memory cell.
int32_t pasm_readValue (uint32_t address)
 Read value from a virtual memory cell.
void pasm_createStaticMemory (uint32_t size)
 Create a block of virtual static memory.
void pasm_writeInstruction (uint32_t address, Instruction instruction)
 Write some instruction into some virtual memory cell.
ErrorCode pasm_readInstruction (uint32_t address, Instruction *instruction)
 Read instruction from a virtual memory cell.

Detailed Description

Memory system of the pseudo-assembler.

The memory system takes care of reading values from and writing values into the virtual memory. The memory system knows 2 ways to allocate virtual memory: virtual static memory and virtual dynamic memory. Virtual static memory is created all at once and allows for fast address seeking. Virtual dynamic memory gets created when it is needed but traversing the virtual dynamic memory is a lot slower.

Author:
Wesley Stessens

Typedef Documentation

Dynamic memory cell.

This type of memory cell belongs to the virtual dynamic memory.


Function Documentation

void pasm_createStaticMemory ( uint32_t  size  ) 

Create a block of virtual static memory.

Parameters:
size Size of the static memory.

ErrorCode pasm_readInstruction ( uint32_t  address,
Instruction instruction 
)

Read instruction from a virtual memory cell.

Parameters:
address Virtual address to read the instruction from
instruction Pointer to empty instruction. The function will fill in the instruction.
Returns:
An error code (NO_ERROR if no error occured)
Note:
If the virtual memory cell does not exist, the INVALID_MEMORY_REGION error will get triggered.
See also:
pasm_writeInstruction

int32_t pasm_readValue ( uint32_t  address  ) 

Read value from a virtual memory cell.

Parameters:
address Virtual address to read the value from
Returns:
Value in the virtual memory cell
Note:
If the virtual memory cell does not exist, the INVALID_MEMORY_REGION error will get triggered and the pseudo-assembler program will stop.
See also:
pasm_writeValue

void pasm_resetMemory (  ) 

Reset the memory system.

This will also free all memory that was allocated on the host machine for the virtual memory.

void pasm_writeInstruction ( uint32_t  address,
Instruction  instruction 
)

Write some instruction into some virtual memory cell.

Parameters:
address Virtual address to write the instruction into
instruction Instruction to write into the memory cell
Note:
If you want to write a value instead, use pasm_writeValue()
See also:
pasm_writeValue

pasm_readInstruction

void pasm_writeValue ( uint32_t  address,
int32_t  value 
)

Write some value into some virtual memory cell.

Parameters:
address Virtual address to write the value into
value Value to write into the memory cell
Note:
If you want to write an instruction instead, use pasm_writeInstruction()
See also:
pasm_writeInstruction

pasm_readValue


Generated on Thu Jun 11 02:07:50 2009 for PASM by  doxygen 1.5.6