P2 Tricks and Traps

We had a similar document for P1, so thought it might be about time to start a P2 version.
My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
Website: www.clusos.com
Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)

Comments

  • 4 Comments sorted by Date Added Votes
  • Cluso99Cluso99 Posts: 13,132
    edited December 2017 Vote Up0Vote Down
    WAITCTn

    In P1 we did this...
                    mov     count,            #(96*2)
                    mov     delay,            cnt           
                    add     delay,            delay5us      
    :loop           waitcnt delay,            delay5us      
                    'do something
                    djnz    count,            #:loop        
    

    In P2 we do this...
                    mov     count,            #(96*2)
                    getct   delay                             
    .loop           addct1  delay,            delay5us                
                    waitct1                                          
                    'do something
                    djnz    count,            #.loop       
    

    And here is the trap: Our P1 code incorrectly converted to P2
                    mov     count,            #(96*2)
                    getct   delay                             
                    addct1  delay,            delay5us                
    .loop           waitct1                                          
                    'do something
                    djnz    count,            #.loop       
    
    Note we need to include the addct1 instruction into the loop because waitctn no longer adds to the count
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Prop2 has WAITX instruction that is easier to use and does what's needed for the common use of just inserting a delay.

    If precise period or phase aligning is needed then ADDCT1 becomes effective.

    The Prisoner's Dilemma, in english - "Selfishness beats altruism within groups. Altruistic groups beat selfish groups." - Quoted part from 2007, D.S Wilson/E.O Wilson.
  • Cluso99 wrote: »
    Note we need to include the addct1 instruction into the loop because waitctn no longer adds to the count
    I think the clue there for P1 users would be that WAITCTx is standalone and doesn't support D and S fields.


    Melbourne, Australia
  • RDWORD, RDLONG, WRWORD, WRLONG Hub non-aligned

    The P1 ignores lowest hub address bit(s) for non-aligned hub reads and writes.
    The P2 correctly accesses non-aligned word and long reads and writes.

    In the P1, there were tricks associated with the lower hub address bit(s) being ignored. This code will fail on P2.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
Sign In or Register to comment.