Shop OBEX P1 Docs P2 Docs Learn Events
Cluso's LMM Serial Debugger (hubexec serial driver for your code with char, string, hex, etc output) — Parallax Forums

Cluso's LMM Serial Debugger (hubexec serial driver for your code with char, string, hex, etc output)

Attached is my LSD (Cluso's LMM Serial Debugger).

It can be included in your code so that you can output to the serial port (P62 & P63) using smart pins, by using simple calls in your program. It is a re-hash of my earlier LSD for the old P2 (2013) pre P2Hot.

Currently I am using the internal fifo/stack for calls. I later plan to save the stack, but this is not implemented yet.

Currently COG RAM $1E0..$1EF is required for LSD parameters.

Examples of the calls are included.

The serial driver remains separate from the main debugger so that alternative I/O drivers will be able to be substituted later.

Comments

  • Cluso99Cluso99 Posts: 18,069
    <reserved for more info>
  • cgraceycgracey Posts: 14,152
    Interesting, Cluso. I will try this out tomorrow. I could use something like this.
  • Cluso99Cluso99 Posts: 18,069
    cgracey wrote: »
    Interesting, Cluso. I will try this out tomorrow. I could use something like this.
    Excellent!
  • Cluso99Cluso99 Posts: 18,069
    These are the instructions for using my "LSD".
    Not everything is running yet, although it was on the original P2 so it's only a matter of conversion time :)
    === Cluso's P2v10a Debugger v.102? ===
     ------------ Help -----------------------------------------------------------
     [[#]xxxxxxxx][.yyyyy][,[$]ccccc]z[m]<cr>          <-- command format
      -----1-----  ---2--  -----3--- 4 5 --6-          <-- parameter no.
    ...where...
     1:  # xx xx xx xx  = an immediate byte/word/long value (spaces optional)
         # xxxxxxxx     = stored as a long (spaces mean little endian order)
           xxxxx        = from address (hex) where <$200 is in cog, else hub
     2:  . yyyyy        = to   address (hex) where <$200 is in cog, else hub
     3:  , $ ccccc      = (hex)     count/length
         ,   ccccc      = (decimal) count/length
     4:  z              = (single char) command ( ? - G L M P Q V )
     5:  m              = (single char) command modifier (command specific)
     6:  <cr>           = <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  VIEW:   View the variables (special for Sapieha)
    ------------------------------------------------------------------------------
    


    <teaser>
    Here is a link to what I had running on the original P2 (that I am now converting)...
    http://forums.parallax.com/discussion/146688/lmm-p2-debugger-uses-serial-tx-rx-for-debugging-single-cog-programs

    and a few snippets of that output...

    Here is a listing from cog ram (hub ram can also be done)
    *0.10l
    
     addr-  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
      000- 02 00 04 E0 1C 00 7C 1C 00 00 00 00 00 00 7C 1C  '......|.......|.'
      004- A0 20 FC 0C A0 20 E8 0C A0 40 F0 0C 00 80 BC 1C  '. ... ...@......'
      008- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  '................'
      00C- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  '................'
    

    Here is the disassembler output from the old Rom Monitor that Chip did
    === Cluso's P2 Debugger v0.85 ===
    *70C.8FFL2
     addr- instr  zcr i cccc dst src - conds         opcode  operands   flags
     ---------------------------------------------------------------------------
    0070C- 000000 000 0 0000 000 000 -               nop
    00710- 000011 011 1 0000 01D 040 - if           *repd??? $01D,#$040 wc
    00714- 111000 000 0 0001 000 1D8 - if_nz_and_nc #subr    $000, $1D8 nr
    00718- 101000 001 1 0100 1F6 000 - if_nz_and_c   mov     $1F6,#$000
    0071C- 000011 001 1 1111 1D8 012 -               getptra $1D8,#$012
    00720- 000011 001 1 1111 1D9 012 -               getptra $1D9,#$012
    00724- 001010 001 1 1111 1D9 009 -               shr     $1D9,#$009
    00728- 000011 000 1 1111 1D9 0DB -               setp    $1D9,#$0DB nr
    0072C- 000011 001 1 1111 1DA 013 -               getptrb $1DA,#$013
    00730- 100001 001 1 1111 1DA 1B4 -               sub     $1DA,#$1B4
    00734- 000011 001 1 1111 1BC 092 -               jmptask $1BC,#$092
    00738- 000011 001 1 1111 011 0CB -               settask $011,#$0CB
    0073C- 111110 000 1 1111 1F5 00C -               tjz     $1F5,#$00C nr
    

  • Cluso99Cluso99 Posts: 18,069
    edited 2016-07-05 08:16
    V0.105

    _hubList working for _MON/_SMON/_LONG now working.

    COG, LUT & HUB (from $400+) can be listed.

    Here is a sample of the output...
    === Cluso's P2v10a Debugger v.105x ===
    OK
    31 32 33 34 34 33 32 31
    
     addr:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
      000: 10 00 90 FD 74 65 73 74 2B 2B 2B 2B 65 6E 64 3C  '....test++++end<'
      004: 32 EF 53 19 1A 08 60 FD C2 EB 0B FF 00 08 84 FA  '2.S...`.........'
    
     addr:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
      300: 2A 2A 2A 2A 74 65 73 74 21 21 21 21 65 6E 64 3C  '****test!!!!end<'
      304: 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D  '================'
    
     addr:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
    01000: 2A 2A 2A 2A 74 65 73 74 21 21 21 21 65 6E 64 3C  '****test!!!!end<'
    01010: 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D  '================'
    01020: 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D  '================'
    01030: D0 AD 03 F6 D0 AF 03 F6 FF A0 27 F5 D4 00 B0 FD  '..........'.....'
    

    I will be reducing the usage of cog memory later.
  • Cluso99Cluso99 Posts: 18,069
    v0.106 latest update...
    Much of the disassembler is now working. Here is a sample of the output..
     addr: cccc instr   cz i dst src - conds         opcode   operands      flags
     ----------------------------------------------------------------------------
    01010: 1111 0101010 00 1 001 055 -               OR       $001,#$055
    01014: 1111 1000001 01 0 001 002 -               *group2  $001, $002       WZ
    01018: 1111 1000110 11 0 001 002 -               *group2  $001, $002    WC,WZ
    0101C: 1111 1001001 01 0 001 002 -               *group2  $001, $002       WZ
    01020: 1111 1101011 11 0 001 001 -               COGID    $001          WC,WZ
    01024: 1111 1101011 10 0 000 024 -               POLLINT                WC
    01028: 1111 1101011 00 1 016 028 -               WAITX   #$016
    0102C: 1111 1101101 10 0 000 010 -               CALL    #$00010
    01030: 1111 1110111 10 0 000 00C -               LOC     PTRB,#$0000C
    01034: 1111 1110100 10 0 000 008 -               LOC     ADRA,#$00008
    01038: 1111 1111000 00 0 015 0CC -               AUGS    #$002ACC
    0103C: 1111 0101010 00 1 001 055 -               OR       $001,#$055
    01040: 1111 0110000 00 0 1D6 1D0 -               MOV      $1D6, $1D0
    01044: 1111 0110000 00 0 1D7 1D0 -               MOV      $1D7, $1D0
    01048: 1111 0101001 00 1 1D0 0FF -               AND      $1D0,#$0FF
    0104C: 1111 1101101 10 0 000 0D4 -               CALL    #$000D4
    01050: 1111 0110000 00 0 1D0 1D7 -               MOV      $1D0, $1D7
    01054: 1111 0000010 01 1 1D0 008 -               SHR      $1D0,#$008       WZ
    01058: 0101 1101100 11 1 1FF 1E8 - if_nz         JMP     #$FFFE8
    0105C: 1111 0110000 00 0 1D0 1D6 -               MOV      $1D0, $1D6
    01060: 1111 1101011 11 0 000 031 -               RET      $000          WC,WZ
    01064: 1111 0110000 00 0 1D8 1D0 -               MOV      $1D8, $1D0
    01068: 1111 0110000 00 0 1D9 1D4 -               MOV      $1D9, $1D4
    0106C: 1111 1010001 01 1 1D1 010 -               *group2  $1D1,#$010       WZ
    01070: 0101 1001010 11 1 1D0 01B - if_nz         *group2  $1D0,#$01B    WC,WZ
    01074: 1111 0110000 00 0 1D4 1D1 -               MOV      $1D4, $1D1
    01078: 1111 0101001 01 1 1D4 007 -               AND      $1D4,#$007       WZ
    0107C: 1010 0110000 00 1 1D4 008 - if_z          MOV      $1D4,#$008
    01080: 1111 0110000 00 1 1D5 008 -               MOV      $1D5,#$008
    01084: 1111 0001100 01 0 1D5 1D4 -               SUB      $1D5, $1D4       WZ
    01088: 0101 0000011 00 1 1D5 002 - if_nz         SHL      $1D5,#$002
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2016-07-10 10:58
    Latest version v0.107

    Most instructions disassembled (except ALTI..SCL). Please report any errors.

    Nexton the list is to work as a monitor (ie read operator input to display hub/cog/lut)

    Here is a sample output... (note there is currently a debug char being displayed before the operands)
    === Cluso's P2v10a Debugger v.107x ===
    OK
    31 32 33 34 34 33 32 31
    
     addr:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
      000: 10 00 90 FD 74 65 73 74 2B 2B 2B 2B 65 6E 64 3C  '....test++++end<'
      004: F2 BE 56 19 1A 08 60 FD C2 EB 0B FF 00 08 84 FA  '..V...`.........'
    
     addr:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
     -----------------------------------------------------
      300: 2A 2A 2A 2A 74 65 73 74 21 21 21 21 65 6E 64 3C  '****test!!!!end<'
      304: 02 02 40 F5 08 02 54 F0 55 02 1C F6 33 02 6C F5  '..@...T.U...3.l.'
    
     addr: cccc instr   cz i dst src - conds         opcode   operands      flags
     ----------------------------------------------------------------------------
    01010: 1111 0101010 00 0 001 002 -               OR      < $001, $002
    01014: 1111 0000010 10 1 001 008 -               SHR     < $001,#$008    WC
    01018: 1111 0110000 11 1 001 055 -               MOV     < $001,#$055    WC,WZ
    0101C: 1111 0101011 01 1 001 033 -               XOR     < $001,#$033       WZ
    01020: 1010 1000001 01 0 001 002 - if_z          SETNIB  ? $001, $002,#5
    01024: 0101 1000110 10 0 001 002 - if_nz         SETBYTE ; $001, $002,#2
    01028: 0011 1001001 01 0 001 002 - if_nc         SETWORD 7 $001, $002,#1
    0102C: 1100 1001001 00 1 001 002 - if_c          SETWORD 7 $001,#$002,#0
    01030: 1111 1001101 00 1 001 008 -               REV     0 $001,#$008
    01034: 1111 1010100 10 0 001 002 -               ADDCT3  0 $001, $002
    01038: 1111 1011011 10 0 001 002 -               BLNPIX  0 $001, $002
    0103C: 0010 1010011 11 1 001 002 - if_z_and_nc   TESTB   < $001,#$002    WC,WZ
    01040: 1000 1010101 00 1 001 00F - if_z_and_c    CALLD   < $001,#$00F
    01044: 0001 1010111 00 0 001 002 - if_nz_and_nc  RDLUT   < $001, $002
    01048: 0100 1011010 00 0 001 002 - if_nz_and_c   RDLONG  < $001, $002
    0104C: 1011 1100011 01 1 100 100 - if_z_or_nc    WRLONG  2#$100,#$100
    01050: 1110 1100111 10 0 001 002 - if_z_or_c     COGINIT * $001          WC
    01054: 0111 1100111 00 0 001 002 - if_nz_or_nc   COGINIT * $001
    01058: 1101 1101010 10 0 001 002 - if_nz_or_c    QVECTOR 2 $001, $002
    0105C: 1111 1101011 11 0 001 001 -               COGID   - $001          WC,WZ
    01060: 1111 1101011 10 0 000 024 -               POLLINT L               WC
    01064: 1111 1101011 00 1 016 028 -               WAITX   -#$016
    01068: 1111 1101101 10 0 000 014 -               CALL    K#$00014
    0106C: 1111 1110010 10 0 000 010 -               CALLD   OPTRA,#$00010
    01070: 1111 1110111 10 0 000 00C -               LOC     OPTRB,#$0000C
    01074: 1111 1110100 00 0 008 080 -               LOC     OADRA,#\$01080
    01078: 1111 1111011 11 1 066 0CF -               AUGS    C#$F9999E00
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2016-07-10 21:59
    I have been thinking about the "monitor" commands that I previously implemented (see prior posts).

    For the LIST command, previously I used...
    [[#]xxxxxxxx][.yyyyy][,[$]ccccc]z[m]<cr>
    
     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
    
    Some examples of LIST use would be
    
    100,10L0<cr>       ' list bytes+ascii         from cog $100 for 10 (decimal count) lines
    100,10L1<cr>       ' list bytes               from cog $100 for 10 (decimal count) lines
    33333,10L2<cr>     ' list code (disassemble)  from hub $33333 for 10 (decimal count) lines
    33333,10L3<cr>     ' list long                from hub $33333 for 10 (decimal count) lines
    

    My thoughts are that it would be preferable to put the LIST command first, and use an alpha descriptor rather than numeric, like..
    z[m][[#]xxxxxxxx][.yyyyy][,[$]ccccc]z[m]<cr>
    
     L  LIST:   from cog/hub {addr1} to {addr2}
                from cog/hub {addr1} for {count3}|{length3}
                L = LL = bytes + ascii; LS = bytes; LC = code; LD = long
    
    Some the above examples of LIST use would now become
    
    LL100,10<cr>       ' List Long  (bytes+ascii) from cog $100 for 10 (decimal count) lines
    LS100,10<cr>       ' List Short (bytes)       from cog $100 for 10 (decimal count) lines
    LC33333,10<cr>     ' List Code (disassemble)  from hub $33333 for 10 (decimal count) lines
    LD33333,10<cr>     ' List Dump                from hub $33333 for 10 (decimal count) lines
    

    What are your thoughts/preferences?





  • cgraceycgracey Posts: 14,152
    I really like the syntax of the Apple II monitor, where a character following the address states the action. But, one could adapt to anything in 20 minutes.
  • Cluso99Cluso99 Posts: 18,069
    cgracey wrote: »
    I really like the syntax of the Apple II monitor, where a character following the address states the action. But, one could adapt to anything in 20 minutes.
    I had forgotten - too long ago. But I googled and yes, it's quite clean really.

    I will go with something similar and see how it goes. It is easy enough to change if necessary anyway.

  • Cluso99Cluso99 Posts: 18,069
    Here is v0.108

    All opcodes should be successfully decoded excluding the WR/WM/RDxxxx instructions using PTRA/PTRB. The PTRA/PTRB is not decoded, but shown as an immediate hex value.

    Bug reports welcome ;)
  • Cluso99Cluso99 Posts: 18,069
    V0.109 - all disassembling of instructions are done :)

    Please report any bugs ;)
     addr: cccc instr   cz i dst src - conds         opcode   operands        flags
     ------------------------------------------------------------------------------
    01010: 1111 0101010 00 0 001 002 -               OR       $001, $002
    01014: 1111 0000010 10 1 001 008 -               SHR      $001,#$008      WC
    01018: 1111 0110000 11 1 001 055 -               MOV      $001,#$055      WC,WZ
    0101C: 1111 0110111 01 1 001 033 -               NEGNZ    $001,#$033         WZ
    01020: 1111 0111000 00 1 001 155 -               ALTI     $001,#$155
    01024: 1111 0111000 11 0 001 155 -               ALTS     $001, $155
    01028: 1111 0111001 11 1 001 155 -               ROR      $001,#$155      WC,WZ
    0102C: 1111 0111011 01 1 001 155 -               ROR      $001,#$155         WZ
    01030: 1111 0111101 00 0 001 155 -               ROR      $001, $155
    01034: 1111 0111110 11 1 001 155 -               MULS     $001,#$155         WZ
    01038: 1111 0111111 01 1 001 155 -               SCLU     $001,#$155         WZ
    0103C: 1010 1000001 01 0 001 002 - if_z          SETNIB   $001, $002,#5
    01040: 0101 1000110 10 0 001 002 - if_nz         SETBYTE  $001, $002,#2
    01044: 0011 1001001 01 0 001 002 - if_nc         SETWORD  $001, $002,#1
    01048: 1100 1001001 00 1 001 002 - if_c          SETWORD  $001,#$002,#0
    0104C: 1111 1001101 00 1 001 008 -               REV      $001,#$008
    01050: 1111 1010100 10 0 001 002 -               ADDCT3   $001, $002
    01054: 1111 1011011 10 0 001 002 -               BLNPIX   $001, $002
    01058: 0010 1010011 11 1 001 002 - if_z_and_nc   TESTB    $001,#$002      WC,WZ
    0105C: 1000 1010101 00 1 001 017 - if_z_and_c    CALLD    $001,#$017
    01060: 0001 1010111 00 0 001 002 - if_nz_and_nc  RDLUT    $001, $002
    01064: 0100 1011010 00 0 001 002 - if_nz_and_c   RDLONG   $001, $002
    01068: 1111 1011000 10 1 001 180 -               RDBYTE   $001,PTRB       WC
    0106C: 1111 1010100 11 1 001 15F -               WMLONG   $001,--PTRA
    01070: 1111 1011000 10 1 001 1E1 -               RDBYTE   $001,PTRB++     WC
    01074: 1111 1011001 11 1 001 15B -               RDWORD   $001,--PTRA[5]  WC,WZ
    01078: 1111 1011010 01 1 001 1E7 -               RDLONG   $001,PTRB++[7]     WZ
    0107C: 1111 1100010 00 1 001 1E1 -               WRBYTE   $001,PTRB++
    01080: 1111 1100010 10 1 001 151 -               WRWORD   $001,--PTRA[15]
    01084: 1111 1100011 00 1 001 1EC -               WRLONG   $001,PTRB++[12]
    01088: 1011 1100011 01 1 100 100 - if_z_or_nc    WRLONG  #$100,PTRA
    0108C: 1110 1100111 10 0 001 002 - if_z_or_c     COGINIT  $001            WC
    


  • cgraceycgracey Posts: 14,152
    Looks really good, Cluso.

    In writing the ROM code, I made a few modifications to the instruction coding, as you suggested, to get things grouped better. After I do a full compilation, we'll have a version 11, which will have the final encodings.
  • Cluso99Cluso99 Posts: 18,069
    Chip,
    I am not sure whether you found a couple of others. I will update here shortly.
  • Cluso99Cluso99 Posts: 18,069
    Chip,
    Here are how I had to group the instructions for disassembling. Just ask if you cannot follow the grouping.
    ''-----------------------------------------------------------------------------------------------------------
    ''     Instr00 01      10      11           Cond Opcode  CZ I Dest       Source       Operand(s)  Flags
    ''-----------------------------------------------------------------------------------------------------------
    _TABLE_OPC1				  ' %0011_11_00 (DS CZ xxI)  "<"                                                                          
     byte "ROR    <ROL    <SHR    <SHL    <"  ' CCCC 00000ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "RCR    <RCL    <SAR    <SAL    <"  ' CCCC 00001ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "ADD    <ADDX   <ADDS   <ADDSX  <"  ' CCCC 00010ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "SUB    <SUBX   <SUBS   <SUBSX  <"  ' CCCC 00011ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "CMP    <CMPX   <CMPS   <CMPSX  <"  ' CCCC 00100ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "CMPR   <CMPM   <SUBR   <CMPSUB <"  ' CCCC 00101ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "MIN    <MAX    <MINS   <MAXS   <"  ' CCCC 00110ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "SUMC   <SUMNC  <SUMZ   <SUMNZ  <"  ' CCCC 00111ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "ISOB   <NOTB   <CLRB   <SETB   <"  ' CCCC 01000ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "SETBC  <SETBNC <SETBZ  <SETBNZ <"  ' CCCC 01001ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "ANDN   <AND    <OR     <XOR    <"  ' CCCC 01010ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "MUXC   <MUXNC  <MUXZ   <MUXNZ  <"  ' CCCC 01011ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "MOV    <NOT    <ABS    <NEG    <"  ' CCCC 01100ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "NEGC   <NEGNC  <NEGZ   <NEGNZ  <"  ' CCCC 01101ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ CZ CZ
     byte "**alt**<DECOD  <TOPONE <BOTONE <"  '*CCCC 01110ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         ff CZ CZ CZ
     byte "INCMOD <DECMOD <**mul**<**scl**<"  '*CCCC 01111ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#         CZ CZ fZ fZ
    ''-----------------------------------------------------------------------------------------------------------
    _TABLE_OPC2_ffnnn			  ' %0011_nn_11 (DS nn Rxx)  "?"/";"/"7"                                                                           
     byte "SETNIB ?GETNIB ?ROLNIB ?******* "  ' CCCC 1000ffn nn I DDDDDDDDD  SSSSSSSSS  D,S/#,#n                                       -- -- -- --
    _TABLE_OPC2_fnn
     byte "SETBYTE;GETBYTE;                "  ' CCCC 100011f nn I DDDDDDDDD  SSSSSSSSS  D,S/#,#n                                       -- --      
    _TABLE_OPC2_0nn
     byte "ROLBYTE;                        "  ' CCCC 1001000 nn I DDDDDDDDD  SSSSSSSSS  D,S/#,#n                                       --         
    _TABLE_OPC2_1fn
     byte "SETWORD7GETWORD7                "  ' CCCC 1001001 fn I DDDDDDDDD  SSSSSSSSS  D,S/#,#n                                       -- --      
    _TABLE_OPC2_00n
     byte "ROLWORD7                        "  ' CCCC 1001010 0n I DDDDDDDDD  SSSSSSSSS  D,S/#,#n                                       --         
    _TABLE_OPC2_01f				  ' %0011_00_00 (DS -- xxI)  "0"
     byte "SETBYTS0MOVBYTS0                "  ' CCCC 1001010 1f I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -- --      
    _TABLE_OPC2_CZ				  ' %0011_00_00 (DS -- xxI)  "0", "p" (WMxxxx)
     byte "SPLITB 0MERGEB 0SPLITW 0MERGEW 0"  ' CCCC 1001011 ff I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -- -- -- --
     byte "SEUSSF 0SEUSSR 0RGBSQZ 0RGBEXP 0"  ' CCCC 1001100 ff I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -- -- -- --
     byte "REV    0SETI   0SETD   0SETS   0"  ' CCCC 1001101 ff I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -- -- -- --
     byte "DJZ    0DJNZ   0DJS    0DJNS   0"  ' CCCC 1001110 ff I DDDDDDDDD  SSSSSSSSS  D,S/#rel9                                      -- -- -- --
     byte "TJZ    0TJNZ   0TJS    0TJNS   0"  ' CCCC 1001111 ff I DDDDDDDDD  SSSSSSSSS  D,S/#rel9                                      -- -- -- --
     byte "ADDCT1 0ADDCT2 0ADDCT3 0WMLONG p"  '*CCCC 1010100 ff I DDDDDDDDD  SSSSSSSSS  D,S/#;D,S/#;D,S/#;D,S/#/PTRx                   -- -- -- --
     byte "ADDPIX 0MULPIX 0BLNPIX 0MIXPIX 0"  '*CCCC 1011011 ff I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -- -- -- --
    _TABLE_OPC_alt
     byte "ALTI   0ALTR   0ALTD   0ALTS   0"  '*CCCC 0111000 ff I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -- -- -- --
    _TABLE_OPC2_X				  ' %0011_11_00 (DS CZ xxI)  "<", "?" (RD/WRxxxx)
     byte "TESTN  <TEST   <ANYB   <TESTB  <"  ' CCCC 10100ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#                                          CZ CZ CZ CZ
     byte "******* CALLD  <RDPIN  <RDLUT  <"  '*CCCC 10101ff CZ I DDDDDDDDD  SSSSSSSSS  ?;D,S/#rel9;D,S/#;D,S/#                        xx CZ CZ CZ        
     byte "RDBYTE ",$7C,"RDWORD ",$7C,"RDLONG ",$7C,"*******<"  '*CCCC 10110ff CZ I DDDDDDDDD  SSSSSSSSS  D,S/#/PTRx                                     CZ CZ CZ CZ
    _TABLE_OPC2_iC				  ' %0011_00_10 (DS -- xLI)  "2", "*" (COGINIT), "r" (WRxxxx)
     byte "<empty>2<empty>2JP     2JNP    2"  ' CCCC 101110f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#;D/#,S/#;D/#,S/#rel9;D/#,S/#rel9        -- -- -- --
     byte "SETPAE 2SETPAN 2SETPBE 2SETPBN 2"  ' CCCC 101111f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#                                        -- -- -- --
     byte "WRPIN  2WXPIN  2WYPIN  2WRLUT  2"  ' CCCC 110000f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#                                        -- -- -- --
     byte "WRBYTE rWRWORD rWRLONG rRDFAST 2"  ' CCCC 110001f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#/PTRx;D/#,S/#/PTRx;D/#,S/#/PTRx;D/#,S/# -- -- -- --
     byte "WRFAST 2FBLOCK 2XINIT  2XZERO  2"  ' CCCC 110010f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#                                        -- -- -- --
     byte "XCONT  2REP    2COGINIT*COGINIT*"  '*CCCC 110011f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#                                        -- -- C- C-
     byte "QMUL   2QDIV   2QFRAC  2QSQRT  2"  ' CCCC 110100f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#                                        -- -- -- --
     byte "QROTATE2QVECTOR2#######2#######2"  ' CCCC 110101f fL I DDDDDDDDD  SSSSSSSSS  D/#,S/#                                        -- -- ## ##
    _TABLE_OPC_mul				  ' %0011_01_00 (DS -Z xxI)  "4"
     byte "MUL    4MULS   4SCLU   4SCL    4"  '*CCCC 011111f fZ I DDDDDDDDD  SSSSSSSSS  D,S/#                                          -Z -Z -Z -Z
    ''-----------------------------------------------------------------------------------------------------------
    _TABLE_OPC3				  ' %0010_11_01 (D- CZ xxL)  "-"                                                         
     byte "CLKSET -COGID  -<empty>-COGSTOP-"  ' CCCC 1101011 CZ L DDDDDDDDD  0000000ff  D/#           CZ CZ CZ --
     byte "LOCKNEW-LOCKRET-LOCKCLR-LOCKSET-"  ' CCCC 1101011 CZ 0 DDDDDDDDD  0000001ff  D;D/#;D/#;D/# CZ -- C- C-
     byte "<empty>-<empty>-<empty>-<empty>-"  ' CCCC 1101011 CZ L DDDDDDDDD  0000010ff  D/#           CZ CZ CZ CZ
     byte "<empty>-<empty>-QLOG   -QEXP   -"  ' CCCC 1101011 CZ L DDDDDDDDD  0000011ff  D/#           CZ CZ -- --
     byte "RFBYTE -RFWORD -RFLONG -WFBYTE -"  ' CCCC 1101011 CZ 0 DDDDDDDDD  0000100ff  D;D;D;D/#     CZ CZ CZ --
     byte "WFWORD -WFLONG -SETQ   -SETQ2  -"  ' CCCC 1101011 00 L DDDDDDDDD  0000101ff  D/#           -- -- -- --
     byte "GETQX  -GETQY  -GETCT  -GETRND -"  ' CCCC 1101011 CZ 0 DDDDDDDDD  0000110ff  D             CZ CZ -- CZ
     byte "SETDACS-SETXFRQ-GETXCOS-GETXSIN-"  ' CCCC 1101011 00 L DDDDDDDDD  0000111ff  D/#;D/#;D;D   -- -- -- --
     byte "SETEDG -SETRDL -SETWRL -SETHLK -"  ' CCCC 1101011 00 L DDDDDDDDD  0001000ff  D/#           -- -- -- --
     byte "*******-SETINT1-SETINT2-SETINT3-"  ' CCCC 1101011 00 L DDDDDDDDD  0001001ff  -;D/#;D/#;D/# -- -- -- --
     byte "WAITX  -SETCZ  -PUSH   -POP    -"  ' CCCC 1101011 CZ L DDDDDDDDD  0001010ff  D/#;D/#;D/#;D -- CZ -- CZ
     byte "JMP    -CALL   -CALLA  -CALLB  -"  ' CCCC 1101011 CZ 0 DDDDDDDDD  0001011ff  D             CZ CZ CZ CZ
     byte "JMPREL -RET    -RETA   -RETB   -"  ' CCCC 1101011 CZ L DDDDDDDDD  0001100ff  D/#;-;-;-     -- CZ CZ CZ
     byte "GETPTR -GETINT -SETBRK -SETLUT -"  ' CCCC 1101011 00 0 DDDDDDDDD  0001101ff  D;D;D/#;D/#   -- -- -- --
     byte "SETCY  -SETCI  -SETCQ  -SETCFRQ-"  ' CCCC 1101011 00 L DDDDDDDDD  0001110ff  D/#           -- -- -- --
     byte "SETCMOD-SETPIX -SETPIV -COGATN -"  ' CCCC 1101011 00 L DDDDDDDDD  0001111ff  D/#           -- -- -- --
    ''-----------------------------------------------------------------------------------------------------------
    _TABLE_OPC4				  ' %0100_11_00 (-- CZ xxI)  "L"                                                                            
     byte "POLLINTLPOLLCT1LPOLLCT2LPOLLCT3L"  ' CCCC 1101011 C0 0 0000000ff  000100100                C- C- C- C- 
     byte "POLLEDGLPOLLPATLPOLLRDLLPOLLWRLL"  ' CCCC 1101011 C0 0 0000001ff  000100100                C- C- C- C- 
     byte "POLLXMTLPOLLXFILPOLLXROLPOLLXRLL"  ' CCCC 1101011 C0 0 0000010ff  000100100                C- C- C- C- 
     byte "POLLFBWLPOLLHLKLPOLLATNLPOLLQMTL"  ' CCCC 1101011 C0 0 0000011ff  000100100                C- C- C- C- 
     byte "WAITINTLWAITCT1LWAITCT2LWAITCT3L"  ' CCCC 1101011 C0 0 0000100ff  000100100                C- C- C- C- 
     byte "WAITEDGLWAITPATLWAITRDLLWAITWRLL"  ' CCCC 1101011 C0 0 0000101ff  000100100                C- C- C- C- 
     byte "WAITXMTLWAITXFILWAITXROLWAITXRLL"  ' CCCC 1101011 C0 0 0000110ff  000100100                C- C- C- C- 
     byte "WAITFBWLWAITHLKLWAITATNL<empty>L"  ' CCCC 1101011 C0 0 0000111ff  000100100                C- C- C- CZ 
     byte "ALLOWI LSTALLI L<empty>L<empty>L"  ' CCCC 1101011 00 0 0001000ff  000100100                -- -- xx xx 
     byte "<empty>L<empty>L<empty>L<empty>L"  ' CCCC 1101011 CZ 0 0001001ff  000100100                CZ CZ CZ CZ 
    ''-----------------------------------------------------------------------------------------------------------
    _TABLE_OPC5				  ' %0100_xx_11 (-- RW xxR)  "K"/"O"/"C"                                                                            
     byte "JMP    KCALL   KCALLA  KCALLB  K"  ' CCCC 11011ff Rn n nnnnnnnnn  nnnnnnnnn  #abs/#rel     -- -- -- --
     byte "CALLD  OLOC    O"                  ' CCCC 1110fww Rn n nnnnnnnnn  nnnnnnnnn  reg,#abs/#rel -- --      
     byte "AUGS   CAUGD   C"                  ' CCCC 1111fnn nn n nnnnnnnnn  nnnnnnnnn  #23bits       -- --      
    
    Just ignore the 8th char of each instruction. Where there are instructions that are broken down, they are marked as "*******" or "**alt**" etc.

    It was mainly the order of the group 2 opcodes so that similar decodings are grouped together.
    Not sure if you did the change to the group4 (POLLINT etc with no operands) to use D=001000000 so they fall out of being in the middle of group 2 (currently between SETHLK and SETINT1).

    While the SETNIB-ROLWORD & SETBYTS-MOVBYTS didn't quite fit the mould, they really fit nicely where they are.
  • Cluso99Cluso99 Posts: 18,069
    BTW there are two CALLD instructions. CALLD D,S/#rel9 and CALLD reg,#abs/#rel.
    Do you think one needs a different name???
  • Cluso99Cluso99 Posts: 18,069
    Chip,
    Do you feel like dropping some debug code into the ROM?

    I have RX and RXSTRING working so I would just need to update the instruction table and we could call all these routines I have in my debugger from user programs???
  • cgraceycgracey Posts: 14,152
    Cluso99 wrote: »
    BTW there are two CALLD instructions. CALLD D,S/#rel9 and CALLD reg,#abs/#rel.
    Do you think one needs a different name???

    No. The assembler will pick which one.

    If the 2nd operand is 'S', instead of '#', or D is not $1F6..$1F9, then it must be the 'CALLD D,S/#rel9'. Otherwise, it's 'CALLD reg,#abs/#rel'.
  • cgraceycgracey Posts: 14,152
    edited 2016-07-12 04:45
    Cluso99 wrote: »
    Chip,
    Do you feel like dropping some debug code into the ROM?

    I have RX and RXSTRING working so I would just need to update the instruction table and we could call all these routines I have in my debugger from user programs???

    Here's the problem:

    The ROM can only be reliably read at boot time, since other cogs doing CLKSET instructions can mess up the ROM address counter. It uses the CLKSET instruction to read the ROM, one byte at a time. The idea is only to read the data into $00000..$03FFF and then do a 'COGINIT #0,#0' to execute the cog program starting at $00000. I could change the way that it works, somewhat, so all cogs could access it, but I don't know that there's much benefit to that.

    This means that the ROM image is fleeting, and not permanently mapped into the RAM, unlike Prop2-Hot. It also means you get more RAM. Being there only at boot time means that you can't just call up a debugger any time from ROM. That could change. Or, the ROM could become maybe only 2KB, instead of 16KB, because that's all we actually need. Well, 4K would afford a nice monitor, in case no fancy tools are available and you just want to shoot it an image via text, or poke around.
  • Cluso99Cluso99 Posts: 18,069
    Chip

    Here is my latest code v0.110 which has RX and RXSTRING working with a hub buffer. <bs> works to edit, echo char too.

    The user cog code can be removed as its only a test. All code runs in hubexec mode. Currently requires cog $1D0-$1EF for registers until I save on a hub stack.
  • Cluso99Cluso99 Posts: 18,069
    Chip,
    On an early version you had a ROM monitor built-in. I had presumed you were going to do similar for this version.

    Would it be possible on bootup to load the internal ROM into hub somewhere? That way, if the user wants it, its there. Otherwise he can overwrite it with code from the external SPI Flash.

    If so, could you just place this in the pseudo ROM and load up on boot. At least it will go a long way to help debug the P2 even if its not in the final P2 ROM???

    I will take a look at how big it is - what is pnut option to see the listing?
Sign In or Register to comment.