1

I am working through the exercises of Lance Leventhal's 6800 Assembly Language Programming on my Epson HX-20. My understanding is that the HX-20's Hitachi 6301 processor is compatible with the Motorola 6800.

The first examples of Leventhal's book use direct referencing, and try to manipulate, for example, addresses 0040 and 0041. However, on the HX-20 addresses to 004D are protected for I/O routines and cannot be manipulated from the Monitor. Furthermore, according to chapter 14 of the technical reference manual (available here), the following addresses up to 00FF are also used by different processes:

  • 004E to 007F: "Real Time Clock"
  • 0080 to 00FF: "This area is used as a work area by the basic interpreter."

My understanding is that direct addressing on the 6301 (as on the 6800) is only for addresses to 00FF, and (in contrast to the 6809) this behaviour cannot be modified - there is no DP register.

In this case, how can I safely modify such example routines to work on the HX-20? What would be the effects of using either of the areas above? Or do I need to resort to a different type of addressing and use addresses from 0A40 to 3FFF, which seem to be the RAM areas left exclusively for user programs?

3

Direct Addressing is what Hitachi used as a term for an addressing mode that takes immediate 8-bit values as address. Obviously, this can only be used to address the lower 256 bytes of memory/IO. Apparently, the HX-20 ROM already uses this memory area for internal purposes. If you don't want to interfere (or, knowing what you're doing, manipulate) these ROM routines, you should stay away from modifying these addresses (No harm done if you only read from there).

With direct addressing of the low memory variables, you could achieve such things as, for example, re-writing the vectors that are called when the BREAK key is pressed or the battery voltage is low to own machine code routines.

The other immediate addressing mode the 6301 supports is Extended Addressing that takes addresses from 0 to $FFFF - This works exactly the same as Direct Addressing, but uses 2-byte long addresses and also uses the same mnemonics. Your assembler should be smart enough to assemble instructions that use short addresses into direct addressing modes and longer (>$FF) addresses into extended addressing modes instructions automatically. Extended addressing has to use a 3-byte instruction format, because obviously the 16-bit address has to go somewhere, so your programs are a bit longer when using extended addressing.

  • So is direct addressing really the same thing as zero page on the 6502? – Wilson Mar 19 '18 at 13:43
  • @Wilson Sortof, I'd say. The 6502 zero page can hold 16-bit pointers and has extra zero-page addressing modes that load and store indirectly via zero-page registers (e.g. LDA ($FE),Y, which loads the data from the address pointed to by zero-page addresses $FE and $FF + Y). The 6301 doesn't have such functions but uses its index registers instead. The lower 256 bytes don't seem in any way special to me except they can be accessed using shorter instructions. – tofro Mar 19 '18 at 14:10
  • So it's not really "immediate". Immediate means the "address" in the instruction is actually a constant. – JeremyP Mar 20 '18 at 10:36
  • @JeremyP Well, for the 6301, it is "immideate" - The address in the instruction is a constant - either an 8-bit or a 16-bit one. – tofro Mar 28 '18 at 11:43
2

Warning
I remember the HX-20 being around but have never used one.
The following advice is untested. Use at your own risk!


Working through information from HX-20 Wikipedia page:

  • You can enter the Monitor by pressing 1 at the startup menu.

  • If the BASIC ROMs are absent (#2 and #3 from the Wiki page), then the machine works fine (but without the option of using BASIC, obviously).

From those two points, I would be fairly confident in saying any RAM used by BASIC when it is running (i.e. 0080 to 00FF) would be safe to use while you are in the monitor (i.e., the monitor does not make use of code in the BASIC ROMs, so shouldn't be dependent on any RAM that BASIC uses).

Thus, if you were to go straight to the Monitor on startup, I believe you should be able to use the RAM between 0080 and 00FF for your own purposes.

If you used MON to enter the monitor from BASIC, then it would probably be OK to use that RAM "for the duration", but if you were to return to BASIC (using the B command, if I'm reading that Wiki page correctly), then BASIC may get confused – it would probably be safer to reset.

  • If you can figure out what BASIC is using any particular location for, you can probably return to BASIC safely. For example, on the Commodore PET, a common trick was to use the BASIC floating point accumulators for zero page addressing (there were two four byte locations used for them). The fp accumulators were only used when evaluating BASIC arithmetic expressions, so it was fine to trash them in a machine code routine. – JeremyP Mar 20 '18 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.