Page 1 of 1
X816 syntax question
Posted: Tue Feb 06, 2018 5:55 pm
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
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.
Re: x816 syntax question
Posted: Tue Feb 06, 2018 6:45 pm
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.
Re: x816 syntax question
Posted: Tue Feb 06, 2018 7:50 pm
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.)
Re: x816 syntax question
Posted: Tue Feb 06, 2018 10:41 pm
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
Re: x816 syntax question
Posted: Wed Feb 07, 2018 12:17 pm
by pikachu64
Thank you