nealcrook / nascom

Software, utilities and documentation for the Z80-based NASCOM2 computer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to add Intel HEX as an optional assembly listing mode?

feilipu opened this issue · comments

I'm using Zen with the RC2014 NASCOM Basic, and I'd like to have it produce Intel HEX as an optional assembly listing mode.

I understand that Zen already produces a tabulated object format output which is close to HEX (key ->A->C), and with your perl tools it is easily convertible to HEX. But, it would very be nice to be able to go directly from a captured HEX output to loading it back into the machine without intermediate processing. This would allow larger programs to be built, and would simplify usage for me (and hopefully others too).

I'm quite happy to write the option and submit it back via PR, if you'd prefer. But, currently the only source I have has no comments so is challenging (to say the least) to understand where is the best place contribute.

Could you please give some guidance on where to start in the code to achieve this outcome?

Just to note I've modified my forked source format to assemble with z88dk-z80asm (just changes to text quoting and the OR symbol) rather than self assemble.

Cheers, Phillip

Hi Phillip,

I think your code started off at my github and was then modified by Phil_G?

There is a file here named "ZEN_t4_annotated.asm" in which I worked with another nostalgiast (is that a word?) to reverse-engineer the behaviour of the code and add comments. That was the starting-point for the source code that Phil used.

My original project to get a commented listing was inspired by a request from Phil. However, I wanted to use Zen to assemble Zen and the commented listing was too big! I used a PERL script to remove the comments before cross-assembling on a NASCOM emulator from ZEN itself (yeah, I'm so hard-core :-)

Since your assembler will not have these file size restrictions I suggest you use some kind of visual diff tool to start with ZEN_t4_annotated.asm and port all of you changes/Phil's changes to that source, then you will have nice(ish) commented source.

That should be a much better starting point for modifying the code. The "C" command is to save on tape, in a ZEN-specific format. To save in Intel Hex format I think you will need a small memory buffer because that format has a byte count at the start of the line and you don't know that count for sure until later (you could avoid that problem by always using a block-size of, say, 8 but then you'll need to pad to 0 any time the ORG changes?) Somewhere out on the web I found Zen for the Sharp MZ80K and the manual for that version included (slightly) commented source code, but it was rather different from the NASCOM version and the comments didn't help shed light on the fiddly bits of the code.

When you look at the source there are numerous places where the author has used 8-bit addressing/offsets as a space-saver, assuming a constant high-order byte. What that means is, if you assemble Zen at certain start addresses where the code will cross a page boundary at an "awkward" place, it will not work!

Hope that helps. Feel free to ping me if you have any other questions (or if you have any improvements to make to the source code comments). I'm sure Phil will also be interested in your mods.

Thanks Neal, I'll follow the path as you suggested.

It might take a bit of mull time for me to get back with a PR for IHEX, so if you prefer you could close this question.

PS. Hope the acknowledgment and link from my git repo is ok for you.

P.

Acknowlegement is fine, thanks; I'll update my README to point to your work. I'll close this ticket but feel free to get back in contact if you have any other questions,
Neal.

Just to note that Phil G has already done this, and his updates are included in my repo too.