Shop OBEX P1 Docs P2 Docs Learn Events
Understanding vocal tract frame handler code — Parallax Forums

Understanding vocal tract frame handler code

Eternal-studentEternal-student Posts: 7
edited 2011-02-05 05:32 in Propeller 1
Hi all,

I've been going through the vocaltract code and trying to understand the frame handler routine (included below). I'm a bit of a newbie with the propeller machine code but I'm starting to get most of it now.

I understand that the jmpret statements are used to split processing cycles between the vocal tract loop and the frame handler loop (as per the jmpret manual entry - I hope I'm right about this). However, I'm having difficulty understanding the reference to the cycles in the comments next to the instructions. Do they refer to the number of cycles that are used before the next vocal tract loop is executed? Why are there two values with or/ in between? And how are the number of cycles calculated? I thought each statement used 4 cycles for each statement?

If anyone can offer any guidance, I would appreciate it very much.

Thanks,

Stephen
:ret                    long    :wait                   'pointer to next frame handler routine
 
:wait                   jmpret  :ret,#loop              '(6 or 17.5 cycles)
                        mov     frame_ptr,par           'check for next frame
                        add     frame_ptr,#8*4          'point past miscellaneous data
                        add     frame_ptr,frame_index   'point to start of frame
                        rdlong  step_size,frame_ptr     'get stepsize
                        and     step_size,h00FFFFFF  wz 'isolate stepsize and check if not 0
        if_nz           jmp     #:next                  'if not 0, next frame ready
 
                        mov     :final1,:finali         'no frame ready, ready to finalize parameters
                        mov     frame_cnt,#13           'iterate aa..ff
:final                  jmpret  :ret,#loop              '(13.5 or 4 cycles)
:final1                 mov     par_curr,par_next       'current parameter = next parameter
                        add     :final1,d0s0            'update pointers
                        djnz    frame_cnt,#:final       'another parameter?
 
                        jmp     #:wait                  'check for next frame
 
:next                   add     step_size,#1            'next frame ready, insure accurate accumulation
                        mov     step_acc,step_size      'initialize step accumulator                    
 
                        movs    :set1,#par_next         'ready to get parameters and steps for aa..ff
                        movd    :set2,#par_curr   
                        movd    :set3,#par_next
                        movd    :set4,#par_step
                        add     frame_ptr,#3            'point to first parameter
                        mov     frame_cnt,#13           'iterate aa..ff
:set                    jmpret  :ret,#loop              '(19.5 or 46.5 cycles)
                        rdbyte  t1,frame_ptr            'get new parameter
                        shl     t1,#24                  'msb justify
:set1                   mov     t2,par_next             'get next parameter
:set2                   mov     par_curr,t2             'current parameter = next parameter
:set3                   mov     par_next,t1             'next parameter = new parameter
                        sub     t1,t2           wc      'get next-current delta with sign in c            
                        negc    t1,t1                   'make delta absolute (by c, not msb)
                        rcl     vscl,#1         wz, nr  'save sign into nz (vscl unaffected)
                        mov     t2,#8                   'multiply delta by step size
:mult                   shl     t1,#1           wc
        if_c            add     t1,step_size
                        djnz    t2,#:mult
:set4                   negnz    par_step,t1            'set signed step
                        add     :set1,#1                'update pointers for next parameter+step
                        add     :set2,d0
                        add     :set3,d0
                        add     :set4,d0
                        add     frame_ptr,#1
                        djnz    frame_cnt,#:set         'another parameter?
 
 
:stepframe              jmpret  :ret,#loop              '(47.5 or 8 cycles)
                        mov     :step1,:stepi           'ready to step parameters
                        mov     frame_cnt,#13           'iterate aa..ff
 
:step                   jmpret  :ret,#loop              '(3 or 4 cycles)
:step1                  add     par_curr,par_step       'step parameter
                        add     :step1,d0s0             'update pointers for next parameter+step
                        djnz    frame_cnt,#:step        'another parameter?
 
                        add     step_acc,step_size      'accumulate frame steps
                        test    step_acc,h01000000  wc  'check for frame steps done
        if_nc           jmp     #:stepframe             'another frame step?
 
                        sub     frame_ptr,#frame_bytes  'zero stepsize in frame to signal frame done
                        wrlong  vscl,frame_ptr
                        add     frame_index,#frame_bytes'point to next frame
                        and     frame_index,#frame_buffer_bytes - 1
 
                        jmp     #:wait                  'check for next frame
 
:finali                 mov     par_curr,par_next       'instruction used to finalize parameters                 
:stepi                  add     par_curr,par_step       'instruction used to step parameters               

Comments

  • Eternal-studentEternal-student Posts: 7
    edited 2010-12-19 08:29
    Do you think the cycles that are mentioned in the comments are referring to the number of multiple of 4-cycles that could take place? I don't really understand how they are calculated.
  • kwinnkwinn Posts: 8,697
    edited 2010-12-19 09:29
    The "jmpret" instruction itself takes 4 cycles so the other number looks like it may be the calculated average execution time of the routine. I could not find any PASM instruction that takes x.5 cycles, which reinforces my conclusion.
  • Eternal-studentEternal-student Posts: 7
    edited 2010-12-20 15:58
    I don't really understand one of the last statements though is the 3 or 4 cycles here.. that's only time to do 1 or less than 1 instruction? It doesn't sound right to me?
    :stepframe              jmpret  :ret,#loop              '(47.5 or 8 cycles)
                            mov     :step1,:stepi           'ready to step parameters
                            mov     frame_cnt,#13           'iterate aa..ff
    
    :step                   jmpret  :ret,#loop              '(3 or 4 cycles)
    :step1                  add     par_curr,par_step       'step parameter
                            add     :step1,d0s0             'update pointers for next parameter+step
                            djnz    frame_cnt,#:step        'another parameter?
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-20 16:53
    Dang it! Still can't delete a post.

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2010-12-20 20:20
    I think I may have been wandering down the garden path on this one. I thought it was refering to instruction cycles since most were 4 or greater (4 cycles for a jmpret). It may be the number of loops through a subroutine or something else entirely. Author, author....some help please.
  • Eternal-studentEternal-student Posts: 7
    edited 2010-12-21 13:34
    What did you post Phil? Did you delete the post in the end?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-12-21 17:33
    I misread the program fragment that you posted, thought I had the answer, posted it, then realized I was mistaken -- an Emily Litella (nevermind!) moment which, because of the no-delete policy, forever becomes part of forum history. :(

    -Phil
  • Eternal-studentEternal-student Posts: 7
    edited 2010-12-22 21:03
    Thanks for looking at it though :smile:
    Will it only be Chip who could answer the question definitively?
  • kuronekokuroneko Posts: 3,623
    edited 2010-12-23 02:48
    Will it only be Chip who could answer the question definitively?

    Probably. That said, don't get stuck on what might just be an ambiguous comment. Get creative with your own ideas.
  • Eternal-studentEternal-student Posts: 7
    edited 2010-12-23 14:04
    Yes, ok thanks. I'm still getting to grips with the code and I think the frame handler code is really useful. I would still be interested in knowing what the cycles refer to though. It's such a nice and carefully written piece of code I can't imagine the comments were written by mistake. Does Chip read the forums?
  • Eternal-studentEternal-student Posts: 7
    edited 2011-02-05 05:32
    If anyone reads this post in the future and knows the answer to it, please feel free to respond, even if the post very old and it is a long time since it was first posted. I guess I'm over fixating on this but I'd really like to know what the answer is about the commented cycles, if indeed there is one.

    Yours perseveringly,

    Stephen
Sign In or Register to comment.