DASM
|
DCPU-16 assembler context class. More...
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. |
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();
retval DASM::addhardware | ( | scalar | self, |
scalar | address, | ||
scalar | object | ||
) | [private] |
Record the hardware provided by a device.
[in] | $self | DASM object |
[in] | $address | Base address of the device |
[in] | $object | Device object |
retval DASM::dump | ( | scalar | self | ) | [private] |
Display a dump of the code that we've compiled so far.
[in] | $self | DASM object |
retval DASM::endfile | ( | scalar | self | ) | [private] |
End processing a file.
[in] | $self | DASM object |
retval DASM::error | ( | scalar | self, |
scalar | error | ||
) | [private] |
Report a parsing error to the user.
[in] | $error | Error message |
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.
[in] | $self | DASM object |
[in] | $filename | Filename to access |
[in] | $type | Type name (optional) |
[in] | $access | Access type; 'read' or 'write' |
retval DASM::getsymbol | ( | scalar | self, |
scalar | symname | ||
) | [private] |
Return a given symbol name.
[in] | $self | DASM object |
[in] | $symname | Symbol name |
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.
[in] | $self | DASM object |
retval DASM::label | ( | scalar | self, |
scalar | addr, | ||
scalar | label | ||
) | [private] |
Assign a label to an address.
[in] | $self | DASM object |
[in] | $addr | Address to store at |
[in] | $label | Label to assign |
retval DASM::listio | ( | scalar | self | ) | [private] |
retval DASM::new | ( | scalar | proto | ) | [private] |
Construct a new assembler object.
[in] | $proto | This class object, or prototype to add to |
retval DASM::parsestack | ( | scalar | self | ) | [private] |
Return the location in the parser stack we currently are at.
[in] | $self | DASM object |
retval DASM::read | ( | scalar | self, |
scalar | addr | ||
) | [private] |
Read a value from the core.
[in] | $self | DASM object |
[in] | $addr | Address 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.
[in] | $self | DASM object |
[in] | $filename | Filename to read |
[in] | $type | Type of file to read (a DASMIO object) |
retval DASM::resolve | ( | scalar | self | ) | [private] |
Resolve any unresolved relocations, where possible.
[in] | $self | DASM object |
1 | if everything was resolved |
0 | if there were symbols unresolved |
retval DASM::setpc | ( | scalar | self, |
scalar | pc | ||
) | [private] |
Set the PC value.
[in] | $self | DASM object |
[in] | $pc | New PC value |
[in] | $value | Value to store |
retval DASM::setsymbol | ( | scalar | self, |
scalar | symname, | ||
scalar | value, | ||
scalar | type | ||
) | [private] |
Set a symbol to a value.
[in] | $self | DASM object |
[in] | $symname | Symbol name |
[in] | $value | The value of the symbol |
[in] | $type | The type of symbol to set |
retval DASM::startfile | ( | scalar | self, |
scalar | file, | ||
scalar | line | ||
) | [private] |
Begin processing a file at a given line.
[in] | $self | DASM object |
[in] | $file | File we start beginning processing |
[in] | $line | Line we are parsing at (or undef for start of file) |
retval DASM::stepline | ( | scalar | self, |
scalar | line | ||
) | [private] |
Step to the next line.
[in] | $self | DASM object |
[in] | $line | Explicitly move to a given line (optional) |
retval DASM::store | ( | scalar | self, |
scalar | addr, | ||
scalar | value | ||
) | [private] |
Store a value in the core.
[in] | $self | DASM object |
[in] | $addr | Address to store at |
[in] | $value | Value to store |
retval DASM::storeinc | ( | scalar | self, |
scalar | addr, | ||
scalar | value | ||
) | [private] |
Store and increment value in the core.
[in] | $self | DASM object |
[in] | $addr | Address to store at |
[in] | $value | Value to store |
retval DASM::storetopc | ( | scalar | self, |
scalar | value | ||
) | [private] |
Store a value at the current PC, incrementing after.
[in] | $self | DASM object |
[in] | $value | Value 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.
[in] | $self | DASM object |
[in] | $filename | Filename to read; just an extension starting with a period will print to the screen, eg '.dasm' |
[in] | $type | Type of file to write (a DASMIO object) |
scalar DASM::debug_asm [private] |
scalar DASM::debug_store [private] |
scalar DASM::debug_sym [private] |