Shop Learn
TAQOZ Reloaded v2.8 - Writing Inline Assembly code notes — Parallax Forums

TAQOZ Reloaded v2.8 - Writing Inline Assembly code notes

bob_g4bbybob_g4bby Posts: 243
edited 2021-09-13 18:29 in ForthSpace

I've just started learning how to write new TAQOZ words in assembly language instead of forth, because I have a ham radio project that will demand high speed in the signal path. Here's my notes at version 9. I'll up-issue as I learn more.

Comments

  • Just super Bob. I had a quick look and will have a better read of that later.

  • I took the time to read the document end to end and I can only repeat what Peter has already said. You must've prepared many, many quality docs in your career, obviously.

  • bob_g4bbybob_g4bby Posts: 243
    edited 2021-05-06 10:01

    Thanks both, I expect there's a lot that can be added, there's plenty more features in TIA. I fixed some mistakes so worth downloading before rereading.

    Very satisfying when a word assembles with no stack mismatch and then after a few more tweeks actually works. The reset button gets a lot of use as does the dump
    and stack display commands! I like the conventional syntax in TIA, so many forth assemblers use RPN which makes adopting code from other assemblers a real chore. Plus I found writing assembler in tiny chunks and testing the word out interactively in TAQOZ is fun, you get constantly rewarded with another working word you can trust. Deserves wider recognition as a tool for seriously high speed applications with fewer bugs.

  • @bob_g4bby said:
    ... and stack display commands! ....

    .... writing assembler in tiny chunks and testing the word out interactively in TAQOZ is fun, you get constantly rewarded with another working word you can trust. 
    

    Deserves wider recognition as a tool for seriously high speed applications with fewer bugs.

    You nailed it !
    That's why Peter is trying to promote the TAQOZ in so many ways but, unfortunately, the majority of folks are stuck with the conventional tools and methods (for various reasons which we know all too well). The hardest part is to start with something new but once you see how productive one can be with TAQOZ it's even harder to stop using it, especially that it includes interactive assembler too. And many more :).

  • @bob_g4bby said:
    I've just started learning how to write new TAQOZ words in assembly language instead of forth, because I have a ham radio project that will demand high speed in the signal path. Here's my notes at version 7. I'll up-issue as I learn more.

    Hi Bob, this document is really very helpful! Great!

    Perhaps you might add some lines about LOADMOD and COGMOD?
    LOADMOD ( startadr number_of_longs -- ) will copy PASM code from hub into cog ram starting at fixed address.
    COGMOD will execute any code, that has been loaded before.

    code test ( value n -- value+3*n 0 )
        add b,#3
        sub a,#1 wz
        if_nz jmp #\@COGMOD '\ loop from start
        ret
    end
    
    AT test 2+ 4 LOADMOD \ loads the asm instructions of test into cog ram
    
    10 5 COGMOD . . \ executes any loaded code
    

    The result is: 0 25
    It took me some time to find #\@COGMOD as a way to implement the loop....

  • bob_g4bbybob_g4bby Posts: 243
    edited 2021-09-12 18:24

    @Christof Eb.

    That looks useful, I will add that to both the inline code and glossary documents, this was new information to me,

    regards, Bob

  • Christof Eb.Christof Eb. Posts: 517
    edited 2021-09-15 19:15

    Hi can someone help, please? -solved
    I have now struggled for half a day to assemble some code with Taqoz 2.8 inline assembler and forward label reference for half a day, and cannot get it running.
    The version with the { } comment works. It fills a buffer with Sync3 adc data. The code within the comment shall bring a positive edge trigger.
    But if I delete the { }, jmp #la2 should skip the code until la2. Instead it does not work any more.
    So how can I do a forward jump?
    (setse4+waitse4 did not work too.)
    Many thanks!

    code fs3a ( d: stat c:aBuf b:len a:level -- d c b a )
        '\ setse4 a '\ from tos
        mov r1,#0 '\ clear diff1
        mov r2,#0 '\ clear diff2
    .l0 testp #adcpin wc  '\ waitse4 '\ wait for sample period done
        if_nc jmp #l0
        rdpin r0,#adcpin '\ get SINC3 accumulator
        sub r0,r1 '\ compute sample
        add r1,r0 '\ update diff1 value
        sub r0,r2 '\ compute sample
        add r2,r0 '\ update diff2 value
        shr r0,#9 '\ #7 justify 14-bit sample
        zerox r0,#17 '\ #13 trim 14-bit sample, now use sample somehow
        {
        jmp #la2
        cmp d,#2 wz     '\ stat 0: wait f minus, 1: w plus, 2: sample
        if_z jmp #la2     '\ la2
    
        cmp d,#1 wz     '\ stat 0: wait f minus, 1: w plus, 2: sample
        if_z jmp #la3     '\ la3
    
        cmp r0,a wc     '\ status is 0 - wait for minus
        if_c mov d,#1   '\ new status 1
        jmp #l0
    
    la3 cmp r0,a wc      '\ status is 1 - wait for plus
        if_nc mov d,#2   '\ new status 2   
        jmp #l0
        }
    la2 wrlong r0,c     '\ sampling write to buffer
        add c,#4        '\ next address in buffer
        djnz b,#l0  '\ loop for next period
        ret 
    end
    
    : fillSync3Adc ( -- 0 1 2 3 ) \ with trigger 18 bit 512 clocks
        setSync3
        2 \ trigger status 0 on stack: d
        aBuf \ Buffer address on stack: c
        aBufLen \ on stack: b
        adcReso 2/ \ trigger level on stack: a
        fs3a
    ;
    

    **Solved: I finally found the remark in PASM.fth, that forward references do only work for djnz!
    **

  • @bob_g4bby
    1. I think it should be helpful, if you could add some lines into your description about labels. While jumps backward do make no problems, forward jumps are only supported for djnz. jmp is not supprted. It took me several hours to find this "feature" because sometimes the forward jump seemed to work.

    At the moment the best workaround seems to be to use the skip instruction. It needs one bit set for every instruction, that needs to be skipped.

    cmp d,#2 wz    
    if_z skip #%11111111  '\ skips next 8 instructions   
    
    1. If you know the rules, which lead to or avoid "stack mismatch", please add them too. At the moment, I believe, that lines, which contain only whitespaces within PASM code, make problems.
  • I saw your article and thought the same thing - I will add the information on jumps.

  • Hi Bob,
    although I tried, I could not get
    ....
    ASM:
    ....
    FORTH:
    ....
    work. This switch back to Forth seems not to work?
    Perhaps you could check this and put it into your paper?

  • Hi Bob,
    in your passage "Taqoz temporary registers", it would be good to clarify, that some of these register names refer to the same cell.
    xx, yy=r0, zz=r1, r2, r3, r4, acc=ac
    I had some strange things going on, when I used both r1 and zz, thinking they would be independent...

Sign In or Register to comment.