TAQOZ - Tachyon Forth for the P2 BOOT ROM

Comments

well I have TAQOZ in RAM loaded together with my user-program via P2load, not loaded from SD so I guess I need to specify a filename for BACKUP. Then I can use that saved binary instead of _BOOT_P2.BIX which I currently link to my program as binary.

And then AUTO EMBED would do the trick and TAQOZ starts, switches to mailbox and starts my FastSpin program, presenting itself as a virtual serial device there without using pins. Perfect.

Another minor question. A result from TAQOZ say sending 2 3 + . <cr> results in

--- 5 ok
TAQOZ#

what would I need to do to get rid of --- and ok <cr> TAQOZ#, I would like to have 5 <cr> without all the decoration?

Anyways, almost there!

Mike

I am just another Code Monkey.
A determined coder can write COBOL programs in any language. -- Author unknown.
Press any key to continue, any other key to quit

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.

reformatting a SD, putting a _BOOT_P2.BIX on it, running my program entering my words adding AUTO EMBED and finally doing a BACKUP BIX created the binary I needed. Except I need to run at 115200 or have garbage on the screen, that might be solvable. Spin2Gui standard setting for terminal is 230400.

This is absolutely cool. Thank you very much.

Mike

I am just another Code Monkey.
A determined coder can write COBOL programs in any language. -- Author unknown.
Press any key to continue, any other key to quit

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.

uprompt and uaccept are user vectors which are normally zero and then use the default action.
$C9 REG is task register $C9 = line number which is used by the default prompt routine which is now disabled but checked by OK
bit 0 of flags is echo

BTW, I don't use a BIX as I just use the MBR to store the file. BU by itself will do this. You can also rename the BIX file after you give yourself RW permissions on the previous line.

I will try to think of something better in the meantime but I am always happy to help those who give it a go and besides, doing it this way I don't have to try to guess whether it is suitable since I am only "assisting"

230400 CONBAUD changes the baud rate instantly and you could do a backup to lock it in or alternatively specify this baud rate in your startup. Same with the clock, just say 160 P2MHZ which also adjusts the console baud rate to suit the new clock. I use P2MHZ for the P2 clock since MHZ is a general smartpin function that sets the pin to NCO mode etc.

From this definition you can see that M is the "mega" suffix that simply multiplies the value supplied by 1 million and passes the result to CLOCK.

changing the output worked also perfect, now remains to change the clockfreq to 160Mhz instead of 80Mhz and the boot-console to 230400 instead of 115200.

Then I am perfectly happy and can explore TAQOZ from my trusted and known environment.

Mike

If you provide a way to switch your serial console transparently through to Taqos (can be via the mailbox).
By using Peters new REMOTE / LOCAL words.
You could still develop Taqos oneliners interactively - so having best of both worlds.

what would I need to do to replace CON by MBX thus preventing CON using the serial pins and using the mailbox instead?

I could then replace CON with a non-blocking mailbox, start TAQOZ not touching serial (and writing garbage on the screen depending on used baud rate) and after my startup finished replace CON with a blocking Mailbox.

my understanding of FORTH thinks that I can redefine a word thus overwriting the existing one with a new one, correct?

This TAQOZ stuff is interesting.

Mike

I am just another Code Monkey.
A determined coder can write COBOL programs in any language. -- Author unknown.
Press any key to continue, any other key to quit

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.

changing the output worked also perfect, now remains to change the clockfreq to 160Mhz instead of 80Mhz and the boot-console to 230400 instead of 115200.

Then I am perfectly happy and can explore TAQOZ from my trusted and known environment.

Mike

If you provide a way to switch your serial console transparently through to Taqos (can be via the mailbox).
By using Peters new REMOTE / LOCAL words.
You could still develop Taqos oneliners interactively - so having best of both worlds.

Yes, I can do that already, but this is quite useless since you will need to write a new image to disk copy the file Back to your PC and recompile your FastSpin program. Doable but complicated.
I think more about a static base TAQOZ and sending definitions of words or just one-liners from the user-program to TAQOZ and back.
But one can also send a one-liner to load some extension from SD into the empty TAQOZ, I guess.

what would I need to do to replace CON by MBX thus preventing CON using the serial pins and using the mailbox instead?

I could then replace CON with a non-blocking mailbox, start TAQOZ not touching serial (and writing garbage on the screen depending on used baud rate) and after my startup finished replace CON with a blocking Mailbox.

my understanding of FORTH thinks that I can redefine a word thus overwriting the existing one with a new one, correct?

This TAQOZ stuff is interesting.

Mike

Hi Mike,
you are already so deep into it.

Just take all the Taqos source files into an editor and search for the words you are interested in.
Like CON
in file TAQOZ (stable).spin2
byte 3, "CON" ,t
word _CON
so the CON word is performed by wordcode _CON

so search for _CON
_CON word rg+uemit,CLRL,EXIT

which is just the internal representation for
pub CON uemit ~ ;

which simply wipes out the uemit and ukey vectors (2 words - here as a long) that you set up with all your effort ;-)

so you want to redefine CON to do MBX instead to restore the mailbox should it have been altered by s.o.

no time to research more and no HW to test, but s.th. like:
' MBX ' CON W! before the BACKUP might do the job.

The trouble with simply overwriting the first wordcode of CON is that it still does a W~ before it exits which clears "a" 16-bit hub memory location, that is, whatever is on top of the stack, even empty, that it treats as an address. There is the REVECTOR word which does the same thing except it sets the "jump" bit b0 of the normally even wordcode before it overwrites the first wordcode of the destination. So try REVECTOR CON MBX.

All the links to my P2 folders of which there is tons of hardware and software are mentioned in my sig. However I decided that I would unclutter it somewhat by creating a new TAQOZ folder which includes not only the P2ASM kernel but also a Forth folder. I just need to add a README yet. (DONE)

The trouble with simply overwriting the first wordcode of CON is that it still does a W~ before it exits which clears "a" 16-bit hub memory location, that is, whatever is on top of the stack, even empty, that it treats as an address. There is the REVECTOR word which does the same thing except it sets the "jump" bit b0 of the normally even wordcode before it overwrites the first wordcode of the destination. So try REVECTOR CON MBX.

All the links to my P2 folders of which there is tons of hardware and software are mentioned in my sig. However I decided that I would unclutter it somewhat by creating a new TAQOZ folder which includes not only the P2ASM kernel but also a Forth folder. I just need to add a README yet. (DONE)

@MJB - Yes, I will have that with the new silicon if it all works since the chips are available around then. I will publish details of the dev board on the P2D2 thread. Please let me know if there is some features you would like, I may just include it.

to me it looks like bmporg will just be used if VGA is enabled, so I might not need it without VGA pins set. But flashpart seems to be a buffer at $E0000. Not good for coexistence. I fought a lot to give TAQOZ the lower HUB RAM and now it wants even $E0000...?

flashpart is an area in serial Flash that I like to store an image of TAQOZ to, nothing more. Even the ROM version can use this and a ^R will restore the Flash version. BTW, SFBU will backup to Flash and SFRE or ^R will restore it.

REVECTOR is in the TAQOZ Forth source folder (the part that is pasted in and compiled by the kernel running on the P2) and it is an immediate word which means that it executes immediately rather than compiles as regular code. So it's only good as a user command by itself although you can put it in your source code but on a line by itself outside of a definition. It's like a compiler directive.
Forth defintiions start with : which you can use in TAQOZ but the dictionary in TAQOZ is enhanced and separate and you can define a word like we do in Spin as pub or pri. While TAQOZ compiles the word normally it marks the dictionary header so that pri word can be culled during a RECLAIM which also makes them "private" To mark a dictionary header as a special immediate word normally required the word IMMEDIATE in Forth but I prefer using pre in place of : or pub to indicate the preemptive nature of the word.

BTW, the ' symbol is an immediate word too and it normally reads the next word in the input stream and compiles the code address of that. All the building words such as :/pub/pri/pre/; etc are immediate.

pre REVECTOR ( <target> <new> -- ) [C] ' [C] ' [G] 1+ SWAP W! ;

(NOTE: if you are curious about what [C] is, it is just another immediate word to force the following immediate word to compile, not execute)

To embed the same into your code you just need to do this manually.

' NEW_WORD 1+ ' OLD_WORD W!

The 1+ just adds one to the address to set bit0 of the address to make it a jump rather than a call. Also, 1+ is just a fast way of setting bit0 on an even address rather than a 1 OR operation.

P.S. I'm interested with how you go with compiling all this with fastspin. I will have to have a look at it myself too.

So compiling and running that will load TAQOZ first, leaves a long for the mailbox and loads my binary just behind it, waiting to be called by TAQOZ.

if told with cmdline switch -H 0x10004 -E FastSpin creates a binary compiled for starting at HUB $10004 without all those $10004 empty bytes in front of the binary. That is what I do with my fastspin program.

And the above trick glues them together like a linker...

what should
word COGINIT do in your source at line 3866, I think fastspin complains because it is a assembler instruction I guess. Pnut does not compile es.spin2 either.

So I will go back to ' NEW_WORD 1+ ' OLD_WORD W! this did work.

I also might need to change my MBX to something else since you already have MBX in use.

on the other hand I may adapt to your different mailbox approach, being able to switch between blocking and nonblocking output may come in handy.

Good to know that flashpart is not a HUB address. If I would like to use VGA also, where would the free HUB memory begin? And where without?

I can chose my start address and don't want to clobber TAQOZ nor being destroyed by it.

Because currently I can't compile from source and have to use one of the existing "CHIP" binaries 190212-1700 (_boot_P2.bix) or -190711_0930 (es.bin)

Mike

I am just another Code Monkey.
A determined coder can write COBOL programs in any language. -- Author unknown.
Press any key to continue, any other key to quit

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.

But is missing rxwr also in COG memory not on longword boundary, that is what Pnut complais about

Pnut complains too. You want to create HUB labels on word boundaries after org 0, that dies since both compiler assign HUB and COG labels inside of COG code and there word boundaries are a no go for labels in COG memory.

trying Pnut results in "COG label must be long aligned" at rxwr does not coplain about line 255
rxrd word 0
rxwr word 0
lastkey word 0
athen word 0

I've been using Dave Hein's p2asm and loadp2 which just work but I see now that PNut is not happy with the final spin2 file. It seems that some of the includes have LF line ending and other CRLF. So I have fixed them all up to CRLF so PNut doesn't go nuts. There's also the alignment thing it is complaining about with rxwr etc so I made these into an orgh and changed the res word.

There were a few other things such as "tjnz X,#@INITSTKS" that Pnut is complaining about so I am still checking.

Confidence: the feeling you have before you understand the implications.

So following @Peter Jakacki's advice I tried BU a couple of days ago. Now I have some TAQOZ in the MBR and have to remove the SD all the time, else it hangs on loading from fastspin.

The boot from MBR solution is pretty solid, it survives even formatting in Windows.

As for BACKUP, currently I need to HAVE a _boot_P2.BIX on SD to BACKUP into it. Is there a way to tell BACKUP to create and use some file I could specify, something like BACKUP "filename" instead of BAKUP BIX?

And I do not have a see, this needs some work.

fun,

Mike

I am just another Code Monkey.
A determined coder can write COBOL programs in any language. -- Author unknown.
Press any key to continue, any other key to quit

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.