coolray.org FAQ Contact Us
CoolRay Banner
CoolRay / Documentation
Main Page   Class Hierarchy   Compound List   Compound Members   Related Pages  

Assembler Class Reference

The class Assembler provides basic code generation facilities. More...

#include <Assembler.h>

Collaboration diagram for Assembler:

Collaboration graph
[legend]
List of all members.

Public Methods

 Assembler ()
 constructor.

 ~Assembler ()
 destructor.

Label allocString (const char *szString)
 get a symbolic reference id for a String and store the double in the data area.

Label allocDouble (double value)
 get a symbolic reference id for a double and store the double in the data area.

Label allocVector (const Vector3 &v)
 get a symbolic reference id for a Vector3 and store the double in the data area.

Label allocPoint (const Vector2 &v)
 get a symbolic reference id for a Vector2 and store the double in the data area.

Label allocColor (const Color &c)
 get a symbolic reference id for a Color and store the double in the data area.

Label allocLabel ()
 allocate a code label.

Label allocBSS (unsigned long size)
 allocate a bss label.

Label allocVariable (const Type &type,const char *name)
 Allocate a global variable label. More...

StackLabel getStackLabel ()const
 Get the current Stack position as StackLabel object.

StackLabel getBaseLabel ()const
 Get the current BasePointer position as StackLabel object.

void setLabel (const Label &label)
 define the location of a allocated label.

void addCommand (long opcode) throw (bad_alloc)
 add a assembler command without addtional parameters. More...

void addCommand (long opcode,const string &data) throw (bad_alloc)
 add a assembler command which takes a string parameter.

void addCommand (long opcode,const char *data) throw (bad_alloc)
 add a assembler command which takes a string parameter.

void addCommand (long opcode,long data) throw (bad_alloc)
 add a assembler command which takes a integer parameter.

void addCommand (long opcode,int data) throw (bad_alloc)
 add a assembler command which takes a integer parameter.

void addCommand (long opcode,unsigned long data) throw (bad_alloc)
 add a assembler command which takes a integer parameter.

void addCommand (long opcode,bool data) throw (bad_alloc)
 add a assembler command which takes a boolean parameter.

void addCommand (long opcode,double data) throw (bad_alloc)
 add a assembler command which takes a double parameter.

void addCommand (long opcode,const Vector2 &data) throw (bad_alloc)
 add a assembler command which takes a Vector2 parameter.

void addCommand (long opcode,const Vector3 &data) throw (bad_alloc)
 add a assembler command which takes a Vector3 parameter.

void addCommand (long opcode,const Color &data) throw (bad_alloc)
 add a assembler command which takes a Color parameter.

void addCommand (long opcode,const Label &label) throw (bad_alloc)
 add a assembler command which takes a Label parameter The possible Labels are: code labels (for jumps) (global uninitialized) data (load/store) (constant initialized) data (load/store).

void addCommand (long opcode,const StackLabel &label) throw (bad_alloc)
 add a assembler command which takes a StackLabel parameter for stack or base pointer relative addressing.

ObjectFilegetObjectFile ()const
void setObjectFile (ObjectFile *pObjectFile)
void finalizeObjectFile ()
 Finalize generation of the ObjectFile.


Detailed Description

The class Assembler provides basic code generation facilities.

It allows handling of Assembler code with labels and frees the code generation code from address calculations and low level opcode calculations. It also provides some means for register allocation management.

See also:
Register , Label


Member Function Documentation

void Assembler::addCommand ( long opcode ) throw (bad_alloc)
 

add a assembler command without addtional parameters.

The opcode given is a 32-bit value with various options. Either it can be one of the real opcodes defined for the virutal machine or it can be a replacement opcode. A replacement opcode is a virtual opcode defined by the assembler only. It something like a macro and will expand automatically into one of various real opcodes. One example is OPCODE_LOAD_STACK which doesn't define if the offset is encoded as 8/16 or 32-bit constant, the real virtual machine opcodes nevertheless does. The assembler will choose automatically what special opcode for OPCODE_LOAD_STACK is actually used.

The replacement opcodes are therefore as a method for more convenient code generation. Additionally this leaves some optimizations to the assembler, the "real" parsers haven't to bother with them.

NOTE: addCommand is heavily overloaded with a second parameter of various diffrent types, this is for convenience. Depending on the addtional parameter t

Label Assembler::allocVariable ( const Type & type,
const char * name )
 

Allocate a global variable label.

Parameters:
type   type of the variable
Returns:
label to use to generate access code to this variable


The documentation for this class was generated from the following file:
  • Assembler.h
You are visitor No.

counter

Copyright (c) 2001 Stefan Michel, All Rights Reserved.
Last modified: