The goal of this program is to load an arbitrary program in Intel HEX format into an arbitrary location in the Z80 address space, and allow you to start the program from Nascom Basic.
There are are several stages to this process.
hexloadr.asmloader program must be compiled into a binary format,
HEXLOADR.BINmust then be converted to a series of poke statements using the
- These poke statements are then loaded through the serial interface into Nascom Basic to get the HexLoadr program placed correctly into the RAM of the RC2014 or YAZ180 machine.
- The starting adddress of the HexLoadr program must be inserted into the correct location for the
USR(x)jump out of Nascom Basic.
- Then the HexLoadr program will initiate and look for your program's Intel HEX formatted information on the serial interface.
- Once the final line of the HEX code is read, the HexLoadr will return to Nascom Basic.
- The newly loaded program starting address must be loaded into the
- Start the new arbitrary program by entering
There are a number of important Z80 addresses or origins that need to be modified (managed) within the assembly and python programs.
Arbitrary Program Origin
Your program (the one that you're doing all this for) needs to start in RAM located somewhere. Some recommendations can be given.
For the RC2014 with 32kB of RAM, when Nascom Basic initiates it requests the "Memory Top?" figure. Setting this to 57343 (
0xDFFF), or lower, will give you space from
0xFFFF for your program and for the hexloader program.
The eXit option on my initiation routine for Nascom Basic is set to jump to
0xE000, Under the assumption that if you are jumping off at restart you are interested to have a large space for your arbitrary program.
For the YAZ180 with 56kB of RAM, the arbitrary program location is set to
0x3000, to allow this to be in the Common 0 Space for the MMU.
HexLoadr supports the Extended Segment Address Record Type, and will store the MSB of the ESA in the Z180 BBR Register. The LSB of the ESA is silently abandoned. When HexLoadr terminates the BBR is returned to the original value.
HexLoadr Program Origin
For convenience, the HexLoadr program is configured to load itself from
0xFF00. This means your arbitrary program can use the space from
0xFEFF without compromise. Further, if you want to use a separate stack or heap space (preserving Nascom Basic) the HexLoadr program space can be overwritten, by setting the stack pointer to
0x0000 (which decrements on use to
This can be changed if substantial code is added to the HexLoadr program
For convenience, because we can't easily change ROM code interrupt routines already present in the RC2014 or YAZ180, the serial Tx and Rx routines are reachable by calling
RST 08Hexpects a byte in the
RST 10Hreturns a byte in the
aregister, and will loop until it has a byte to return.
- Rx Check:
RST 18Hwill return the number of bytes in the Rx buffer (0 if buffer empty) in the
Select the preferred origin
.ORGfor your arbitrary program, and assemble a HEX file using your preferred assembler.
Confirm your preferred origin of the hexloadr program, and adjust it to match in the
Assemble hexloadr.asm using TASM to produce a HEXLOADR.BIN file using this command line.
tasm -80 -x3 -a7 -fff -c -l -g3 d:hexloadr.asm d:hexloadr.bin.
Produce the "poke" file called
hexloadr.basby using the python command.
python bin2bas.py HEXLOADR.BIN > hexloadr.bas.
Start your RC2014 with the
Memory top?set to 57343 (
0xDFFF) or lower. This leaves space for your program and for the HexLoadr program.
Using a serial terminal (assuming your machine is located at device
/dev/ttyUSB0) either copy and paste all of the "poke" commands into the RC2014, or upload them using a slow (or timed) serial loading program. If desired the python
slowprint.pyprogram can be used for this purpose.
python slowprint.py < hexloadr.bas > /dev/ttyUSB0.
okprompt in Basic, start the HexLoadr program with
Using a serial terminal, upload the HEX file for your arbitrary program that you prepared in Step 1. If desired the python
slowprint.pyprogram can also be used for this purpose.
python slowprint.py < myarbitraryprogram.hex > /dev/ttyUSB0. The Linux
catprogram also works well in this role.
DOKEcommand relocate the address for the
USR(x)command to point to
.ORGof your arbitrary program.
When HexLoadr has finished, and you are back at the Basic
okprompt start your arbitrary program using
PRINT USR(x), or other variant if you have parameters to pass to your program.
If you are using the version integrated into the NASCOM Basic, you can start at Item 6 above, by loading your program where you choose. But, don't forget you still need to follow the rest of the steps to set the jump location for the
For the RC2014 the
USR(x) jump address is located at
&h8124. If your program is located at
&hA000 then the command is
doke &h8124, &hA000
For the YAZ180 the
USR(x) jump address is located at
Derived from the work of @fbergama and @foxweb at RC2014.