Class IntelHEX
java.lang.Object
net.emustudio.emulib.io.IntelHEX
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(byte... data) Adds bytes at the next address, in the given order.intvoidWrites the program into an Intel HEX file.getCode()voidloadIntoMemory(MemoryContext<Byte> memory) Writes the program into memory.static IntelHEXParses an Intel HEX file.voidsetNextAddress(int address) Sets the address where the next byte will be added.
-
Constructor Details
-
IntelHEX
public IntelHEX()
-
-
Method Details
-
add
public void add(byte... data) Adds bytes at the next address, in the given order. Existing bytes are overwritten.- Parameters:
data- bytes to add
-
setNextAddress
public void setNextAddress(int address) Sets the address where the next byte will be added.- Parameters:
address- next address
-
getCode
- Returns:
- unmodifiable view of program bytes by address, in ascending address order
-
findProgramLocation
public int findProgramLocation()- Returns:
- the lowest address of the program, or 0 if the program is empty
-
loadIntoMemory
Writes the program into memory.- Parameters:
memory- target memory
-
generate
Writes the program into an Intel HEX file. Records hold up to 16 bytes and break at address gaps.- Parameters:
outputPath- output file- Throws:
IOException- if the file could not be written
-
parse
Parses an Intel HEX file.Blank lines and lines starting with ';' (after leading whitespace) are ignored, as are input checksums and empty records. Only data records are supported. Later records overwrite earlier ones.
- Parameters:
file- input file- Returns:
- parsed program
- Throws:
IOException- if the file cannot be read or is malformed (the message contains the line number)
-