Forum Update - Announcement about May 10th, 2018 update and your password.

p2asm

edit: moved this from another thread

@Dave Hein - While scratching my head I decided to add a bit more info to p2asm such as printing buffer2 on error messages. I found the offending line.
peter:BOOT$ ./p2asm ROM_137PBJ.spin2
ERROR: Expected ",", but found "["
  _HUBBUF       = $0_2000'[128]   ' hub buffer[128] used as default buffer by _HubRxString  (in writable hub ram!!)
By putting a space between the 2000 and the comment it was happy but of course I am now tracking down other funnies.
That was part of Cluso's code btw.

update - I added buffer2 to the "but found" lines even though PrintError should print it but had a segmentation fault. So I fudged the source a few times but eventually realized that Cluso's code doesn't always have whitespace where you would expect. Adding whitespace fixed the errors but I may fork p2asm.c and add some enhancements to it (as time permits).
peter:BOOT$ ./p2asm ROM_137PBJ.spin2
ERROR: Expected "41", but found "  ACMD41= 41 +$40   ' $4000_0000      R1       -       APP_SEND_OP_COND         *Reqs CMD55 first"
Segmentation fault
peter:BOOT$ ./p2asm ROM_137PBJ.spin2
ERROR: Expected "23", but found "  ACMD23= 23 +$40   ' NoBlks[22:0]    R1       -       SET_WR_BLOCK_ERASE_COUNT *Reqs CMD55 first"
Segmentation fault
So the asm source doesn't have whitespace between ACMD41 and the = operator. Also noticed that it doesn't like ackpin without an # operator as it throws an error.
ERROR: Unexpected EOL
ff1c4 156 fc0c0200                         akpin   pinreg                  '..acknowledge pin

After I cleaned up the source these are the remaining errors. BTW, Thanks for your hard work, it is so helpful to obtain a listing!
ERROR: MODZ is undefined
        _RET_   MODZ    _set                      wz    ' "Z" = success
ERROR: MODZ is undefined
        _RET_   MODZ    _set                      wz    ' "Z" = success
ERROR: MODZ is undefined
        _RET_   MODZ      _clr                        wz  '/ return "NZ" = not found
ERROR: MODZ is undefined
        _RET_   MODZ    _set                        wz  ' "Z" = success
ERROR: MODZ is undefined
        _RET_   MODZ    _clr                      wz    ' "NZ" = fail
ERROR: modc is undefined
pRCMOVE                 modc    $0F wc          ' set carry for decrementing (always cleared by PUSH)
ERROR: modc is undefined
        _ret_   modc    0
ERROR: MODZ is undefined
        _RET_   MODZ    _set                      wz    ' "Z" = success
ERROR: MODZ is undefined
        _RET_   MODZ    _set                      wz    ' "Z" = success
ERROR: MODZ is undefined
        _RET_   MODZ      _clr                        wz  '/ return "NZ" = not found
ERROR: MODZ is undefined
        _RET_   MODZ    _set                        wz  ' "Z" = success
ERROR: MODZ is undefined
        _RET_   MODZ    _clr                      wz    ' "NZ" = fail
ERROR: Unexpected EOL
                        akpin   pinreg                  '..acknowledge pin
ERROR: PTR not allowed
        if_z            wrlut   PTRA,retptr             ' save IP onto return stack
ERROR: modc is undefined
pRCMOVE                 modc    $0F wc          ' set carry for decrementing (always cleared by PUSH)
ERROR: modc is undefined
        _ret_   modc    0
ERROR: Unexpected EOL
                        akpin   pinreg                  '..acknowledge pin


I've worked around modc and modz for the moment by using modcz instead. Haven't had a look at PTR not allowed yet.
Tachyon Forth - compact, fast, forthwright and interactive
useforthlogo-s.png
--->CLICK THE LOGO for more links<---
Tachyon Forth News Blog
P2 SHORTFORM DATASHEET
TAQOZ documentation
Brisbane, Australia

Comments

  • 16 Comments sorted by Date Added Votes
  • FYI
    MODC and MODZ are aliases in Pnut for MODCZ.
    MODC    c               =       MODCZ   c,0         {WC}
    MODZ    z               =       MODCZ   0,z         {WZ}
    
    Melbourne, Australia
  • Test of pnut modcz aliases
    		modc	0	wc
    		modc	1	wc
    		modc	2	wc
    		modc	3	wc
    		modc	4	wc
    		modc	5	wc
    		modc	6	wc
    		modc	7	wc
    		modc	8	wc
    		modc	9	wc
    		modc	10	wc
    		modc	11	wc
    		modc	12	wc
    		modc	13	wc
    		modc	14	wc
    		modc	15	wc
    		modz	0	wz
    		modz	1	wz
    		modz	2	wz
    		modz	3	wz
    		modz	4	wz
    		modz	5	wz
    		modz	6	wz
    		modz	7	wz
    		modz	8	wz
    		modz	9	wz
    		modz	10	wz
    		modz	11	wz
    		modz	12	wz
    		modz	13	wz
    		modz	14	wz
    		modz	15	wz
    
    Compiles to
    000: FD74006F                  MODCZ   _CLR,_CLR  WC
    001: FD74206F                  MODCZ   _NC_AND_NZ,_CLR  WC
    002: FD74406F                  MODCZ   _NC_AND_Z,_CLR  WC
    003: FD74606F                  MODCZ   _NC,_CLR  WC
    004: FD74806F                  MODCZ   _C_AND_NZ,_CLR  WC
    005: FD74A06F                  MODCZ   _NZ,_CLR  WC
    006: FD74C06F                  MODCZ   _C_NE_Z,_CLR  WC
    007: FD74E06F                  MODCZ   _NC_OR_NZ,_CLR  WC
    008: FD75006F                  MODCZ   _C_AND_Z,_CLR  WC
    009: FD75206F                  MODCZ   _c_EQ_Z,_CLR  WC
    00A: FD75406F                  MODCZ   _z,_CLR  WC
    00B: FD75606F                  MODCZ   _NC_OR_Z,_CLR  WC
    00C: FD75806F                  MODCZ   _c,_CLR  WC
    00D: FD75A06F                  MODCZ   _C_OR_NZ,_CLR  WC
    00E: FD75C06F                  MODCZ   _C_OR_Z,_CLR  WC
    00F: FD75E06F                  MODCZ   _SET,_CLR  WC
    010: FD6C006F                  MODCZ   _CLR,_CLR  WZ
    011: FD6C026F                  MODCZ   _CLR,_NC_AND_NZ  WZ
    012: FD6C046F                  MODCZ   _CLR,_NC_AND_Z  WZ
    013: FD6C066F                  MODCZ   _CLR,_NC  WZ
    014: FD6C086F                  MODCZ   _CLR,_C_AND_NZ  WZ
    015: FD6C0A6F                  MODCZ   _CLR,_NZ  WZ
    016: FD6C0C6F                  MODCZ   _CLR,_C_NE_Z  WZ
    017: FD6C0E6F                  MODCZ   _CLR,_NC_OR_NZ  WZ
    018: FD6C106F                  MODCZ   _CLR,_C_AND_Z  WZ
    019: FD6C126F                  MODCZ   _CLR,_c_EQ_Z  WZ
    01A: FD6C146F                  MODCZ   _CLR,_z  WZ
    01B: FD6C166F                  MODCZ   _CLR,_NC_OR_Z  WZ
    01C: FD6C186F                  MODCZ   _CLR,_c  WZ
    01D: FD6C1A6F                  MODCZ   _CLR,_C_OR_NZ  WZ
    01E: FD6C1C6F                  MODCZ   _CLR,_C_OR_Z  WZ
    01F: FD6C1E6F                  MODCZ   _CLR,_SET  WZ
    
    Melbourne, Australia
  • Thanks for finding the issues with p2asm. Some of those were already on my TODO list, but I haven't gotten around to fixing them yet. I encountered the "ACMD41=" problem when I was trying to assemble another program. I also have the MODZ/MODC aliases on my list of things to do. I think there's a few other aliases I haven't implemented.

    There's also an issue with labels not appearing in the listing if they are on the same line as other code. Looks like it's time to clean up all these issues. Is the file ROM_137PBJ.spin2 available somewhere so I can test with it? If not, I'll just create a file that contains all the issues you pointed out so I can test with it.

  • Peter JakackiPeter Jakacki Posts: 7,252
    edited May 18 Vote Up0Vote Down
    Dave Hein wrote: »
    Thanks for finding the issues with p2asm. Some of those were already on my TODO list, but I haven't gotten around to fixing them yet. I encountered the "ACMD41=" problem when I was trying to assemble another program. I also have the MODZ/MODC aliases on my list of things to do. I think there's a few other aliases I haven't implemented.

    There's also an issue with labels not appearing in the listing if they are on the same line as other code. Looks like it's time to clean up all these issues. Is the file ROM_137PBJ.spin2 available somewhere so I can test with it? If not, I'll just create a file that contains all the issues you pointed out so I can test with it.

    Thanks, you can find that file in my Dropbox P2 folder BOOT folder
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET
    TAQOZ documentation
    Brisbane, Australia
  • Ooh. Didn't realise there is a P2ASM.
    Where is it please?
  • Has anyone done a plugin for NotePad++ ?
  • Peter JakackiPeter Jakacki Posts: 7,252
    edited May 18 Vote Up0Vote Down
    You can get Dave's p2gcc which includes p2asm from this zip but you need gcc to build it.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET
    TAQOZ documentation
    Brisbane, Australia
  • You can get Dave's p2gcc which includes p2asm from this zip but you need gcc to build it.
    :(
  • I checked some fixes to p2asm into GitHub. p2asm can now correctly assemble ROM_137PBJ.spin2, and the binary file matches the binary produced by PNut. The source is included in the attached zip file. I also included a p2asm.exe Windows executable. Cluso, hopefully this will work for you.
  • Peter JakackiPeter Jakacki Posts: 7,252
    edited May 19 Vote Up0Vote Down
    Thanks Dave, you're a champion. I grabbed a zip off github and ran it through the very latest ROM (still testing) without any errors :)

    <link to ROM listing>

    That listing is soooo helpful, I found why my code wasn't running after I combined all the other code it had a byte string at the end which ended up knocking out the word alignment and TAQOZ uses the lsb of a hub code address to indicate jumping rather than calling :)
    fd003              _Enter_TAQOZ
                       ''---------------------------------------------------------------------------------------------------
                       
                       
    fd003     fedfeff9                 loc     PTRA,#_hubrom           ' copy all of ROM to low 64K'
    fd007     fef0eff5                 loc     PTRB,#$C000
    fd00b     ff000008                 rep     #2,##$1000
    fd00f     fcdc0400 
    fd013     fb041761                 rdlong  fx,PTRA++
    fd017     fc6417e1                 wrlong  fx,PTRB++
    

    Add an alignw
    fcfff                              orgh
    fcfff              		alignw
                       		
                       ''-------[ Start TAQOZ ]----------------------------------------------------- <--- start TAQOZr --->
    fd000     fdbffa54 _Start_TAQOZ    call    #@_reset_booter                 ' reset the booters interrupts and autobaud
                       
    fd004              _Enter_TAQOZ
                       ''---------------------------------------------------------------------------------------------------
                       
                       
    fd004     fedfeff8                 loc     PTRA,#_hubrom           ' copy all of ROM to low 64K'
    fd008     fef0eff4                 loc     PTRB,#$C000
    fd00c     ff000008                 rep     #2,##$1000
    

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    --->CLICK THE LOGO for more links<---
    Tachyon Forth News Blog
    P2 SHORTFORM DATASHEET
    TAQOZ documentation
    Brisbane, Australia
  • Thanks Dave. Peter sent me a copy of the output looks great!
    I have downloaded now. Thanks for the exe ;)
  • FWIW
    Anyone with W10 will need to open a command line and supply the filename as a parameter. It helps to have P2ASM and the source file in the same folder.

    Dave,
    Thanks for this. Already proved useful with a bug to call the ROM routines. Was using a string in cog but it needs to be in hub and I forgot. The listing showed it up straight away :)

  • @Dave Hein I too am liking your p2asm listing!
    But it looks like p2asm is having a problem in the CON section digesting the bitwise decode "|<" (and maybe encode?) ">|" operators:
    ' USB receiver RDPIN status bit positions:
            #0, J_IDLEB, K_RESUMEB, SE0_RESETB, SE1_BADB, SOPB, EOPB, RXERRB, BYTE_TGLB
    ' USB receiver RDPIN status bitflags:
            J_IDLEF    = |< J_IDLEB
            K_RESUMEF  = |< K_RESUMEB
            SE0_RESETF = |< SE0_RESETB
            SE1_BADF   = |< SE1_BADB
            SOPF       = |< SOPB
            EOPF       = |< EOPB
            RXERRF     = |< RXERRB
            BYTE_TGLF  = |< BYTE_TGLB
    
    and the enumeration[offset] syntax option:
    '------------------------------------------------------------------------------
    ' HID Class Requests (v1.11 HID Device Class Definition, Section 7.2):
    '------------------------------------------------------------------------------
            #$01, HID_GET_REPORT, HID_GET_IDLE, HID_GET_PROTO[6] ' $04 - $08 reserved
            HID_SET_REPORT, HID_SET_IDLE, HID_SET_PROTO
    ' HID Descriptor types:
            #$21, TYPE_HID, TYPE_REPORT, TYPE_PHYSICAL ' HID types $24 - $2f are reserved
    

    I've attached the full source in case you'd like to use it as a test case.
    garryj
  • I'll look into it. I'm pretty sure I hadn't implemented those features. It shouldn't be too hard to add them.
  • Dave HeinDave Hein Posts: 5,453
    edited May 27 Vote Up0Vote Down
    @garryj, I fixed the problems that p2asm was having with USBHost and I checked it into GitHub. I added support for the |< operator, and also support for handling HID_GET_PROTO[6]. I wasn't aware that [n] could be used in a CON section to increment the enum value.

    I also found that I wasn't handling forward references to constants correctly. I had to restructure how I parse the source file to fix it. Previously, I used 2 passes, where the first pass gathered symbols and their values, and the second pass generated code. However, Spin/PASM requires processing all the CON symbols first, and then the next 2 passes are performed. If constants reference other constants that are defined later in the file it actually requires an additional pass through the source file.


    Thanks for posting the USBHost code. I added it to the list of programs that I use to test the assembler.
  • Just ran a test build and it works great! Thanks, Dave, for taking the time to do this!
    garryj
Sign In or Register to comment.