Shop OBEX P1 Docs P2 Docs Learn Events
@ or \ addressing - which to use? - Page 2 — Parallax Forums

@ or \ addressing - which to use?

2»

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-05-17 23:33
    @cgracey - the problem we have is that TAQOZ relocates to first 64k but while in TAQOZ a ^D only ends up using a relative jump to Cluso's debugger (can we refer to it simply as LSD ) but we were modifying the version of LSD in ROM so nothing happened. Looking at the machine code showed that the jump was relative but we had mistakenly thought that the @ would give us an absolute address but now we know it always refers to the hub address and we need to use \ to force absolute address or \@ for both. But we don't have an operator symbol to force relative although by default it looks like it does this.

    In some other assembly languages the # forces absolute mode and @ relative but the Prop has register addressing by default so the # is used to force a jump to immediate address which means we can't use this symbol for absolute vs relative.

    Maybe we could use:
    @ Force absolute hub address
    \ Use absolute address (cog or hub)
    ~ Try to use relative address but issue warning if out of range.


    @"Dave Hein" - Is p2asm something I can run on my system as I like having a real listing? Is there source available that we can enhance?

  • p2asm is part of the p2gcc toolset. It is available from GitHub at https://github.com/davehein/p2gcc . p2asm is located in the p2asm_src subdirectory. You can also get the latest release from the Can't Wait for PropGCC on the P2? thread.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-05-18 02:49
    Dave Hein wrote: »
    p2asm is part of the p2gcc toolset. It is available from GitHub at https://github.com/davehein/p2gcc . p2asm is located in the p2asm_src subdirectory. You can also get the latest release from the Can't Wait for PropGCC on the P2? thread.

    Thanks David, that was as easy as pie. I assembled a simple spin2 file but my ROM code doesn't. Guess I need to RTM ;)
    peter:BOOT$ ./p2asm ROM_137PBJ.spin2
    ERROR: Expected ",", but found "["
    Segmentation fault
    

    It might be because I am addressing 1MB of memory with the ROM at $FC000......
  • I just want to point out that we've had roughly the same conversation several times over the last year or two. I think it's an indication that the current syntax is confusing and hard to remember. Is there an alternative syntax we could use that's more understandable, even if it isn't as terse?
  • cgraceycgracey Posts: 14,131
    Seairth wrote: »
    I just want to point out that we've had roughly the same conversation several times over the last year or two. I think it's an indication that the current syntax is confusing and hard to remember. Is there an alternative syntax we could use that's more understandable, even if it isn't as terse?

    I don't know. I think the set of cases that Cluso put up and the revamping I made to it spells it out pretty well. There are just a few concepts to grasp. The complexity stems from the difference between cog and hub ram and their address spaces.
  • cgraceycgracey Posts: 14,131
    edited 2018-05-18 02:48
    @cgracey - the problem we have is that TAQOZ relocates to first 64k but while in TAQOZ a ^D only ends up using a relative jump to Cluso's debugger (can we refer to it simply as LSD ) but we were modifying the version of LSD in ROM so nothing happened. Looking at the machine code showed that the jump was relative but we had mistakenly thought that the @ would give us an absolute address but now we know it always refers to the hub address and we need to use \ to force absolute address or \@ for both. But we don't have an operator symbol to force relative although by default it looks like it does this.

    In some other assembly languages the # forces absolute mode and @ relative but the Prop has register addressing by default so the # is used to force a jump to immediate address which means we can't use this symbol for absolute vs relative.

    Maybe we could use:
    @ Force absolute hub address
    \ Use absolute address (cog or hub)
    ~ Try to use relative address but issue warning if out of range.


    @"Dave Hein" - Is p2asm something I can run on my system as I like having a real listing? Is there source available that we can enhance?

    Maybe there is a better way.

    Relative is what you'd want in most cases, but sometimes you need absolute addressing, in both intra-cog and intra-hub code.

    We've though about stripping the '#' from immediate addresses, but it causes other subtle confusion. I'd like '@' for relative, in place of '#', but '@' is our address-of operator in Spin.
  • how about just doing it with keywords in PASM

    keep it simple and readable.

    JMPA jumps absolute
    JMPR jumps relative

    and if JMPR is not possible because of crossing boundaries the compiler uses absolute and gives a warning/error?

    DJNZA /DJNZR does not look bad either.

    but DJNZ #\@.loop

    looks more like if someone is swearing in a comic book

    Mike
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-05-18 06:17
    <moved to a new thread>
  • evanhevanh Posts: 15,091
    edited 2018-12-06 10:43
    Just found this old topic. I thought it worth highlighting the latest findings: There is a bug in Pnut's LOC instruction encoding of relative hub addresses below absolute $400 for a LOC in cogRAM. See https://forums.parallax.com/discussion/comment/1457026/#Comment_1457026

    EDIT: Removed a totally wrong understanding.

Sign In or Register to comment.