Shop OBEX P1 Docs P2 Docs Learn Events
ILA: Inline (mini) Assembler for P2... — Parallax Forums

ILA: Inline (mini) Assembler for P2...

Cluso99Cluso99 Posts: 18,069
edited 2013-05-10 01:22 in Propeller 2
I have been thinking about adding inline assembly capability to my P2 LMM Debugger...
http://forums.parallax.com/forumdisplay.php/97-Propeller-2-Multicore

This would be a simple inline assembler built right into the debugger. So you could enter a small program (no labels, just addresses so you will only do small programs), and then test it out and verify the correct results with the debugger. The debuger can examine and display both cog and hub memory, as well as changing it inputting bytes/longs. It can partially decode instructions (at least into their bit patterns now, and will do some basic opcodes soon).

Your program calls the debugger, while it waits patiently in cog to resume (almost all debugger code resides in hub and is executed by an LMM unit in cog). You can return to the user program, or restart at any cog address, or do coginit (wip).

So, wouldn't it be a nice addition to be able to change or add a few short asm instructions into your user code in cog, and then execute it?

Initially I think only the basic instructions will be implemented (there are over 300 instructions in the P2).

This could work quite nicely with Chip's little interpreter for testing the small code units.

BTW I proved the debugger concept will happily run on the P1 also because I chose not to use any of the newer features of the P2 where possible.

Chip: Would you be willing to release the code tables for pnut and just that part of the assembly using it? I won't be using labels/symbols so I don't need any of that, nor the editor. I was proficient in 486 assembler a number of years ago so I can certainly read the code.

Comments

  • cgraceycgracey Posts: 14,151
    edited 2013-05-09 21:43
    Cluso99 wrote: »
    Chip: Would you be willing to release the code tables for pnut and just that part of the assembly using it? I won't be using labels/symbols so I don't need any of that, nor the editor. I was proficient in 486 assembler a number of years ago so I can certainly read the code.

    I'll do whatever you need, but what do you mean by code tables? Do you mean a comprehensive list of instructions and their coding? I've been working on that. The PC assembly code is pure spaghetti.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-09 22:02
    I thought you may have prepared lookup tables for the instructions in pnut. Otherwise I have your instructions in excel so I can generate them there - just thought it may save me some time.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-09 22:05
    I have thought about the conditional assembly section - the 'cccc' bits and can get them into a 16 byte table (pretest for 0000 & 1111, so realy oly 14).
    Here is what I have prepared
    '                             000= never/ignore/always
    '                             100= eq
    '           ignores C =00     101= ne      00= ignores Z
    '                  NC =10     110= or      10= NZ       
    '                   C =11     111= and     11= Z        
    '                      │└─┐   │││ ┌────────┘│
    '                      └─┐│   │││ │┌────────┘ 
    '                                   '                       Z   C    
    _CCCC         byte      %00_0_000_00       ' if_never        0000  * 0 *
                  byte      %10_0_111_10       ' if_nz_and_nc    0001  N & N
                  byte      %10_0_111_11       ' if_z_and_nc     0010  Z & N
                  byte      %10_0_000_00       ' if_nc           0011  * * N
                  byte      %11_0_111_10       ' if_nz_and_c     0100  N & C
                  byte      %00_0_000_10       ' if_nz           0101  N * *
                  byte      %11_0_101_11       ' if_z_ne_c       0110  Z ! C
                  byte      %10_0_110_10       ' if_nz_or_nc     0111  N | N
                  byte      %11_0_111_11       ' if_z_and_c      1000  Z & C
                  byte      %11_0_100_11       ' if_z_eq_c       1001  Z = C
                  byte      %00_0_000_11       ' if_z            1010  Z * *
                  byte      %10_0_110_11       ' if_z_or_nc      1011  Z | N
                  byte      %11_0_000_00       ' if_c            1100  * * C
                  byte      %11_0_110_10       ' if_nz_or_c      1101  N | C
                  byte      %11_0_110_11       ' if_z_or_c       1110  Z | C
                  byte      %00_0_000_00       ' if_always       1111  * 1 *
    
    
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-05-09 22:15
    for some reason I cannot edit the last post :(

    For disassembling in my debugger, I will do this...

    By extracting cccc I can check for '0000' (if_never) and '1111' (if_always). The remainder I will fetch a byte from the table, offset by cccc.
    Then I can output "if_", then check the first 2 bits to see if the Z flag is used, and if so, output either "z" or "nz".
    Then I check the next 3 bits to determine if there needs to be "_and_", "_or_", "_eq_" or "_ne_" output,
    And last I skip a bit and check the 2 bits to see if the C flag is used and if so, output either "c" or "nc".

    Obviously, compile works the opposite, and I have to check for the alternatives such as if_be, etc. However, I may only support those basic ones since this will be a mini inline compiler.
  • SapiehaSapieha Posts: 2,964
    edited 2013-05-10 01:22
    Hi Chip.

    I can handle any PC assembly -- So if You can release code -- I can made my additions to it that help in LMM coding

    Thanks
    cgracey wrote: »
    I'll do whatever you need, but what do you mean by code tables? Do you mean a comprehensive list of instructions and their coding? I've been working on that. The PC assembly code is pure spaghetti.
Sign In or Register to comment.