• Please review our updated Terms and Rules here

Epson HX-20 - FORTH ROM

It's already working nicely! At least for simple definitions... let me implement factorial... but so far - really nice progress!!
Yes, system routines such as "BEEP" immediately give us the Trap! But simple stuff is working!
 

Attachments

  • 20220325_081622.jpg
    20220325_081622.jpg
    408.8 KB · Views: 6
  • 20220325_081637.jpg
    20220325_081637.jpg
    393.3 KB · Views: 6
Factorial...
 

Attachments

  • 20220325_082841.jpg
    20220325_082841.jpg
    422.2 KB · Views: 2
  • 20220325_082848.jpg
    20220325_082848.jpg
    423.7 KB · Views: 2
@GeoffB17
Could do the same for the other ROMs. 8000-9FFF, A000-BFFF, C000-DFFF, E000-FFFF? Assuming writing the original file as a .WAV will work, then the hxtape process to convert the .WAV to text? I've done this with smaller files before, OK.
That would be fantastic... the HX-20 community would be really thankful for that! The are so few software titles available for that machine. I think that'll be really important to preserve and keep these few titles running, such as the FORTH.

You don't have a programmer to simply read them out? My TL866 (and the Genius G540) have no issues reading the original EPSON ROMs (which are already EPROMS in my case). There is some different information on the Web saying that these are not standard 2764 EPROMs, but I couldn't attest to that. I had no issue simply dumping them to a BIN with the programmer.
 
I'll have a go at the first of the ROMs, see how that goes. If it all works, then I'll try the others.

You mentioned the BEEP word as giving a problem. It works fine when I try it on my machine. But then, it would!

I've looked at the code in the .BIN file.

The definition starts with the usual header items (links to this and prev items), this is followed by some PUL codes to get the parameters off the stack, then there is a JSR to E34D which is likely to be slightly different in your ROMs? This is followed by the JMP NEXT, so there's not much to BEEP! I'd guess that it's nothing more than resolve the parameters and jump to the hardware at E34D. By the way, BEEP requires two paramers (numbers) for note and len, so in FORTH you need to enter, say, 5 6 BEEP. If the parameters are not given then it may produce an error anyway. But not a Trap? It you get a Trap, then I think the E34D may be x bytes out.

Oh, I don't want to be doing all 100 pages of the manual. Most is standard FORTH anyway. I'll look to see what's involved with doing the specifically HX parts, i.e. some of the examples, and the part of the dictionary for the HX words. As someone noted in this thread, the bulk of the system seems to be standard fig forth?

Geoff
 
Yes, 5 6 BEEP also Trap! s (and many other things, e.g., IMMEDIATE, VARIABLE, ...) Right now it's a mine field - I was extremely lucky that FACT above worked out of the box :)
 
If D715 ends up jumping to FF49 (DSPLCN), then the ‘jsr $D715’ can be replaced with ‘jsr $FF49’ and that will now work with either version of the firmware.

Incidentally, the firmware manual that describes FF49 (DSPLCN) identifies the first two bytes of the string pointed to by the X register as the starting X and Y coordinate to display the text at on the virtual screen.

The next thing is BEEP then...

Keep pecking at it a call at a time!

EDIT: You probably need to list the FORTH vocabulary and try each defined word out one at a time in a test program to see which ones fail. This should at least identify what is failing. If we can disassemble the existing FORTH ROM enough to identify where the vocabulary starts, then we could disassemble the vocabulary to identify the bits of machine code that are identified with each word. @Dwight Elvey, this is right up your street isn’t it!

Dave
 
Last edited:
If you mean disassembler I don’t, I am doing it by hand...

There is an online assembler I like to use (asm80.com). It will do 6800 - but not the enhanced 6803.

Dave
 
Forth is a fascinating language. I've got a number of versions. It's not a great deal of use for the main things I need to write programs for, but it's by far the most interesting to play with.

All the definitions (words) within the system are linked, this is part of the structure that allows the system to find the word it needs. The structure starts at the end of the file, and each word is linked to the previous word. The system knows which is the last word, but if you try to do something with the raw file (i.e. not using forth) then it's a little more problematic, but once you've got the last word you can link through from there.

The word to list the whole vocabulary (in this case) is VLIST, but in other implementations it might be WORDS. If you do VLIST here, then the first word to list is 2*, and if you use a hex editor on the binary file then you can see 2* on the last page, but there is some binary stuff after that and I'm not sure what that it just now. The next word to list is MOD, and that's the word immed previous to 2*. There may be code definitions within the structure that do not have names, but that's one of the complications, for example the data immed before BEEP has a fair bit of code but no visible names. Each definition has a header before the active code, which will include a code for the type of word, also the address of the next word up, and the address of the active code in this definition. So 2* links up to MOD, which in turn links up to the previous word WIND (re the cassette drive) and so on. Fun! The last part of each definition is usually common to all, and is the link to NEXT, which returns from processing this word and proceeds to the next word in the higher level.

It would be quite possible to create a prog that will look through the complete system and look for any use of suspect links, i.e. that might not work in the currest situation. Prob best to work out the address of the last (first) word in the chain manually mind you. This address is prob defined in forth, as this is needed for properly adding new definitions to the chain, but if you're not actually using forth, the process may need some help.

Pity that you don't get this much help when looking through a screen of machine code!

By the way, I've got some definitions worked out from years ago regarding some 'disassembly' of FORTH definitions - this worked very well on the HX, although it was better to display on the printer. I copied the code from a magazine back 198?, made a few adjustments to suit the words available in this FORTH, and got it working. I think I've got a photocopy of the magazine article as well somwehere, which explains everything.

Geoff
 
That’s the reason why I linked Dwight into the thread. I seem to remember (from a couple of years ago) that he wrote just such a FORTH disassembler in FORTH itself...

Dave
 
Yes, Forth is fascinating - interesting also the "meta programming" aspects that are possible with it. I am Common Lisp programmer for~ 25 years by now, and was surprised to see that language / compiler extensions are possible in Forth as well. Even though I only got into Forth recently, I have a pretty good understanding of the language by now, the dictionary (LFA, CFA; PFA, ...), as I dissected the Forth for my Microprofessor MPF-IP using the Brodie books - I even got to implementing DOER / MAKE and recursive versions of FACT ;-) Which requires some form of vectored execution. If you are interested into my "Forth on the Microprofessor", have a look here - I made 5 videos (apologies for poor English):

https://www.youtube.com/playlist?list=PLvdXKcHrGqhdMPXNGfCzHPD5k9wWIG5PS

Since I master the Microprofessor Forth, I of course needed a new Forth challenge - and this is the HX-20 Forth :)

Yes, I understand - go through the dictionary, follow the LFA / linked list, for each word, go to the PFA / parameter fields containing the calls to the CFAs for the address interpreter, check which of these CFAs are in 0x6000 - 0x7FFF (these are other Forth words), and check which are outside - these are direct system calls then. We could list all these, but then, you'd still have to have a good mapping table from 1.0 to 1.1 as discussed. Pheew...well at least the Name Fields for the respective Words will give you a good hint of the intended semantics. But still, a lot of work. It's such a pity that they didn't use the jump tables (Amstrad did it right, @GeoffB17 will know what I mean ;-) )
 
Last edited:
Btw, @Dwight Elvey you probably don't remember me, but I saw your 4004 "naval torpedo calculation" demo at VCF West in Mountain View last year (that Gary Kildall implemented as a student?)
 
Btw, what assembler are you guys using for this work? Just some generic 6809?
I'm using DASMx, specifying the 6301 as the target CPU. I can't use a generic 6800 disassembler because this FORTH is taking advantage of some of the 6301's enhanced instructions.

I think I'm going to try modifying EMIT to use the serial port output routine instead of the "virtual screen" output routine. I'd like to get a mapping of the dictionary using a more capable VLIST that also includes the address of the word. There's probably a page in the manual with this information, but I can't find any scans of the manual online :(
 
Hello @TangentDelta,

I have the manual for this FORTH, I don't think there's any mention of the serial port at all. Any print things are just using the built-in printer, and nothing re comms as such.

But when I was trying to add some definitions for using the TF-20 floppy drives with FORTH, I created words to access the high speed serial port routines and these worked fine, so no reason why you couldn't do the same with standard SIO.

Regarding your VLIST idea, just need to note the code for normal VLIST, then create a new version i.e. VLIST2 which does the extra function after the EMIT to screen?

Geoff
 
Hello @TangentDelta,

I have the manual for this FORTH, I don't think there's any mention of the serial port at all.
Is there a page or two in there with a big list of the words, and what address the word is located at in the dictionary? Something that looks like this attached image?Screenshot_20220326_120920.png
 
Here is an example how to get the CFA address for a word:

' + CFA U. -> 25798 OK
10 20 25798 EXECUTE . -> 30 OK

Or directly:
10 20 ' + CFA EXECUTE . -> 30 OK
Does the same as:
10 20 + . -> 30 OK

(Here we are demonstrating the CFA of "+", and executing it indirectly -
' <WORD> puts the PFA of <WORD> on the Stack, and CFA converts PFA to CFA for EXECUTE)
 
PS I should say that the example above actually worked with your patched FORTH on the HX-20, so it should be possible to implement VLIST2 already. I can try...
 
Just to answer the question asked above regarding the vocab list in the manual, for what it's worth..

There IS a list of FORTH words, with parameters, in the back of the manual, BUT this is a generic FIG listing, and it does not include the CFA address as is being suggested, and it does not include the 'special' HX-20 definitions.

Geoff
 
These are a list of subroutines that appear to be called (outside of the 'nice and clean' subroutine table that is):

Code:
d715
e2ef
d310
e3f2
e34d
e2a5
d957
d977
d9d6
da07
e1ff
eb8f

These are a (less refined) list of JuMPs:

Code:
e900
cafe?
f661?
fe85
ce00?
ae38?
a565?
ac64?
cedf?
b565?
db65?

I will now try and constrain them to the FORTH words to which they are associated with.

Dave
 
Back
Top