DASM
Private Attributes
DASM Class Reference

DCPU-16 assembler context class. More...

List of all members.

Private Member Functions

Public Functions
retval new (scalar proto)
 Construct a new assembler object.
retval initio (scalar self)
 Initialise all the IO types so that we know about them.
retval listio (scalar self)
 List the IO methods available.
retval findio (scalar self, scalar filename, scalar type, scalar access)
 Find the correct IO object to use for a given file operation.
retval readfile (scalar self, scalar filename, scalar type)
 Read a file of a given type.
retval writefile (scalar self, scalar filename, scalar type)
 Write a file of a given type.
retval error (scalar self, scalar error)
 Report a parsing error to the user.
retval parsestack (scalar self)
 Return the location in the parser stack we currently are at.
retval startfile (scalar self, scalar file, scalar line)
 Begin processing a file at a given line.
retval endfile (scalar self)
 End processing a file.
retval stepline (scalar self, scalar line)
 Step to the next line.
retval setpc (scalar self, scalar pc)
 Set the PC value.
retval store (scalar self, scalar addr, scalar value)
 Store a value in the core.
retval storetopc (scalar self, scalar value)
 Store a value at the current PC, incrementing after.
retval storeinc (scalar self, scalar addr, scalar value)
 Store and increment value in the core.
retval read (scalar self, scalar addr)
 Read a value from the core.
retval label (scalar self, scalar addr, scalar label)
 Assign a label to an address.
retval setsymbol (scalar self, scalar symname, scalar value, scalar type)
 Set a symbol to a value.
retval getsymbol (scalar self, scalar symname)
 Return a given symbol name.
retval resolve (scalar self)
 Resolve any unresolved relocations, where possible.
retval addhardware (scalar self, scalar address, scalar object)
 Record the hardware provided by a device.
retval dump (scalar self)
 Display a dump of the code that we've compiled so far.

Private Attributes

scalar debug_store
 Whether we're debugging the store operations.
scalar debug_asm
 Whether we're debugging the assembly operations.
scalar debug_sym
 Whether we're debugging the symbols.

Detailed Description

DCPU-16 assembler context class.

Holds the current state of our assembler context as we build and the methods to perform the assembly. We manage a number of IO objects which can provide file read and write formats. The IO objects can process the files based on their extension, or be explicitly requested to read or write data by giving their type.

Possible use:

  my $dasm = new DASM();
  $dasm->readfile($inputname);
  $dasm->writefile($output);
  $dasm->dump();

Definition at line 47 of file DASM.pm.


Member Function Documentation

retval DASM::addhardware ( scalar  self,
scalar  address,
scalar  object 
) [private]

Record the hardware provided by a device.

Parameters:
[in]$selfDASM object
[in]$addressBase address of the device
[in]$objectDevice object
retval DASM::dump ( scalar  self) [private]

Display a dump of the code that we've compiled so far.

Parameters:
[in]$selfDASM object
retval DASM::endfile ( scalar  self) [private]

End processing a file.

Parameters:
[in]$selfDASM object
retval DASM::error ( scalar  self,
scalar  error 
) [private]

Report a parsing error to the user.

Parameters:
[in]$errorError message
Note:
never returns
retval DASM::findio ( scalar  self,
scalar  filename,
scalar  type,
scalar  access 
) [private]

Find the correct IO object to use for a given file operation.

If a type is explicitly given, we attempt to use it. If not, each io object is queried to identify whether they understand the file by its name.

If no type is recognised, we die.

Parameters:
[in]$selfDASM object
[in]$filenameFilename to access
[in]$typeType name (optional)
[in]$accessAccess type; 'read' or 'write'
Returns:
IO object for accessing the file
retval DASM::getsymbol ( scalar  self,
scalar  symname 
) [private]

Return a given symbol name.

Parameters:
[in]$selfDASM object
[in]$symnameSymbol name
Returns:
hashref for symbol, or undef if not known: 'type' => 'address' or 'constant' 'value' => 'value' of the symbol
retval DASM::initio ( scalar  self) [private]

Initialise all the IO types so that we know about them.

We try to initialise all the objects in the DASMIO directory, and for those objects we create an object.

Parameters:
[in]$selfDASM object
retval DASM::label ( scalar  self,
scalar  addr,
scalar  label 
) [private]

Assign a label to an address.

Parameters:
[in]$selfDASM object
[in]$addrAddress to store at
[in]$labelLabel to assign
retval DASM::listio ( scalar  self) [private]

List the IO methods available.

Parameters:
[in]$selfDASM object
Returns:
arrayref of IO objects
retval DASM::new ( scalar  proto) [private]

Construct a new assembler object.

Parameters:
[in]$protoThis class object, or prototype to add to
Returns:
Assembler object
retval DASM::parsestack ( scalar  self) [private]

Return the location in the parser stack we currently are at.

Parameters:
[in]$selfDASM object
Returns:
Description of the line stack, from most recent to oldest over multiple lines
retval DASM::read ( scalar  self,
scalar  addr 
) [private]

Read a value from the core.

Parameters:
[in]$selfDASM object
[in]$addrAddress to read from
retval DASM::readfile ( scalar  self,
scalar  filename,
scalar  type 
) [private]

Read a file of a given type.

If the type cannot be found, or some other error occurs, we die.

Parameters:
[in]$selfDASM object
[in]$filenameFilename to read
[in]$typeType of file to read (a DASMIO object)
retval DASM::resolve ( scalar  self) [private]

Resolve any unresolved relocations, where possible.

Parameters:
[in]$selfDASM object
Return values:
1if everything was resolved
0if there were symbols unresolved
retval DASM::setpc ( scalar  self,
scalar  pc 
) [private]

Set the PC value.

Parameters:
[in]$selfDASM object
[in]$pcNew PC value
[in]$valueValue to store
retval DASM::setsymbol ( scalar  self,
scalar  symname,
scalar  value,
scalar  type 
) [private]

Set a symbol to a value.

Parameters:
[in]$selfDASM object
[in]$symnameSymbol name
[in]$valueThe value of the symbol
[in]$typeThe type of symbol to set
retval DASM::startfile ( scalar  self,
scalar  file,
scalar  line 
) [private]

Begin processing a file at a given line.

Parameters:
[in]$selfDASM object
[in]$fileFile we start beginning processing
[in]$lineLine we are parsing at (or undef for start of file)
retval DASM::stepline ( scalar  self,
scalar  line 
) [private]

Step to the next line.

Parameters:
[in]$selfDASM object
[in]$lineExplicitly move to a given line (optional)
retval DASM::store ( scalar  self,
scalar  addr,
scalar  value 
) [private]

Store a value in the core.

Parameters:
[in]$selfDASM object
[in]$addrAddress to store at
[in]$valueValue to store
retval DASM::storeinc ( scalar  self,
scalar  addr,
scalar  value 
) [private]

Store and increment value in the core.

Parameters:
[in]$selfDASM object
[in]$addrAddress to store at
[in]$valueValue to store
retval DASM::storetopc ( scalar  self,
scalar  value 
) [private]

Store a value at the current PC, incrementing after.

Parameters:
[in]$selfDASM object
[in]$valueValue to store
retval DASM::writefile ( scalar  self,
scalar  filename,
scalar  type 
) [private]

Write a file of a given type.

If the type cannot be found, or some other error occurs, we die.

Parameters:
[in]$selfDASM object
[in]$filenameFilename to read; just an extension starting with a period will print to the screen, eg '.dasm'
[in]$typeType of file to write (a DASMIO object)

Member Data Documentation

scalar DASM::debug_asm [private]

Whether we're debugging the assembly operations.

Definition at line 54 of file DASM.pm.

scalar DASM::debug_store [private]

Whether we're debugging the store operations.

Definition at line 51 of file DASM.pm.

scalar DASM::debug_sym [private]

Whether we're debugging the symbols.

Definition at line 57 of file DASM.pm.


The documentation for this class was generated from the following file: