It is currently Sun May 20, 2018 8:29 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: x816 syntax question
PostPosted: Tue Feb 06, 2018 5:55 pm 
Offline

Joined: Tue Feb 06, 2018 5:32 pm
Posts: 2
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:
            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.


Top
 Profile  
 
 Post subject: Re: x816 syntax question
PostPosted: Tue Feb 06, 2018 6:45 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3064
Location: Tampere, Finland
"<" 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


Top
 Profile  
 
 Post subject: Re: x816 syntax question
PostPosted: Tue Feb 06, 2018 7:50 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 868
Location: cypress, texas
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.

Top
 Profile  
 
 Post subject: Re: x816 syntax question
PostPosted: Tue Feb 06, 2018 10:41 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3369
Location: Mountain View, CA, USA
Aforementioned answers are correct, but I wanted to quote the actual x816 documentation (X816.DOC):

Code:
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


Top
 Profile  
 
 Post subject: Re: x816 syntax question
PostPosted: Wed Feb 07, 2018 12:17 pm 
Offline

Joined: Tue Feb 06, 2018 5:32 pm
Posts: 2
Thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group