X816 syntax question

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
pikachu64
Posts: 6
Joined: Tue Feb 06, 2018 5:32 pm
Location: Upstate NY, USA

X816 syntax question

Post by pikachu64 »

Hello. I am looking at the Super Mario Bros 1 assembly code that is on Github Gist (Google "Super Mario Bros assembly code" to find it). I came upon some syntax that I don't understand, and to this point it is also the only question I have regarding the source code thus far.

The syntax in question is the ">" and "<" prefixes.

For example, line 1592

Code: Select all

            lda #<TitleScreenDataOffset
I understand # means immediate addressing, but what are the less-than and greater-than signs for?

The Gist says it compiles using x816, and I tried looking up the docs of that to no avail.
Last edited by pikachu64 on Sat Feb 23, 2019 6:19 am, edited 1 time in total.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: x816 syntax question

Post by thefox »

"<" means "low byte", ">" means "high byte". In other words, "<" takes the bottom 8 bits from the value, and ">" takes the upper 8 bits.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: x816 syntax question

Post by unregistered »

If the address of TitleScreenDataOffset is $C123 then:

lda #<TitleScreenDataOffset would load the accumulator with #$23 :)

edit: $ means hexadecimal. Each digit in hex takes 4 bits... 0 to F (hex) == 0000 to 1111 (binary).

edit2 (was: b == a; switched the order to a == b since it makes more sense when reading it, to me at least.)
Last edited by unregistered on Wed Feb 07, 2018 1:31 pm, edited 1 time in total.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: x816 syntax question

Post by koitsu »

Aforementioned answers are correct, but I wanted to quote the actual x816 documentation (X816.DOC):

Code: Select all

Numbers and Expressions
-----------------------
...

A number can be modified using the symbols <, >, ^, and !
preceding the number or symbol.

   < get low byte
   > get high byte
   ^ get bank byte
   ! get word value

The use of the ^ or ! will only function if they are placed
at the beginning of the expression in the operand field.

   LDA  !512
   LDA  !$1234
   LDA  #!512
   LDA  #!$1234
pikachu64
Posts: 6
Joined: Tue Feb 06, 2018 5:32 pm
Location: Upstate NY, USA

Re: x816 syntax question

Post by pikachu64 »

Thank you
Post Reply