Shop OBEX P1 Docs P2 Docs Learn Events
PASM and gcc-asm syntax difference — Parallax Forums

PASM and gcc-asm syntax difference

Hi,

I'm writing a driver source using gcc-asm instead of spin/pasm and I found that there is a little syntax difference:

With spin/pasm, if I write:
rdlong  var_base, ptr
add     ptr, #4
rdlong  var_base + 1, ptr

It works and writes the longs readed from hub memory to the location var_base and var_base+1, however the same code compiled with gcc-asm doesn't work, I think it takes only the first part (var_base) and ignore the addition and all results are written to the same location.

The obvious fix is to explicitly name the destination locations, however I wonder if this is a known issue, or there is a different syntax to do the same?

Comments

  • You might try "var_base + 4" instead. or try the keywords ".compress off". GCC is not used to 32-bit addresses and therefore does weird things.

    Also, this stuff has been changing in recent versions of PropGCC, so it will help if you can tell us exactly which version of propeller-elf-as you are using.
  • Yes, using var_base + 4 instead of +1 seems to work well, looks like gcc expects a byte count, a bit confusing when porting code snippets from spin projects (it took me half a day to figure out what wasn't working).

    In my source I have ".cog_ram" and ".compress off" directives already.

    The gcc version is:
    propeller-elf-gcc (propellergcc_v1_0_0_2411) 4.6.1
    
  • The .cog_ram directive was intended to resolve the byte addressing vs. long addressing problem, but it didn't work very well. It has been replaced in newer gas versions with .pasm, which works much better -- in fact if you use the .pasm directive (or the -pasm command line flag to propeller-elf-as) the GNU assembler is able to parse most .spin files and throw away the non-assembler parts of them, and it produces the same output for the assembler binary as Spin would.

    This does require a more recent version of the binutils package than the one that comes with SimpleIDE. In fact PropGCC has changed a lot since the 1.0.0 release, but for whatever reason SimpleIDE is not being updated with new versions. You can build it from source, of course (David Betz has a nice top level repository for this at https://github.com/dbetz/propeller-gcc). I think David Zemon has recent PropGCC binaries available from his PropWare page (look under "Useful Links" on http://david.zemon.name/PropWare/).
  • Thanks for the gentle shove ;). The links on PropWare's site were actually quite old so I just updated them to point to the build server
  • I have downloaded the binaries from PropWare's site, the version is propeller-elf-gcc (propellergcc-alpha_v1_9_0_) 4.6.1 the .pasm directive is recognized but still requires a byte count with the syntax above. I'll try to compile the source code when I have some more time, if it is a more recent version.

    Just to clarify, in my source file I have the following header:
    .pasm
    .compress off
    
    .section .coglcd_driver, "ax"
    
    .org     0
    
    ...
    

  • Sorry for being slow getting back to you. The .pasm directive should have worked correctly, but it appears there was a problem during the switch from mercurial to git -- the fixes for .pasm ended up in one repository but not in the one we're using for the propeller-gcc builds.

    I've fixed that, and builds done after today should have .pasm working correctly.
  • Great that you got it fixed. As always, the new builds are available from the links posted above
  • Yes, I have recompiled the source from GitHub and now it works.
    Thank you all.
Sign In or Register to comment.