Shop OBEX P1 Docs P2 Docs Learn Events
PASM: Not getting the value for PAR I expect. [Using Gear to evaluate] — Parallax Forums

PASM: Not getting the value for PAR I expect. [Using Gear to evaluate]

WurlitzerWurlitzer Posts: 237
edited 2012-11-15 11:32 in Propeller 1
I have taken a SPIN program from a much larger running program to play with some different functionality and most of it seems to work except the value passed to PAR for the address of MasterArray seems to point to an unexpected address per GEAR.

Cog 0 is running the SPIN and Cog 1 is running the PASM and the PASM is running based on the proper toggling of 2 pins.

MasterArray is the first variable declared in the SPIN program

VAR
 long  MasterArray[268]
  long  ThisCog
  long  cog
  long  lc
  long  indx
  long  LastValue
  long  testread

PUB Main | Temp
getcaldata  
      
 ThisCog := cogid '    
       cog := cognew(@entry,@MasterArray) + 1


"entry" is right after the DAT org 0 for

In Gear, looking into the Cog running PASM I see that PAR = 1F0h ( PAR is used on 4 lines of code and I verified the address of these 4 lines from the address shown in the Prop Development Tool after I compile) so I am confident that Cog1's PAR value is 1F0h.

Based upon this information I am expecting @MasterArray to start at 1F0h but it is not there. Using a dummy fill of $AABBCCDD I found MasterArray at address $814

I tried changing the cog start instruction to use @MasterArray[0] with the exact same results.

Here is the PASM code segment using PAR.
 }                      mov     CurrentModeADDR,par       
DmyLabel        mov     HUB_PedalPointer, par
                        add     HUB_PedalPointer, #4 'offset for pedal current write address
                        
                        mov     CirQueStartADDR, par
                        add     CirQueStartAddr, #12 'offset for begining of Pedal Queue
                        
                        mov     PedalCalStartAddr, par
                        add     PedalCalStartAddr, #332 'begin address of HUB data for pedal calibration

The Prop Tool shows the cog address of DmyLabel to be $0AD and that address and the one before it, and the other 2 after it all show PAR to be $1F0

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-15 11:06
    The symbol PAR's value is $1F0 (the register PAR is located at $1F0 in the cog's memory). The content of the PAR memory location (register) is the address @MasterArray.

    The MOV instructions you've mentioned all copy the contents of PAR to the destination register (like CurrentModeADDR, CirQueStartADDR, PedalCalStartAddr, etc.) which is what should happen. You then add an offset to each of these and presumably use them in a RDLONG instruction to get the actual data values from hub memory.
  • WurlitzerWurlitzer Posts: 237
    edited 2012-11-15 11:22
    Thanks Mike for the quick reply. Arrgg I missed that Par value pointed to the value.

    That gets me a little closer.

    In Cog1 @ $1f0 I see it contains $7C8 which is closer to $814 (where MasterArray seems to start) but no cigar. If I look at the data being obtained by the various destination registers, it does seem they are getting their data based upon the $7C8 address so somehow I seem to be passing something other than MasterArray's starting address but the trees are getting in the way of the forest.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-11-15 11:30
    There's no way that you're passing something other than MasterArray's starting address. That's what you've written and that's what COGNEW does. You've only shown fragments of your program. Maybe there's something else going on in the parts you haven't shown that's throwing you off.
  • WurlitzerWurlitzer Posts: 237
    edited 2012-11-15 11:32
    Mike, found it! I thought I had remarked out any other reference to MasterArray for this testing but there was a sub-routine overwriting the first 20 or so addresses so It looked like MasterArray stated at a different location.

    Thanks again Mike.
Sign In or Register to comment.