Shop OBEX P1 Docs P2 Docs Learn Events
ViewPort Assembly Code Debug — Parallax Forums

ViewPort Assembly Code Debug

SpillerSpiller Posts: 52
edited 2010-02-23 09:20 in Propeller 1
Hi,

I know that ViewPort is basically developed for Spin Code debugging. I like·debug my assembly program with it, by using vp.share(@a,@b)
command·of the ViewPort. But it is·seems to me that I can not share variables which are decraled in my assemby program. Can I·share it somehow?

Regard

Spiller

Comments

  • HannoHanno Posts: 1,130
    edited 2010-02-15 08:45
    Hi Spiller,
    ViewPort uses the "vp.share" command to share data stored in global hub ram. This allows users to monitor and change variable values used by their spin and pasm programs. In PASM, you can use "rdlong/wrlong" to read and write data from global hub ram. You can not share the 512 registers that are private to each cog. Here some simple pseudo code- just typed it in, should work:
    CON
     _clkmode     = xtal1 + pll16x
     _xinfreq        = 5_000_000         'use standard 5MHz clock
    OBJ
     vp :"conduit"
    VAR
    long a,b 'data to share with ViewPort
    PUB main
     vp.share(@a,@b) 'share hub memory from a..b
     cognew(@pasm,@a) 'start a cog running PASM, that reads/writes starting at address of variable a
    DAT
     pasm            'PASM routine to copy data from one long in hub ram to another
       rdlong     aa,par 'read the value of where "par" is pointing
       mov        bptr,par 'calculate a pointer to b
       add        bptr,#1  'pointer to b is 1 long after pointer to a
       wrlong     aa,bptr 'write value of aa to bptr
       jmp        #pasm  'jump back to pasm routine
     aa   res 1
     bptr res 1
    
    


    Hanno

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Co-author of the official Propeller Guide- available at Amazon
    Developer of ViewPort, the premier visual debugger for the Propeller (read the review here, thread here),
    12Blocks, the block-based programming environment (thread here)
    and PropScope, the multi-function USB oscilloscope/function generator/logic analyzer
  • kuronekokuroneko Posts: 3,623
    edited 2010-02-15 09:09
    Minor correction, hub addresses have byte granularity so in order to skip a long you'll need to add 4 instead of 1.

    add bptr,#4  'pointer to b is 1 long after pointer to a
    
  • SpillerSpiller Posts: 52
    edited 2010-02-18 07:02
    Hi Hanno,

    Thanks for this code. Fist of all I'm new in Propleller, but I have practice with several controllers.
    I didn't understand this code. If I want to share the hub memory from a..b with the conduit object, I sould built in vp.share(@a,@b)
    start a new cog @pasm, @a. If know ir right the @a will be start addres for new cog stack. Until this step I understand the code, but didn't understand why the whole code in pasm. Reading the par (stack pointer) to aa, then overwriting it with bptr value which is calculated from par. What is this good for?
    By the way I think it would be best to share my code with you. (The code compiled with PropBASIC)
    Here is:
    '' *** COMPILED WITH PropBasic VERSION 00.00.79 Feb 7, 2010 ***
    '' ======================================================================
    ''
    '' File......
    '' Purpose...
    '' Author....
    '' E-mail....
    '' Started...
    '' Updated...
    ''
    '' ======================================================================


    ''
    '' Program Description
    ''
    '' RFID Reader with IR disance sensor and IRDA

    ''
    '' Device Settings
    ''



    CON 'DEVICE P8X32A, XTAL1, PLL16X
    _ClkMode = XTAL1 + PLL16X

    _XInFreq = 5000000 'FREQ 80_000_000



    ''
    '' Constants
    ''


    ''
    '' I/O Pins
    ''
    ' IR_DIST_SEN PIN 16 INPUT 'IR_DIST_SEN PIN 16 INPUT


    ''
    '' Shared (hub) Variables (Byte, Word, Long)
    ''

    ' VAR LONG IR_RANGE 'IR_RANGE HUB LONG


    ''
    '' Shared (hub) Data (DATA, WDATA, LDATA, FILE)
    ''


    ''
    '' TASK Definitions
    ''


    ''
    '' Cog Variables (Long only)
    ''

    ' DIST_VAL VAR LONG = 0 'DIST_VAL VAR LONG = 0


    ''
    '' SUB/FUNC Definitions
    ''


    '' ======================================================================


    PUB __Program ' PROGRAM Start
    CogInit(0, @__Init,@__DATASTART)

    DAT
    org 0
    __Init
    mov dira,__InitDirA
    mov outa,__InitOutA
    jmp #Start

    '' ======================================================================
    Start 'Start:

    ' ' Main code goes here
    __DO_1 'DO

    mov __temp1,#1 ' RCTIME 16,1,DIST_VAL ' Read IR Range Finder
    shl __temp1,#16
    andn dira,__temp1
    mov DIST_VAL,#0
    mov __temp2,cnt
    adds __temp2,#80
    __L0001
    adds DIST_VAL,#1
    waitcnt __temp2,#80
    and __temp1,ina NR, WZ
    IF_NZ jmp #__L0001

    mov __temp1,#IR_RANGE_ofs ' WRLONG IR_RANGE,DIST_VAL ' Store Range In Hub Variable
    add __temp1,par
    wrlong DIST_VAL,__temp1

    mov __temp1,cnt ' PAUSE 100
    adds __temp1,_1mSec
    mov __temp2,#100
    __L0002
    waitcnt __temp1,_1mSec
    djnz __temp2,#__L0002

    jmp #__DO_1 'LOOP
    __LOOP_1


    mov __temp1,#0 'END
    waitpne __temp1,__temp1



    ''
    '' SUB/FUNC Code
    ''

    ''
    '' TASK Code
    ''

    '**********************************************************************
    __InitDirA LONG %00000000_00000000_00000000_00000000
    __InitOutA LONG %00000000_00000000_00000000_00000000
    IR_DIST_SEN LONG 1 << 16
    _1mSec LONG 80000
    _FREQ LONG 80000000

    DIST_VAL LONG 0

    __remainder
    __temp1 RES 1
    __temp2 RES 1
    __temp3 RES 1
    __temp4 RES 1
    __temp5 RES 1
    __param1 RES 1
    __param2 RES 1
    __param3 RES 1
    __param4 RES 1
    __paramcnt RES 1

    FIT 492

    CON
    LSBFIRST = 0
    MSBFIRST = 1
    MSBPRE = 0
    LSBPRE = 1
    MSBPOST = 2
    LSBPOST = 3
    IR_RANGE_ofs = 0

    DAT
    __DATASTART
    IR_RANGE LONG 0

    I like to share the IR_RANGE variable with conduit. As you see the code write to this location already.

    Best Regards

    Spiller
  • HannoHanno Posts: 1,130
    edited 2010-02-18 20:56
    My first PropBasic program [noparse]:)[/noparse]
    It looked like you were already wrlong to a spin variable. So I just added an object reference to ViewPort's conduit and called vp.share with your variable. Let me know if it work...
    Hanno


    '' *** COMPILED WITH PropBasic VERSION 00.00.79 Feb 7, 2010 ***
    '' ======================================================================
    ''
    '' File......
    '' Purpose...
    '' Author....
    '' E-mail....
    '' Started...
    '' Updated...
    ''
    '' ======================================================================
    
    
    '' ----------------------------------------------------------------------
    '' Program Description
    '' ----------------------------------------------------------------------
    '' RFID Reader with IR disance sensor and IRDA
    
    '' ----------------------------------------------------------------------
    '' Device Settings
    '' ----------------------------------------------------------------------
    
    
    
    CON 'DEVICE P8X32A, XTAL1, PLL16X
    _ClkMode = XTAL1 + PLL16X
    
    _XInFreq = 5000000 'FREQ 80_000_000
    
    
    
    '' ----------------------------------------------------------------------
    '' Constants
    '' ----------------------------------------------------------------------
    
    
    '' ----------------------------------------------------------------------
    '' I/O Pins
    '' ----------------------------------------------------------------------
    ' IR_DIST_SEN PIN 16 INPUT 'IR_DIST_SEN PIN 16 INPUT
    
    
    '' ----------------------------------------------------------------------
    '' Shared (hub) Variables (Byte, Word, Long)
    '' ----------------------------------------------------------------------
    
    ' VAR LONG IR_RANGE 'IR_RANGE HUB LONG
    
    
    '' ----------------------------------------------------------------------
    '' Shared (hub) Data (DATA, WDATA, LDATA, FILE)
    '' ----------------------------------------------------------------------
    
    
    '' ----------------------------------------------------------------------
    '' TASK Definitions
    '' ----------------------------------------------------------------------
    
    
    '' ----------------------------------------------------------------------
    '' Cog Variables (Long only)
    '' ----------------------------------------------------------------------
    
    ' DIST_VAL VAR LONG = 0 'DIST_VAL VAR LONG = 0
    
    
    '' ----------------------------------------------------------------------
    '' SUB/FUNC Definitions
    '' ----------------------------------------------------------------------
    
    
    '' ======================================================================
    
    obj vp:"conduit" 'ViewPort object to share memory with the pc
    PUB __Program ' PROGRAM Start 
    vp.share(@dist_val,@dist_val) 'share memory from dist_val..dist_val
    CogInit(0, @__Init,@__DATASTART)
    
    DAT
    org 0
    __Init
    mov dira,__InitDirA
    mov outa,__InitOutA
    jmp #Start
    
    '' ======================================================================
    Start 'Start:
    
    ' ' Main code goes here
    __DO_1 'DO
    
    mov __temp1,#1 ' RCTIME 16,1,DIST_VAL ' Read IR Range Finder
    shl __temp1,#16
    andn dira,__temp1
    mov DIST_VAL,#0
    mov __temp2,cnt
    adds __temp2,#80
    __L0001
    adds DIST_VAL,#1
    waitcnt __temp2,#80
    and __temp1,ina NR, WZ
    IF_NZ jmp #__L0001
    
    mov __temp1,#IR_RANGE_ofs ' WRLONG IR_RANGE,DIST_VAL ' Store Range In Hub Variable
    add __temp1,par
    wrlong DIST_VAL,__temp1
    
    mov __temp1,cnt ' PAUSE 100
    adds __temp1,_1mSec
    mov __temp2,#100
    __L0002
    waitcnt __temp1,_1mSec
    djnz __temp2,#__L0002
    
    jmp #__DO_1 'LOOP
    __LOOP_1
    
    
    mov __temp1,#0 'END
    waitpne __temp1,__temp1
    
    
    
    '' ----------------------------------------------------------------------
    '' SUB/FUNC Code
    '' ----------------------------------------------------------------------
    
    '' ----------------------------------------------------------------------
    '' TASK Code
    '' ----------------------------------------------------------------------
    
    '**********************************************************************
    __InitDirA LONG %00000000_00000000_00000000_00000000
    __InitOutA LONG %00000000_00000000_00000000_00000000
    IR_DIST_SEN LONG 1 << 16
    _1mSec LONG 80000
    _FREQ LONG 80000000
    
    DIST_VAL LONG 0
    rangeptr long 0 'will get filled in by spin code, before this pasm cog starts
    __remainder
    __temp1 RES 1
    __temp2 RES 1
    __temp3 RES 1
    __temp4 RES 1
    __temp5 RES 1
    __param1 RES 1
    __param2 RES 1
    __param3 RES 1
    __param4 RES 1
    __paramcnt RES 1
    
    FIT 492
    
    CON
    LSBFIRST = 0
    MSBFIRST = 1
    MSBPRE = 0
    LSBPRE = 1
    MSBPOST = 2
    LSBPOST = 3
    IR_RANGE_ofs = 0
    
    DAT
    __DATASTART
    IR_RANGE LONG 0
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Co-author of the official Propeller Guide- available at Amazon
    Developer of ViewPort, the premier visual debugger for the Propeller (read the review here, thread here),
    12Blocks, the block-based programming environment (thread here)
    and PropScope, the multi-function USB oscilloscope/function generator/logic analyzer
  • SpillerSpiller Posts: 52
    edited 2010-02-23 09:20
    Hi Hanno,

    Thanks for the code, but it s still not working. I gave up this code and written it in Spin. This is working.

    Best Regards

    Spiller
Sign In or Register to comment.