Shop OBEX P1 Docs P2 Docs Learn Events
LMM P2 Debugger - Uses Serial Tx & Rx for debugging single cog programs - Page 9 — Parallax Forums

LMM P2 Debugger - Uses Serial Tx & Rx for debugging single cog programs

145679

Comments

  • SapiehaSapieha Posts: 2,964
    edited 2013-04-26 02:00
    Hi Cluso.

    Look on this.

    Copy and paste this:
    000- 00 00 BC 5C 00 00 BC 60 00 00 BC 64 00 00 BC 68   ...\...`...d...h
    010- 00 00 BC 6C 00 00 BC 70 00 00 BC 74 00 00 BC 78   ...l...p...t...x
    020- 00 00 BC 7C 00 00 BC 80 00 00 00 00 00 00 00 00   ...|............
    030- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
    040- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
    050- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
    060- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
    070- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
    080- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
    090- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7C 1C   ..............|.
    0A0- 00 00 00 00 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D   ....============
    0B0- 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D   ================
    0C0- 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D   ================
    .
    

    For me it give only first LINE correct in COG

    But input correct to HUB
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-26 07:37
    Hi Cluso.

    I found what is problem!

    With copy and paste --- Address are:
    0000- 20 20 20 20 20 20 20 20 20 20 20 20 53 68 6F 77
    0010- 20 48 65 6C 70 20 2D 20 74 68 69 73 20 74 65 78
    0020- 74 20 0D 0D 20 20 20 20 47 3C 63 72 3E 20 20 20
    0030- 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 74
    0040- 75 72 6E 20 74 6F 20 75 73 65 72 20 70 72 6F 67
    0050- 72 61 6D 20 0D 20 20 20 30 47 3C 63 72 3E 20 20
    0060- 20 20 20 20 20 20 20 20 20 20 20 20 20 20 47 6F
    0070- 74 6F 20 63 6F 67 20 61 64 64 72 65 73 73 20 24
    0080- 30 20 28 72 65 73 74 61 72 74 20 77 69 74 68 6F
    0090- 75 74 20 69 6E 69 74 69 61 6C 69 73 61 74 69 6F
    00A0- 6E 29 20 0D 20 78 78 78 47 3C 63 72 3E 20 20 20
    
    


    It needs be translated in any way to:
     addr-  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
      000- 0D 08 FC 0C 05 08 BC 80 00 08 BC FC 09 00 7C 1C
      004- D7 C0 9C 3A 80 C3 C9 01 00 A3 E1 11 4D 3C 2B 1A
      008- 31 32 0D 00 40 D0 FF A0 07 D2 BF A0 E0 CF FF 1F
      00C- 20 D2 FF A0 E2 CF FF 1F 50 D0 FF A0 07 D2 BF A0
      010- E0 CF FF 1F 0D D2 FF A0 E2 CF FF 1F 80 D0 FF A0
      014- D8 D7 BF A0 E0 CF FF 1F 37 D2 FF A0 E2 CF FF 1F
      018- 38 D2 FF A0 E2 CF FF 1F 39 D2 FF A0 E2 CF FF 1F
      01C- 0D D2 FF A0 E2 CF FF 1F 08 D2 BF A0 E2 CF FF 1F
      020- 20 D0 FF A0 0D D2 FF A0 E0 CF FF 1F 25 D2 FF A0
      024- E0 CF FF 1F 95 D2 FF A0 E0 CF FF 1F 0D D2 FF A0
    


    Tested by edit address --- And function correct:
    *000- 20 20 20 20 20 20 20 20 20 20 20 20 53 68 6F 77
    *004- 20 48 65 6C 70 20 2D 20 74 68 69 73 20 74 65 78
    *008- 74 20 0D 0D 20 20 20 20 47 3C 63 72 3E 20 20 20
    *00C- 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 74
    *010- 75 72 6E 20 74 6F 20 75 73 65 72 20 70 72 6F 67
    *014- 72 61 6D 20 0D 20 20 20 30 47 3C 63 72 3E 20 20
    *018- 20 20 20 20 20 20 20 20 20 20 20 20 20 20 47 6F
    *01C- 74 6F 20 63 6F 67 20 61 64 64 72 65 73 73 20 24
    *020- 30 20 28 72 65 73 74 61 72 74 20 77 69 74 68 6F
    *024- 75 74 20 69 6E 69 74 69 61 6C 69 73 61 74 69 6F
    *0l
    
     addr-  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
      000- 20 20 20 20 20 20 20 20 20 20 20 20 53 68 6F 77  '            Show'
      004- 20 48 65 6C 70 20 2D 20 74 68 69 73 20 74 65 78  ' Help - this tex'
      008- 74 20 0D 0D 20 20 20 20 47 3C 63 72 3E 20 20 20  't ..    G<cr>   '
      00C- 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 74  '             Ret'
      010- 75 72 6E 20 74 6F 20 75 73 65 72 20 70 72 6F 67  'urn to user prog'
      014- 72 61 6D 20 0D 20 20 20 30 47 3C 63 72 3E 20 20  'ram .   0G<cr>  '
      018- 20 20 20 20 20 20 20 20 20 20 20 20 20 20 47 6F  '              Go'
      01C- 74 6F 20 63 6F 67 20 61 64 64 72 65 73 73 20 24  'to cog address $'
      020- 30 20 28 72 65 73 74 61 72 74 20 77 69 74 68 6F  '0 (restart witho'
      024- 75 74 20 69 6E 69 74 69 61 6C 69 73 61 74 69 6F  'ut initialisatio'
    *
    .
    
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-26 11:06
    Hi Cluso..

    Attachment:
    1. With Cleaned portion of USER area code.
    2. Cleaned descriptions to my part of variables above LMM.
    3. Cleaned HELP text
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-26 22:06
    Here is v0.70. Changes are...
    '' RR20130427 0.70 structure change using stack; remove ASCII mode
    ''   replaced _HubHex & _HubNibble with new _HubHex routine
    ''   modify calling structure for LmmTx,LmmRx,LmmFun
    ''   remove use of lmm_v
    ''   Note: lmm_w is only for internal use and is destroyed on returns from calls
    ''   Tidy _HubTx, _HubTxString, _HubHex, _HubRx, _HubRxString
    

    Sapieha: I have not yet looked at or included your changes. I will do that for the next release.
    Parameters are now being saved for the man routines. Now I can look into LIST etc to ensure the values are saved between calls.

    It is now possible to do
    mov lmm_x, #"*"
    call LmmTx
    call LmmTx
    to display **.

    LSD_070.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 01:02
    Hi Cluso.

    Nice - Thanks

    Cluso99 wrote: »
    Here is v0.70. Changes are...
    '' RR20130427 0.70 structure change using stack; remove ASCII mode
    ''   replaced _HubHex & _HubNibble with new _HubHex routine
    ''   modify calling structure for LmmTx,LmmRx,LmmFun
    ''   remove use of lmm_v
    ''   Note: lmm_w is only for internal use and is destroyed on returns from calls
    ''   Tidy _HubTx, _HubTxString, _HubHex, _HubRx, _HubRxString
    

    Sapieha: I have not yet looked at or included your changes. I will do that for the next release.
    Parameters are now being saved for the man routines. Now I can look into LIST etc to ensure the values are saved between calls.

    It is now possible to do
    mov lmm_x, #"*"
    call LmmTx
    call LmmTx
    to display **.

    LSD_070.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 01:17
    Hi Cluso.

    Need this Variables be in same order and correct in this place:
    ''-------[ LMM workareas ]------------------------------
    '  Internal workareas used by the LMM routines. 
    lmm_pc          long    @_LmmCogReturn + 4              ' LMM PC (program counter)
    lmm_sp          long    @_hub_stack                     ' LMM SP (stack pointer)
    lmm_w           long    0                               ' workarea (never saved - only immediate use between calls)
    lmm_mode        long    0                               ' saved in LIST
    lmm_p2        long    0                ' typically a 2nd address
    lmm_bittime     long    _bitrate                        ' bit rate for baud
    '------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------------------------
    I_Start        long    $0                '' IStart
    I_countL    long    5                '' (@I_End - @I_Start+1)    ''IEnd - IStart
    Vars_PL        long    LMM_Pos                        '' ??? Have same position as     BYTE    "INDA"
    Vars_C        long    8                            '  ??? hub address to LIST (executes as "NOP")
            BYTE    "INDA"                ''\ Important that 2 BYTE fill position's
            BYTE    "INDB"                ''/   are in this place
    
    

    I need move 2 of them above MY ones As I need to BASIC 2 extra variables that can give me place holders without disturbing LMM:

    So it look's that way:
    ''-----------------------------------------------------------------------------------------------
    I_Start        long    $0                '' IStart
    I_countL    long    5                '' (@I_End - @I_Start+1)    ''IEnd - IStart
    Vars_PL        long    LMM_Pos                        '' ??? Have same position as     BYTE    "INDA"
    Vars_C        long    8                            '  ??? hub address to LIST (executes as "NOP")
    '
    lmm_bittime     long    _bitrate                        ' bit rate for baud
    lmm_mode        long    0                               ' saved in LIST
    '
            BYTE    "INDA"                ''\ Important that 2 BYTE fill position's
            BYTE    "INDB"                ''/   are in this place
    
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 02:27
    Hi Cluso.

    I moved that variables in my Candidate version --- All function correctly.

    If it is - OK -- Can we have them in this place?
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-27 02:28
    Sapieha, no problems, I'll change them around.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 02:30
    Hi Cluso.

    Thanks
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 02:32
    Hi Cluso.

    In my Candidate version I added one more command.

    "V"
    Display USER Custom variables.
    But have some work to before I can post code.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-27 04:19
    Here is V0.71

    Sapieha: I have tried to tidy up the user program demo area and the variables/strings. I hope that this is what you are after as well.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 04:58
    Hi Cluso.

    Thanks.

    I on my end made much changes to to user area --- So I will look in Yours code and merge with my changes.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 07:33
    Hi Cluso.

    Attached "LSD_071_c1.spin" with Yours and my cleaning in code.

    Most recent "LSD_071_c3.spin"

    Added "V" command ---- Have some more work on it ---- BUT not in HUB_LMM space only user.
    So it is clean to You to work on other things

    Look in "?" command by type it -- to see changes.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 14:27
    Hi.

    Previous post updated with Latest Candidate file.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-27 15:34
    Sapieha,
    Thanks. I just downloaded 071_c3. Presume this is the latest and contains all mods done in the previous c1 & c2.
    It is great that you work on it overnight (for me).
    I will look shortly and comment.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-27 15:42
    Hi Cluso.

    Yes -- It is most recent.

    BUT I work more on "V" command.

    It will be ",[cc]V[n]" --->
    [n]-- = 0 else omited for System info.
    [n]--- = 1 User defined Strings and Variables space
    [.cc] = Count of Variables to display

    Cluso99 wrote: »
    Sapieha,
    Thanks. I just downloaded 071_c3. Presume this is the latest and contains all mods done in the previous c1 & c2.
    It is great that you work on it overnight (for me).
    I will look shortly and comment.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-27 17:22
    Sapieha:
    Here is v0.72 with your changes. Please note I have not taken all the mods...
    I use the double braces and double quotes for comments as I am trying to use the recommended documentation method for Phil's (PhiPi) autodocumenter.
    I use single quoted names like 'addr' to mean that it is an address, where "addr" is a literal meaning the characters addr.
    You will see in the Help strings, I have made any double <cr> put the second on it's own line so it is easier to see what it looks like.
    I have the version string at the end. What this does, is that when a help message is displayed, the version follows it automatically (because of missing 0 terminator on the help string. This way I can also output the version on it's own.
    I have a separate string to mention "type '?<cr>' for help". I intend to have the debugger output this when it does not understand, rather than just "?" as I do now. Otherwise it's not necessary to display this message - it is pretty common for "?" to mean help.

    Thanks again for your input :)

    LSD_072.spin
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-27 19:54
    Here is v0.73 with further changes (code tidy).
    Sapieha: can you please see the notes in the history re _ParseHex and _ParseDec. Thanks.

    LSD_073.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-28 01:25
    Hi Cluso.

    Look nice -- Thanks

    I used that "addr" so NotePad have not problems with colour - so no problem for me

    And all other that quotation changes was for that --- So no problem for me

    That will be nice.

    Cluso99 wrote: »
    Sapieha:
    Here is v0.72 with your changes. Please note I have not taken all the mods...
    I use the double braces and double quotes for comments as I am trying to use the recommended documentation method for Phil's (PhiPi) autodocumenter.
    I use single quoted names like 'addr' to mean that it is an address, where "addr" is a literal meaning the characters addr.
    You will see in the Help strings, I have made any double <cr> put the second on it's own line so it is easier to see what it looks like.
    I have the version string at the end. What this does, is that when a help message is displayed, the version follows it automatically (because of missing 0 terminator on the help string. This way I can also output the version on it's own.
    I have a separate string to mention "type '?<cr>' for help". I intend to have the debugger output this when it does not understand, rather than just "?" as I do now. Otherwise it's not necessary to display this message - it is pretty common for "?" to mean help.

    Thanks again for your input :)

    LSD_072.spin
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-28 01:58
    Hi Cluso.

    Even without them --- XXXXX.YYYYYLx --- don't function as desired

    With that command --- [,cc] need be calculated from xxxxxxx.yyyyyyy else use straight definite addresses
    ':nothex
    ':notdec
    '*** Sorry Sapieha - I think this is causing me problems - need to discuss
    '***        ----------------------------------------        
    '*** Cluso without this Single "L" command dont show in repetitive use what is desired.
    '*** NO problem for me -- I can always enable it
    '
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-28 02:24
    Sapieha, pleased it works for you. I am doing a ParseCommand (taking it out of the current Debug section) being a parse command line routine. Then I should be able to keep the previously entered values as the defaults. So, a single <cr> should repeat the last command, with the address(es) incremented each time. Once this is complete, it will simplify the command decoding.

    Therefore, if I enter...
    xxxxx,5L<cr>
    then 5 lines will be displayed from location xxxxx, and the xxxxx address will be incremented.
    Then if I enter
    <cr>
    this should be equivalent to
    xxxxx,5L<cr>
    where xxxxx has been incremented by the amount displayed by the 5 lines.
    And
    ,3L<cr>
    should display 3 lines from xxxxx incremented by the last display.
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-28 02:38
    Hi Cuso.

    LSD_073_c.spin to look on V command.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-04-28 12:36
    How does this look for a revised help (with future commands included)...
    ------------- Help -----------------------------------------------------------
     [[#]xxxxxxxx][.yyyyy][,[h]ccccc]z[m]<cr>          <-- command format         
      -----1-----  ---2--  -----3--- 4 5 --6-          <-- parameter no.          
    ...where...                                                                   
     1:  # xx xx xx xx  = is an immediate byte/word/long value (spaces optional)  
         # xxxxxxxx     = is stored as a long (spaces mean little endian order)   
           xxxxx        = is from address (hex) where <$200 is in cog, else hub   
     2:  . yyyyy        = is to   address (hex) where <$200 is in cog, else hub   
     3:  , h ccccc      = is (hex) count (or length)                              
         ,   ccccc      = is (decimal) count (or length)                          
     4:  z              = is (single char) command ( ? - G L M P Q V )            
     5:  m              = is (single char) command modifier (command specific)    
     6:  <cr>           = is <enter> key                                          
    . 
     ?  HELP:   Show this text                                                    
     -  STORE:  to {addr1} the following {byte(s)}|{word(s)}|{long(s)}            
     G  GOTO:   Goto cog {addr1} (if {addr1} omitted, return to user program)     
                COGINIT  {addr1}:{par2} for COGID {m5}                            
                   {m5} omitted = this cog; 0..7 = cog 0..7; * = next avail cog   
     L  LIST:   from cog/hub {addr1} to {addr2}                                   
                from cog/hub {addr1} for {count3}|{length3}                       
                L = L0 = bytes + ascii; L1 = bytes; L2 = code; L3 = long          
     M  MOVE:   from cog/hub {addr1} to cog/hub {addr2} for {Count3}|{length3}    
                FILL {immediate1} to cog/hub {addr2} for {count3}|{length3}       
     P  PORT:   Show port status                                                  
     Q  QUIT:   Quit user program and run the Rom Monitor                         
     V  VARS:   Show the variables (special for Sapieha)                          
    ------------------------------------------------------------------------------
    
    
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-28 12:51
    Hi Cluso.

    Will look on it.

    I'm next clear to post "LSD_073_c3.spin"
    Much changes.
    So You need look at entire code
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-28 13:12
    Hi Cluso.

    Candidate "LSD_073_c3.spin" in attachment.
    Much changes.
    So You need look at entire code.

    Added Yours Help strings that You can enable so see how it looks
  • SapiehaSapieha Posts: 2,964
    edited 2013-04-28 16:34
    Hi Cluso.

    Added one more mode to V command.

    Attached most recent candidate revision


    Ps.

    Now V command mostly complete ---- One thing You can help me is that mode.--->

    1000,4v To change Initiall address and counter
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-09 21:59
    Here is the latest v0.77

    I have almost rewritten the LIST command and the ParseCommand sections. There a still a number of gremlims and MOVE & STORE do NOT work at all.
    However, the DEBUG mode works for LIST, and a few others. For example, try the following...
    *0,4L<cr>
    (lists=displays 4 lines of cog from $000 in monitor format) then..
    <cr>
    just continues the display of cog memory.
    1000,4L3<cr>
    (lists=displays 4 lines of hub memory from 1000 in quad long format), and...
    <cr>
    just continues.
    ?<cr>
    displays a list of commands
    

    BTW I had a quick try at preparing it for the P1 and so far so good.

    LSD_077.spin
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-10 01:31
    Move now working... v0.78
    LSD_078.spin
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-11 03:18
    V0.80 attached.
    Debug Input (Store) now works to input from the command line (can be pasted from pnut ctl-L listing or from rom monitor output or from List output)
    Extra V commands thanks to Sapieha.

    The debug prompt is "*" and these are the input/store examples...
    *0-12345678 90abcdef<cr>
    will store $1234567 at cog $000 and $90abcdef at cog $001
    *10- 11 22 33 44 55667788<cr>
    will store $44332211 at cog $010 and $55667788 at cog $011
    *1000- 11 22 33 44 5566 778899AA<cr>
    will store bytes $11 $22 $33 $44 at hub $1000 and words $5566 $7788 at hub $1004 and long $99AABBCC at hub $1008
    

    LSD_080.spin
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-12 17:14
    Here is v0.82 of my P2 Debugger.

    Now included is a simple disassembler which works for both cog and hub memory. Below is a sample output. The preceding character to the opcode is an indication that other instructions share this opcode and will be used by me to extend the disassembly later.
    === Cluso's P2 Debugger v0.82 ===
    *0,20l2
     addr- instr  zcr i cccc dst src - conds         opcode  operands   flags
     ---------------------------------------------------------------------------
      000- 000011 001 1 1111 004 00D -              *******  $004,#$00D
      001- 100000 001 0 1111 004 005 -               ADD     $004, $005
      002- 111111 001 0 1111 004 000 -              *WAITxxx $004, $000
      003- 000111 000 1 1111 000 009 -              #JMPRET  $000,#$009 NR
      004- 001111 110 0 0100 165 147 - if_NZ_AND_C   REV     $165, $147 WZ,WC,NR
      005- 000000 011 1 0010 0E1 180 - if_Z_AND_NC  *rwBYTE  $0E1,#$180 WC
      006- 000100 011 1 1000 0D1 100 - if_Z_AND_C   *SETACCx $0D1,#$100 WC
      007- 000000 010 0 1000 1A2 167 - if_Z_AND_C   *rwBYTE  $1A2, $167 WC,NR
      008- 000000 000 0 1100 199 031 - if_C         *rwBYTE  $199, $031 NR
      009- 101000 001 1 1111 1E8 080 -               MOV     $1E8,#$080
      00A- 101000 001 0 1111 1E9 1D1 -               MOV     $1E9, $1D1
      00B- 000111 111 1 1111 1E7 1E0 -              #JMPRET  $1E7,#$1E0 WZ,WC
      00C- 101000 001 1 1111 1EC 037 -               MOV     $1EC,#$037
      00D- 000111 111 1 1111 1E7 1E2 -              #JMPRET  $1E7,#$1E2 WZ,WC
      00E- 101000 001 1 1111 1EC 038 -               MOV     $1EC,#$038
      00F- 000111 111 1 1111 1E7 1E2 -              #JMPRET  $1E7,#$1E2 WZ,WC
      010- 000111 111 1 1111 1E7 1E2 -              #JMPRET  $1E7,#$1E2 WZ,WC
      011- 101000 001 1 1111 1EC 020 -               MOV     $1EC,#$020
      012- 000111 111 1 1111 1E7 1E2 -              #JMPRET  $1E7,#$1E2 WZ,WC
      013- 101000 001 0 1111 1EC 008 -               MOV     $1EC, $008
    *
    

    LSD_082.spin
Sign In or Register to comment.