x816 syntax question
Page 1 of 1

Author:  pikachu64 [ Tue Feb 06, 2018 5:55 pm ]
Post subject:  x816 syntax question

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
            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.

Author:  thefox [ Tue Feb 06, 2018 6:45 pm ]
Post subject:  Re: x816 syntax question

"<" means "low byte", ">" means "high byte". In other words, "<" takes the bottom 8 bits from the value, and ">" takes the upper 8 bits.

Author:  unregistered [ Tue Feb 06, 2018 7:50 pm ]
Post subject:  Re: x816 syntax question

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.)

Author:  koitsu [ Tue Feb 06, 2018 10:41 pm ]
Post subject:  Re: x816 syntax question

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

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

Author:  pikachu64 [ Wed Feb 07, 2018 12:17 pm ]
Post subject:  Re: x816 syntax question

Thank you

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group