Shop OBEX P1 Docs P2 Docs Learn Events
TAQOZ for implementing a parallel bus - Page 2 — Parallax Forums

TAQOZ for implementing a parallel bus

2

Comments

  • Hi everybody,

    after a 5 month I am going on with my project. The core seems to work fine, now I want to realize some text based user interface for a test program.
    Does anybody know some Forth words / helpers for a simple text based menu system, just for an ANSI terminal?
    Its not so complicated I guess, but boring... I guess I have written my first user interface for the TRS-80 in Basic (shame on me..)
    Many Forth code was written before Google came up, so common code snippets in FORTH are hard to find.
    Any hint welcome

    Markus

  • So an answer on my own question, but with a strange effect:
    That works:

    : pcmenu ( -- )
    BEGIN
    crlf ." 0: Q-DOS"
    crlf ." 1: DOS 6.2"
    crlf ." 2: OS/2"
    crlf ." 3: Windows-ME"
    crlf ." 4: SuSe-Linux" crlf
    crlf ." : Select menu press * to exit"
    WKEY
    SWITCH
    '0' CASE crlf ." TRS-80 first choice" THEN
    '1' CASE crlf ." Commodore PC-20" THEN
    '2' CASE crlf ." i486" THEN
    '3' CASE crlf ." oh yeah" THEN
    '4' CASE crlf ." Pentium" crlf THEN
    '' CASE ." exit" BREAK
    '*' =
    UNTIL
    ;
    
    

    that works too:

    --- das geht
    : test
    BEGIN
    crlf ." test"
    WKEY
    SWITCH
    '0' CASE crlf ." null" THEN
    '2' CASE crlf ." two" THEN
    '3' CASE crlf ." three" THEN
    '4' CASE crlf ." four" THEN
    '' CASE ." aus" BREAK
    '' =
    UNTIL
    ;
    
    

    But if I make ****the text line in the menu longer**** the system ts just finishing the loop or Taqoz hangs:

    : pcmenu ( -- )
    BEGIN
    crlf ." 0: Q-DOS"
    crlf ." 1: DOS 6.2"
    crlf ." 2: OS/2"
    crlf ." 3: Windows-ME"
    crlf ." 4: SuSe-Linux" crlf
    crlf ." : Select menu press * to exit"
    WKEY
    SWITCH
    '0' CASE crlf ." TRS-80 first choice of my lifexxxxxxxxxxxxxxxx" THEN
    '1' CASE crlf ." Commodore PC-20" THEN
    '2' CASE crlf ." i486" THEN
    '3' CASE crlf ." oh yeah" THEN
    '4' CASE crlf ." Pentium" crlf THEN
    '' CASE ." exit" BREAK
    '*' =
    UNTIL
    ;
    
    

    Maybe its totally wrong the CASE ... THEN is nowhere explained in the documentation, bit I found it in the source.

    Markus

  • bob_g4bbybob_g4bby Posts: 411
    edited 2023-06-12 18:56

    Hi Markus,

    See page 3 of the glossary for an example of using SWITCH CASE BREAK - the use of THEN is not right. It's a good idea to download the pdf file that is the glossary. In most pdf readers, a table of contents can be opened up to select the category of word you're interested in. Even more specifically use ctrl-F and enter the word you're looking for.

  • Hi Bob,

    many thanks, you are right of course.
    I was a litte bit confused about the code snippet I found in BREAKOUT.FTH, the last line has a THEN, but that something totally different.

    --- game control keys ---
    pub GAMEKEY ( ch -- )
    ?DUP 0EXIT ( ignore if null )
    a>A SWITCH
    'Z' CASE <PADDLE BREAK --- paddle left
    'X' CASE PADDLE> BREAK --- paddle right
    '+' CASE FASTER BREAK --- faster ball
    '=' CASE 5 speed W! BREAK --- reset ball speed
    '-' CASE SLOWER BREAK
    '_' CASE 100 speed W! BREAK --- real slow
    ' ' CASE MUTE WKEY $1B = IF CON CONSOLE THEN  BREAK
    'B' CASE NEWBALL BREAK
    'W' CASE WALLS BREAK
    '<' CASE HIDEBALL ballw 1- 2 MAX ballwh BREAK --- smaller
    '>' CASE HIDEBALL ballw 1+ ballwh BREAK --- bigger ball
    'N'  CASE NEWGAME BREAK
    ^[  CASE " CONSOLE" ALERT ROUT PIN MUTE BREAK
    CASE@ '0' '9' WITHIN IF CASE@ boflgs C! THEN
    ;
    
    

    Below my example code for a menu that finally works now for me.


  • Code was missing, sorry.
    I can't format it as code, some letter may confuse the markdown formatter.

    Markus

    pri menuresponse ( keystroke -- result )
    SWITCH
    '0' CASE crlf ." TRS-80 first choice" 3 s BREAK \ show message for 3 s
    '1' CASE crlf ." Commodore PC-20" 3 s BREAK
    '2' CASE crlf ." i486" 3 s BREAK
    '3' CASE crlf ." oh yeah" 3 s BREAK
    '4' CASE crlf ." Pentium" crlf 3 s BREAK
    '*' CASE ." exit" CASE@ BREAK
    ;
    pub pcmenu ( -- )
    BEGIN
    %ERSCN
    %HOME
    crlf ." [0]: Q-DOS"
    crlf ." [1]: DOS 6.2"
    crlf ." [2]: OS/2"
    crlf ." [3]: Windows-ME"
    crlf ." [4]: SuSe-Linux" crlf
    crlf ." []: Select menu, press * to exit"
    WKEY
    menuresponse
    '' =
    UNTIL
    %ERSCN
    %HOME
    ;

  • Nice one Markus, good to hear it's working. I've yet to find a good use for a P2, but when I do, it'll probably be in Taqoz. I bought a couple of KISS boards for that time.

  • Hi friends,

    I am now some steps further with Taqoz Forth, but maybe I was a little bit too careless during my experiments.
    TAQOZ reloaded seems to changed the serial settings even after power off etc.
    So I get only (?) for each byte on my GTKTerm screen, same in CuteCom. I tried several other baud rates, but maybe the bit length or whatever has changed.
    Whats the right way to come back to the 921600 bits/s 8 N 1 ?
    I am using the P2 Edge board Rev. D. with a 32 GByte Sandisk SD-card.
    Should I re-format the SD card?

    Regards
    Markus

  • Hi Markus,
    if you receive a ? repeatedly then I doubt, that this problem is related to baud rate. But yes, if the serial communication is blocked, restarting from a known working starting point will be needed.
    I sometimes had the situation, that Taqoz does not recognise words any more and print question marks. The dictionary structure seems to be damaged then.
    Christof

  • re-formatting the SD card helps a lot..

    Markus

  • btw...
    using Transcend SD cards 64 GByte type 420T doesn't work. TAQOZ was able to read the card but not able to write on it.
    Sandisk 32 GByte Max Endurance works fine. Just setting the MBR flag and copying the BIX file. No re-formatting or similar.

    Has anybody a syntax highlighting configuration for TAQOZ? I was using the FORTH extension of Geany, but this is only a poor support.
    Visual Code, Pluma or Sublime or something else for Linux ?

    Markus

  • Another Problem in my project....

    IF I call in the interpreter:

    FLOAD TEST.FTH

    the source file TEST.FTH is loaded and executed, so far so good.
    If I use the same command in a word, its suddenly executed during compile time of the word, but that's not my intention.
    I want run this FLOAD TEST.FTH when the wrapping word is called for example as a choice of a menu.
    I found this BATCHFILE tool, but also works only interactive.

    Each suggestion welcome...

    Markus

  • Hi Christof,

    thanks, the atest word works fine, but I am still in troubles.

    If I have the atest anywhere between TAQOZ and END the file is loaded during compile time.
    Is there any construct like a forward definition (like in PASCAL) to say yes here is a word but the content will be defined later and when this word will be called do the command stored anywhere ?

    Markus

  • Sorry aload of course...

  • @MGreim said:
    Hi Christof,

    thanks, the atest word works fine, but I am still in troubles.

    If I have the atest anywhere between TAQOZ and END the file is loaded during compile time.
    Is there any construct like a forward definition (like in PASCAL) to say yes here is a word but the content will be defined later and when this word will be called do the command stored anywhere ?

    Markus

    Hi,
    Yes, like any word aload will be executed directly, if it is not between : and ; .

    I don't understand, what you are trying to do with this forward reference. This is only needed for recursion, I think? There are possibilities to patch new routines into old words. I am not at my PC these days, so looking this up is difficult.

  • Found the patching, as I have used it. Post 25 in https://forums.parallax.com/discussion/175264/does-taqoz-2-8-work-with-32gb-card#latest
    .
    I assume, that there are smarter ways...

  • Hi Christof,

    now it works...aload works fine BUT
    I was using it in a menu with WKEY.
    aload / FLOADS is working somehow asynchronously ...
    So the aload seems to be ready and my menu is jumping in the WKEY waiting for a key, but after some short time TAQOZ is writing the file input to the console.
    I have to say my loaded program has several kBytes.
    Now WKEY is catching the input from file and you will get silly effects...
    I tried NULL and CON but it doesn't seems to help.
    I have to change my program design, I fear

    Markus

  • Hi friends
    ... my next problem..

    I have written a small menu system as user interface for my program.
    It worked well, but if the number of lines in the menu exceed about 5 lines (about 150 characters)
    TAQOZ crashes.
    See the example below.
    It works, but if you remove the curly brackets in MENUTEST ( i.e. increasing the the number of lines) it crashes.

    So what is the max. number of characters in a word?
    And how can I check, ho many space is left?

    As always, any hint welcome!

    Markus


    ...

  • something went wrong with the code example..
    40 bytes UEBERSCHRIFT

    ```
    pub LINIE ( -- )
    crlf ." -------------------------------"
    ;

    pub CLEARIT ( -- )
    %ERSCN
    %HOME
    ;

    pub FOOTER
    CLEARIT
    27 =
    ;

    pub HEADER ( str -- )
    CLEARIT
    CRLF UEBERSCHRIFT PRINT$
    LINIE
    ;

    pub LASTLINE
    LINIE
    crlf ." [ESC]: Exit "
    WKEY
    ;

    pub MENUTESTRESP ( keystroke -- result )
    SWITCH
    '0' CASE crlf ." Inputfilter frequency 3 .. 420 Hz : " GET$ $># DROP DUP CRLF . . 2 s BREAK
    '1' CASE crlf ." Input amplification 1 .. 128 : " GET$ $># DROP DUP CRLF . . 2 s BREAK
    '2' CASE crlf ." Make Autozero " 2 s BREAK
    '3' CASE crlf ." Input Overload (Nmm) : " GET$ $># DROP . 1 s BREAK
    '4' CASE crlf ." Temp. Measurement ON / Off (0/1) : " GET$ $># DROP . 1 s BREAK
    '5' CASE crlf ." Show strain gage data : " 2 s BREAK
    27 CASE ." exit" CASE@ BREAK
    ;

    pub MENUTEST ( -- )
    BEGIN
    " HEAD-MENU 2023/08/26" UEBERSCHRIFT $! HEADER
    crlf ." [0]: Steps fast : "
    crlf ." [1]: Steps slow : "
    crlf ." [2]: Up and something more"
    {
    crlf ." [3]: Down not so nice"
    crlf ." [4]: Up as a rocket "
    crlf ." [5]: Down much better "
    crlf ." [6]: Turn left but not so fast"
    crlf ." [7]: Turn right slowly"
    crlf ." [8]: Stop "
    }
    LASTLINE
    MENUTESTRESP
    FOOTER
    UNTIL
    ;

    ```

  • Christof Eb.Christof Eb. Posts: 1,195
    edited 2023-09-03 05:53

    Yes, one of the tricks, that make Taqoz so fast, is to code jump distances dictly into the wordcodes. So the code for UNTIL contains the conditional jmp instruction together with the relative distance of max +/- 127 ( I think) words.
    SEE will give some info.

  • Hello Christof,

    many thanks for your hint again!
    After playing around with SEE MENUTEST I found out that 256 bytes (127 words) work indeed and 260 bytes (130 words) didn't.
    Reading before of your comment in "TAQOZ Reloaded V2.8 GLOSSARY" would have been helpful ;-) :

    N.B. All loops in TAQOZ are made with relative jumps. If code within a loop is too large then your new word may not work properly and Taqoz may even
    crash. If you suspect this, use SEE to decompile the new word and check the jump distances. All jumps have to be less than 127 words in scope. Thanks for
    this tip, Christof Eb.

    Maybe for beginners like me this should be printed bolt and Italic.

    Many thanks for your sudden reply, even on weekend, again!
    Markus

  • Hi again

    this time two general question about RAM usage.
    (.. my program crew and crew and I am running out of memory I fear..)

    If I load some code to Taqoz I got the following response to .USAGE

    MEMORY MAP
      CODE:     0D6FE  55,038 bytes
      WORDS:    1D52C  10,859 bytes
      DATA:     01B3D  419 bytes
      ROOM:            65,070 bytes ok
    
    

    If I load some more code, and code amount is > 65 kByte I get no ROOM message anymore.

    MEMORY MAP
      CODE:     15FAC  90,028 bytes
      WORDS:    1D51A  10,877 bytes
      DATA:     01B3D  419 bytes ok
    

    If you check the .USAGE command in EXTEND.FTH it is clear why (see the IF part) .
    But does this mean that the max. code size is max. $FFFF bytes?
    I thought the HUB RAM has 512 k?

    Or is there any table / document where I can see how the RAM is used by TAQOZ ?

    pub .USAGE^M
    <------>CRLF PRINT" MEMORY MAP"^M
    <------>CRLF+ PRINT" CODE:" <--><------>2 TABS HERE HERE .UBYTES^M
     <------>CRLF+ PRINT" WORDS:" <-><------>2 TABS @WORDS " END" SEARCH 6 +  @WORDS - .UBYTES^M
    <------>CRLF+ PRINT" DATA:" <--><------>2 TABS org@   org@ AT orglen 6 - CALL @ - .UBYTES^M
    <------>HERE 16>> 0=^M
     <------>IF^M
     <------>  CRLF+ PRINT" ROOM:" <><------>2 TABS @WORDS HERE - 7 SPACES .ASBYTES^M
     <------>THEN^M
     <------>;^M
    

    BTW is there any option to load Words from the Flash instead of SD card.
    I had several times problems with the SD cards. So I not really trust in it.

    As always any help or hint welcome!

    Markus

  • Hi,
    Do you really have that much code? Or do you have data there? If you use "longs" and its brothers, this is allocated in data section instead. For this data section can be moved with org .
    Taqoz can use more than 65k as code space. But I never needed it up to now.
    Christof

  • Now at my computer, to look up things. I do use:

    org@ := oriorg
    $6C000 := userdata
    userdata org
    

    For information about a memory map, you might have a look at .memo in AutoS.fth https://forums.parallax.com/discussion/174970/p2-taqoz-v2-8-lutlongs-value-type-variables-locals-now-faster#latest
    In my setup for example:

    TAQOZ# .memo ---
    MEMORY MAP
      CODE:         0B972  47,474 bytes
      WORDS:        1B5EF  18,856 bytes
      DATA:         6C5AA  1,450 bytes
      ROOM:                64,637 bytes
      Code:      $0000_0000 to $0000_B972
      Words:     $0001_B5EF to $0001_FF97
      Video:     $0003_3100 to $0006_BA00
    
      Original Data:   $0000_1800 to $0006_C5AA
      User Data:       $0006_C000 to $0006_C5AA
      RX Buffer Start: $0007_F500
      SD:              $0007_F800 to End
    Memory scan: (1k)
      $0000_0000 XXXXXX00XXXXXXXXXXXXXXXXXXXXXXXX
      $0000_8000 XXXXXXXXXXXXXX000000000000000000
      $0001_0000 00000000000000000000000000000000
      $0001_8000 00000000000000XXXXXXXXXXXXXXXXXX
      $0002_0000 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      $0002_8000 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      $0003_0000 XXXXXXXXXXXXXX000000000000000000
      $0003_8000 00000000000000000000000000000000
      $0004_0000 00000000000000000000000000000000
      $0004_8000 00000000000000000000000000000000
      $0005_0000 00000000000000000000000000000000
      $0005_8000 00000000000000000000000000000000
      $0006_0000 00000000000000000000000000000000
      $0006_8000 000000000000000XXXXXXXXXXXXXXXXX
      $0007_0000 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      $0007_8000 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ok
    TAQOZ#
    

    (I just see, that " Original Data: $0000_1800 to $0006_C5AA " is nonsense....)
    The video buffer takes a lot of space here.
    If you really have so much code, you will have to tweak the HERE pointer, I think, because the words will get into the way.
    Have fun!
    Christof

  • Hi Christof,

    many thanks again for your useful hints.

    I was playing a little bit around with HERE and @WORDS

    I was loading module by midule and checked the result of HERE:

    FILE + EXTEND   $0000_7A32   31282 
    MYMOD1   $0000_7F2C   32556
    MYMOD2   $0000_8972   35186
    MYMOD3   $0000_B290   45712
    MYMOD4   $0000_D760   55136
    MYMOD5  $0001_600A   90122
    MYMOD6  $0001_73BE   95166
    

    So code seems to go from 0...$01_FFFF ?

    In the same way the dictionary
    @WORDS
    goes down from $0001_FFFF to $0001_D___ and below
    So that MUST crash!

    But the SC card buffer starts at

    sdbuf $0007_F800 522240

    and also the rxbuf, I guess at
    rxbuf $0007_F500

    between $002_0000 and $0007_0000 there is a gap for the VGA buffer I guess, but this is not used by my software.
    So is there any chance to move the TAQOZ "border" from $0002_000 to, for example, $0004_000 ?

    Best Regards
    Markus

  • I just found the
    memmap.inc

    in the TAQOZ source directories.

    The comment ' dictionary can be moved elsewhere at runtime' means, you have to re-compile TAQOZ ?
    Or may I set it at startup?

    *** MEMORY MAP ***

    registers = $0200 Variables used by kernel + general-purpose
    _hubcode = $0400 start of TAQOZ code
    THREADS = $2000
    dictorg = $1F340-$C0 dictionary can be moved elsewhere at runtime
    cfgbackup = $1FF40
    config2 = $EB40 backup of page 0 config for $0C0 bytes
    extvars = $01800 EXTEND variables '
    datram = $7E000 start of data memory (PERHAPS)- user variables
    rxbuffers = $7F500 SERIAL RX buffer
    rxsize = $0300
    SDBUFS = $7F800 allocate 4 sector buffers
    bmporg = $33100 $32B00 start of bmp header, palette, and bitmap data


    its hard for a FORTH beginner...

  • Christof Eb.Christof Eb. Posts: 1,195
    edited 2023-09-21 15:53

    Hi @MGreim

    so I did some simple test, if I can manipulate HERE.

    TAQOZ# @here .s ---
     DATA STACK (2)
    1   $0000_02C4   708
    2   $0002_8745   165701 ok
    TAQOZ# @ . --- 56634  ok
    TAQOZ# here . --- 56634  ok
    TAQOZ# $40000 @here ! ---  ok
    TAQOZ# here . --- 262144  ok
    TAQOZ# : dummy 123 . ; ---  ok
    TAQOZ# see dummy
    
    1ABEA: dummy
    40000: 187B     123
    40002: 2B6F     . ;
          ( 4  bytes )
     ---  ok
    TAQOZ# dummy --- 123  ok
    TAQOZ#
    

    So you can direct the generation of code to a new location.
    Unfortunately "forget dummy" lead to a heavy crash. Forget seems not to be able to handle the page mechanism.

    What I still don't understand in post #53 is, that you have a rather small difference at words but such big difference of code. This seems to indicate, that you have large volume of data or other ???? in the code segment???
    My 3100 lines of code of the audio player still leave 52921 bytes of ROOM.

  • Hi Christof,

    many thanks for your suggestions again.

    What I still don't understand in post #53 is, that you have a rather small difference at words but such big difference of code. This seems to indicate, that you have large volume of data or other ???? in the code segment???
    My 3100 lines of code of the audio player still leave 52921 bytes of ROOM.

    You are right. I have 3 bigger modules with the structure as shown below:

    pub XTEST
    
    PININIT
    RES1
    300 ms
    SETIS1
    $0001 WADDRESSPM
    $001C WADDRESSPM
    $780013 WDATAPM
    $400031 WDATAPM
    $18DE9F WDATAPM
    $000000 WDATAPM
    $0024 WADDRESSPM
    $780013 WDATAPM
    $400011 WDATAPM
    $18DE9F WDATAPM
    $000000 WDATAPM
    
      and so on. 
    

    Of course its possible to store the data on disk and write it step by step to the device( that's what WDATPM is doing) . I fear that is what I will realize.

    On the other hand, Peter Jackacki has revised the document "Taqoz Dictionary Structure"on Google Docs this night (by chance or not...).
    He is describing the RELOCATING of code into other memory areas.
    Here a snippet of the document:

    NEED FOR MORE ROOM?
    Relocating the dictionary is useful for when the code memory grows to the point that there is little "room" between the end of code and the
    dictionary. Normally this doesn't happen since wordcode is so compact and name and data memory spaces are also separate, but at some point
    in a very large program with lots of modules (which hasn't happened yet) the code space may grow beyond the first 64kB and so any references
    to this code outside the first 64kB page will use an additional paging code while any code compiled there will still use compact 16-bit wordcode
    when pointing to the first 64kB.

    FORCING CODE to compile outside of first 64kB page.
    TAQOZ# $12000 uhere ! --- ok
    TAQOZ# free? ---
    MEMORY MAP
    CODE:
    12000 73,728 bytes
    NAMES:
    28000 21,251 bytes
    DATA:
    7F294 660 bytes ok
    TAQOZ# : HELLO CRLF ." Hello World!" ; --- ok
    TAQOZ# ' HELLO .L --- $0001_2005 ok
    TAQOZ# : DEMO 5 FOR HELLO NEXT ; --- ok

    Its similar to your suggestion, I think.
    In the header of the document he has a reference to TAQOZ kernel 2.14 which I can't find on SourceForge.
    So I have to test if it will also work with the 2.8 kernel, but I fear no...

    Best Regards
    Markus

  • Hi everybody...

    I played arround with memory borders, but finally everything crashed. I guess its not working with TAQOZ 2.8 properly.
    So two steps for, one step back :(
    I am now following Christofs recommendation, loading my single commands line by line from a text file.

    PININIT
    RES1
    300 ms
    SETIS1
    $0001 WADDRESSPM
    $001C WADDRESSPM
    $780013 WDATAPM
    $400031 WDATAPM
       and so on 
    
    

    For reading and executing the words, I am using a snippet from the AUTOEXEC example fount in the forum.

    " MANYLINE.FTH" FOPEN$ IF @FILE FLOADS THEN
    

    works excellent w/o mixing up the memory. It lasts 1..3 s depending on the size of the file. That's ok.
    BUT if I include the line above in a compiled word like

    pub MYTESTX
      " MANYLINE.FTH" FOPEN$ IF @FILE FLOADS THEN \ the line loading many small words from disk and executes it. 
      DOTHIS
      DOSOMETHING
      ANDMORE
      ;
    
    

    But this word is hanging....

    As far as I understood, TAQOZ should switch on the Interpreter for the first line, wait until its ready and the go on with the other lines following up.
    I can switch to the interpreter during compile time with [ ] but can I switch in any way from the compiler to the interpreter ?
    Or is this not possible?

    Regards

    Markus

  • Hi,
    as far as I understand, @bob_g4bby has done something like this in https://forums.parallax.com/discussion/174593/taqoz-reloaded-v2-8-running-commands-from-sd-card#latest
    Cheers Christof

Sign In or Register to comment.