Shop OBEX P1 Docs P2 Docs Learn Events
Simplified operators — Parallax Forums

Simplified operators

(moving this from the other big thread as well...)

I earlier made the following suggestion for simplifying the operator syntax:
cgracey wrote: »
One thing that is driving everyone nuts is the "@" operator. It was originally used to get the hub address of things. Then, it was used for relative branches. Now, it does both! Branches check for @ at the beginning of the address, and use it to compute relative offsets. If you use '@label' in a non-branch instruction, it means 'the absolute address of in hub memory'. What we need to do is differentiate these two cases of '@' so that one stays '@' and the other becomes some other character, like a back-tick or caret or something - anything else!

I'm not quite sure I'm following. I get that P1 used @, but let's put that aside for the moment. The address of a label depends on which section it's in (ORG/ORGH). When you have an instruction operand that begins with "@", it means immediate-relative. When it begins with "#" it means immediate-absolute. The one edge case is when you want an ORG label, but with a ORGH address. For that, I believe you have "#@", which is also immediate-absolute.

Is that not enough?

Also, can we get rid of "##" and just go with "#"? The assembler can still implicitly insert an AUGx when the value is greater than $1FF. As it stands right now:

# : Use for 9-bit immediates, or for 20-bit immediates, or in AUGx instructions
## : Use for short-hand to insert AUGx instruction (even if the value is less than $200). Does not apply to instructions with 20-bit immediates.

And I'm suggesting:

# : User for immediates. If a 9-bit immediate is expected and the value is greater than $1FF, an AUGx is inserted.

I then followed that up with the following comment:
Actually, if you were to make the change I suggest, we could use ## instead of #@. That way, you would have the following:

# : absolute immediate. In ORGH sections, value is in bytes. In ORG sections, value is in longs/register. If necessary, an AUGx will be inserted.

## : ORGH absolute immediate (regardless of which section the label is defined). If necessary, an AUGx will be inserted.

@ : relative immediate. Follows the same rules as it currently does.

There is no need for an "ORGH relative immediate" because you can't use relative addressing to jump from cog to hub exec mode.

How simple is that?


Discuss! :)

Comments

  • jmgjmg Posts: 15,173
    Seairth wrote: »
    ...

    Also, can we get rid of "##" and just go with "#"? The assembler can still implicitly insert an AUGx when the value is greater than $1FF. As it stands right now:

    # : Use for 9-bit immediates, or for 20-bit immediates, or in AUGx instructions
    If a 9-bit immediate is expected and the value is greater than $1FF, an AUGx is inserted.

    ## : Use for short-hand to insert AUGx instruction (even if the value is less than $200).
    Does not apply to instructions with 20-bit immediates.

    That seems sensible, 99% of use will be #, and AUGx is hidden/automatic, but can be forced in those rare cases that may need absolute control - but the second follow up, seems to modify that ?

  • jmg wrote: »
    That seems sensible, 99% of use will be #, and AUGx is hidden/automatic, but can be forced in those rare cases that may need absolute control - but the second follow up, seems to modify that ?

    I'm just suggesting that if we stop using ## for AUGx immediates, we could use ## instead of #@ to indicate hub-immediate (whereas # is dependent on the ORGx section it's in).
  • Cluso99Cluso99 Posts: 18,069
    Both suggestions make sense to me.

    We can make a relative ORGH ourselves by using the $=current address syntax. We can use it to FILL or NOFILL the gap using a BYTE/WORD/LONG $0 variable or RES variable.

    I have suggested elsewhere some compiler options. I would prefer to have ORGHUB and ORGCOG. The orgcog can automatically include cog and lut in its address. The user just needs to ensure the special registers are skipped. For the compiler (not pnut), it can provide a warning if the special registers are being overwritten (in case the FIT $1F0/$1F8 command was not used).

    Here are my suggestions (summary only)

    ORGHUB [LONG/WORD/BYTE,] $xxxxx [,FILL/NOFILL] 'default $0, default LONG, default NOFILL

    ORGCOG $xxx [,FILL/NOFILL] 'default $0, address in long, $000..$3FF, default NOFILL
  • jmgjmg Posts: 15,173
    Cluso99 wrote: »
    I have suggested elsewhere some compiler options. I would prefer to have ORGHUB and ORGCOG. The orgcog can automatically include cog and lut in its address. The user just needs to ensure the special registers are skipped. For the compiler (not pnut), it can provide a warning if the special registers are being overwritten (in case the FIT $1F0/$1F8 command was not used).

    Here are my suggestions (summary only)

    ORGHUB [LONG/WORD/BYTE,] $xxxxx [,FILL/NOFILL] 'default $0, default LONG, default NOFILL

    ORGCOG $xxx [,FILL/NOFILL] 'default $0, address in long, $000..$3FF, default NOFILL

    That makes sense, but it could be expanded to allow DATA and CODE to be separately defined.
    eg HUB DATA might naturally start at default $0, but HUB Code would naturally start at the lowest legal code address. ( Currently, that is > 0)


  • Cluso99Cluso99 Posts: 18,069
    jmg wrote: »
    That makes sense, but it could be expanded to allow DATA and CODE to be separately defined.
    eg HUB DATA might naturally start at default $0, but HUB Code would naturally start at the lowest legal code address. ( Currently, that is > 0)
    I would prefer to define _HUB_DATA = $00000 and _HUB_CODE = $01000 and then use ORGHUB _HUB_DATA/_HUB_CODE.
    If we had a standard, then they would be able to be moved if a P2 with different bases were produced.
    ie just like we define _XINFREQ now.
  • cgraceycgracey Posts: 14,155
    The trouble with having automatic AUGS/AUGD insertion is that the current assembler is only a two-pass. It can't have code size changing between passes.

    That's why I've been using '##' to mean 32-bit-constant.
Sign In or Register to comment.