It is currently Wed Oct 17, 2018 7:28 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: What does lda #>oam do?
PostPosted: Wed Sep 05, 2018 6:14 pm 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 76
Location: Colorado
So I was looking through some code that was posted on this forum. I can't remember who's code it was (sorry about that), but there was list accumulator load:

Code:
lda #>oam


What does the #> mean. I've been googling around for it, but I just can't seem to find it anywhere.

Thanks for your help,
Rick

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
PostPosted: Wed Sep 05, 2018 6:22 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3634
Location: Mountain View, CA
It depends on the assembler, so you should always refer to your assembler documentation.

>thing usually means "get the high byte of thing". Likewise, <thing means "get the low byte of thing". The # obviously means immediate addressing, thus the accumulator will end up holding the high (or low) byte of wherever thing is located. The high and low bytes are calculated at assemble-time, not run-time. Better demonstrated with pseudocode, I suppose:

Assume oam is a variable that resides somewhere -- say in RAM, at address $0520. Thus:

Code:
  lda #<oam   ; equivalent to lda #$20
  lda #>oam   ; equivalent to lda #$05

Likewise, if you were to not use immediate addressing, and had this instead...
Code:
  lda <oam    ; equivalent to lda $20
  lda >oam    ; equivalent to lda $05

Make sense?


Top
 Profile  
 
PostPosted: Wed Sep 05, 2018 6:28 pm 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 76
Location: Colorado
Ok, that makes sense. I've been looking through the documentation online, and just haven't been able to find it listed. I'm using ca65 btw.

Thanks for your help!

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
PostPosted: Wed Sep 05, 2018 6:34 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3634
Location: Mountain View, CA
The documentation for this feature in ca65 is here, in two places (sort of):

Expressions: https://www.cc65.org/doc/ca65-5.html#ss5.1
Pseudo functions: https://www.cc65.org/doc/ca65-10.html

With regards to the latter, in ca65 you can alternately say this, which may make more sense to you:

Code:
  lda #.hibyte(oam)   ; same as lda #>oam
  lda #.lobyte(oam)   ; same as lda #<oam

Note that it's lobyte, not lowbyte (i.e. no "w" in "low").

The "shorthand" syntax is what a lot of assemblers have used for the past ~40 years.


Top
 Profile  
 
PostPosted: Wed Sep 05, 2018 6:36 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6886
Location: Canada
If the next line is sta #4014 (or sta OAMDMA) you might also need to know that oam has to be aligned to a single page (i.e. <oam =$00) to work properly with the DMA hardware accessed by writing the high byte of its address to $4014.


Top
 Profile  
 
PostPosted: Wed Sep 05, 2018 8:55 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10897
Location: Rio de Janeiro - Brazil
Most people use $0200-$02FF as their OAM buffer, but you can use any page of RAM (or even ROM!) for that purpose. Naming that array, as you would any other variable, allows you to access the OAM buffer by name, instead of by address, and lda #>oam will get the page number for the buffer, which can be used to start an OAM DMA.

The advantage of doing it that way is that if you ever decide to move the OAM buffer to another page, you just need to change the variable declaration, because the sprite routines and the DMA code are not using hardcoded addresses.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 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