It is currently Mon Oct 16, 2017 5:49 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon Dec 26, 2016 8:04 pm 
Offline

Joined: Mon Dec 26, 2016 7:45 pm
Posts: 2
Hey guys, I'm somewhat new to SNES assembly language. I've been reading through the articles on superfamicom and most of it is making pretty decent sense, at least as much as it should after a week or so of studying it. Anyway, I'm attempting to write some simple game logic but for whatever reason I seem to be stuck on finding open registers I can use. It seems like everything is being used by something like OAM or DMA.

My question is how am I supposed to find registers I can store any values I need to remember? Do I just pick registers and see if it screws anything up? I saw some of the memory maps on superfamicom but they don't make a whole lot of sense to me.

Sorry to bother you guys with such a simple question haha. Thanks in advance


Top
 Profile  
 
PostPosted: Mon Dec 26, 2016 8:32 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19083
Location: NE Indiana, USA (NTSC)
Memory at $7E0000-$7FFFFF is free for your use. Additionally, $7E0000-$7E1FFF is mirrored into $0000-$1FFF of banks $00 through $3F and $80 through $BF, so that you can use it as direct page and stack.

Have you programmed for any other 65816-based platform, such as the Apple IIGS?


Top
 Profile  
 
PostPosted: Mon Dec 26, 2016 8:41 pm 
Offline

Joined: Mon Dec 26, 2016 7:45 pm
Posts: 2
Oh gotcha, thanks! Sadly no... This is actually the only project I've ever attempted for any kind of assembly language. I've read that 65816 isn't the best place to start, but I find it interesting so I'm trying my hand at it.


Top
 Profile  
 
PostPosted: Mon Dec 26, 2016 9:20 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1768
Location: DIGDUG
Quote:
open registers I can use. It seems like everything is being used by something like OAM or DMA.


Just so you are clear...'registers' at $2100-421f are hardware registers and not processor registers.

65816 has 3 ...16-bit registers, called A,X,Y. Only A can do math and bit shifts/ AND/OR. Therefore, I only consider A to be the general purpose register.

X and Y are typically used for indexing an array, or dereferencing a pointer, or counting loops. They can also be used for finding variables pushed onto the stack with stack relative addressing.

Like tepples said, use the direct page as temporary holders of values. (Or perhaps the stack).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Dec 27, 2016 1:17 pm 
Offline

Joined: Mon Jul 02, 2012 7:46 am
Posts: 759
Yeah, there really aren't any GPR's, at least not like what you'd see on other architectures. You have the accumulator, the two index registers, and that's pretty much it. It's designed with external memory in mind, which is why you'll see so many instructions with several different addressing variants for operands. Typically the reason for using GPR's is for faster operation, and you can achieve that result using direct-page memory as others have mentioned. A lot of games will use bytes $00-0F in the direct page as local scratchpad, much the same as you would typically use GPR's on other architectures like MIPS (the s/t registers there are a godsend...). Check the superfamicom wiki opcode page, they list the cycle count for all of the opcodes, which should help you figure out how to set up your code to use the faster addressing modes.


Top
 Profile  
 
PostPosted: Tue Dec 27, 2016 9:12 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3470
Location: Indianapolis
If it helps too, you can find tons of docs, tutorials, simulators, and books for 6502 because that CPU was everywhere. The 65816 is 100% backwards-compatible with the 6502. So that could be a useful way to start out with the basics.


Top
 Profile  
 
PostPosted: Wed Dec 28, 2016 12:52 am 
Offline

Joined: Fri Jul 04, 2014 9:31 pm
Posts: 781
There are a few differences between the 65816 in emulation mode and the 6502. This includes a couple of bugfixes, but the main difference is that the 6502's unimplemented opcodes (which did unintended but occasionally useful stuff) are now in use as 65816 opcodes and thus do totally different things.

It is claimed that
Eyes and Lichty (1986) wrote:
All existing 6502 software can be run by the new processor

but this seems to be weighted with the implication that a 6502 program using illegal opcodes isn't really a 6502 program...


Top
 Profile  
 
PostPosted: Wed Dec 28, 2016 3:59 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
65816 emulation mode operates more like 65c02 than 6502. OP: do not get hung up on this part of the thread conversation.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot], lazigamer 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