DASM
|
DCPU-16 assembler I/O functions for reading and writing binary files. More...
Private Member Functions | |
Public Functions | |
retval | new (scalar proto, scalar dasm) |
Create an object upon which we can work. | |
retval | identify (scalar self, scalar filename, scalar type) |
Identify whether we can handle reading or writing a given file by its filename. | |
retval | extensions () |
List the extensions we support. | |
retval | read (scalar self, scalar content, scalar filename) |
Read a binary dump and populate our core. | |
retval | write (scalar self, scalar filename) |
Write a binary dump from our core. | |
Private Attributes | |
scalar | default_endian |
Default endian order; use 'binle' or 'binbe'. |
DCPU-16 assembler I/O functions for reading and writing binary files.
The specification doesn't say anything about the 8bit representation of a 16bit word output. The backstory only talks about the 16bit word ordering. Consequently, the representation could be either way around.
By default we assume little endian, although an explicit ordering can be forced by using a different file extension:
.bin
- default ordering (little endian) .binle
- little-endian .binbe
- big-endianBinary dumps contain no symbols or relocation data. They are raw dumps of the content.
retval DASMIO::Binary::extensions | ( | ) | [private] |
retval DASMIO::Binary::identify | ( | scalar | self, |
scalar | filename, | ||
scalar | type | ||
) | [private] |
Identify whether we can handle reading or writing a given file by its filename.
[in] | $self | Address object |
[in] | $filename | Filename we're accessing |
[in] | $type | 'read' or 'write' |
1 | if we can access it |
0 | if we cannot access it |
retval DASMIO::Binary::new | ( | scalar | proto, |
scalar | dasm | ||
) | [private] |
Create an object upon which we can work.
[in] | $proto | Prototype object, or this class's name |
[in] | $dasm | DASM object we're working on |
retval DASMIO::Binary::read | ( | scalar | self, |
scalar | content, | ||
scalar | filename | ||
) | [private] |
Read a binary dump and populate our core.
[in] | $self | Address object |
[in] | $content | Content to parse |
[in] | $filename | File it came from |
retval DASMIO::Binary::write | ( | scalar | self, |
scalar | filename | ||
) | [private] |
Write a binary dump from our core.
In order to write an address dump, we need to force a resolve of all of the symbols. If there are any symbols that cannot be resolved, that's a fatal error - because they would write out as 0s.
[in] | $self | Address object |
[in] | $filename | Filename we're writing |
scalar DASMIO::Binary::default_endian [private] |