Jump to content
IGNORED

Argh! I don't understand anything about 6502


atari2600land

Recommended Posts

I need a programming guide for the dumbest of the dumb for 6502 programming, especially the NES. I keep reading tutorials about .org $FA or whatever and have no idea what that means. What I need is something to EXPLAIN what I'm typing and why I'm typing it. Something that tells me what all this stuff means. The only thing I've downloaded that's any help is NESticle and NESASM. I'm guessing I can type the code using Notepad and then get some program that turns my coding into a (hopefully working) NES program that I can run with NESticle. After years of doing stuff with BASIC, is there any help for me or am I just too stupid to understand this? It's all Greek to me.

 

EDIT: OK, how do I use NESASM? I'd like to try something I did, but have no clue how to do it. Do I need a batch file? Is the name of my batch file important? I tried various things and all i get is an error message every time.

Edited by atari2600land
Link to comment
Share on other sites

Stuff like .org and .include are directives and are part of the Assembler itself, not 6502 language and vary between Assmemblers.

 

You're probably best off learning to understand the language first, then worry about the specifics of the Assemblers but of course the 2 will likely be parallel events.

 

There was a link posted by carmel andrews somewhere in the 8-bit forums, with a heap of PDFs... maybe PM him and get him to post it here.

 

They were mostly Commodore related books, but 6502 specific books were in there too and will can be helpful with any such machine.

Link to comment
Share on other sites

Machine Language for Beginners

 

This is an excellent book for someone who knows BASIC pretty well and wants to start learning 6502 assembly. Give it a good read-through and bookmark it for reference. I'd suggest giving yourself plenty of practice with assembly before trying to write a game.

Link to comment
Share on other sites

I'll second that (the copy that I have has been falling apart for years). Tho there are a few spots of bad advice...like the suggestion that you should only use branches that work off the Z and C flags and ignore the others. Once you know one type of branching, understanding the others isn't anything difficult to grasp.

Link to comment
Share on other sites

try this link to a nintendoage thread.

 

http://www.nintendoage.com/forum/messageview.cfm?catid=22&threadid=7155

 

there's a few tutorials in order there. This is where I learned the basics to Nes programing.

 

FCEUltra is a better emulator to use in testing, there's even extensions that add debuggers that let you look at specifics as they run.

 

To answer you other questions, to run NESASM, you have to have a batch file that has the command line the same as the .asm file you're writing.(not nessassarily the same name of the batch file itself. you can edit the batch file by right clicking on it and selecting edit. depending on your system it will ask you if you want to "run" it. say yes and notepad will open and show the text of the batch file. it's real simple like this

 

NESASM3 battleball.asm

pause

 

just change it to

 

NESASM3 "YOURFILE NAME".asm

pause

 

and save. Pretty sure you can just write that line in notepad and save as "yourfilename".bat and you can create a new batch file.

 

all you have to do to compile is have nesasm, the batch file, and the associated .asm files in the same folder and the compiler will run.

Link to comment
Share on other sites

Hi! I've been programming the NES for the a while, so I'll try and give you some tips.

 

IMO, to learn 6502 you need 2 things: 6502 documentation and Michal Kowalski's 6502 simulator. Read over and over the documents that were suggested to you, until something makes sense. Use the simulator to try things out. It's much easier than trying to make an actual NES ROM and debugging on emulators.

 

By the way, please don't ever use Nesticle again, it's so old and inaccurate that the chances that a program tested with it will not work on actual hardware are very high, and what good is a program if it doesn't run on the target machine? Nestopia and Nintendulator are the most accurate emulators, and FCEUXD has great debugging features (Nintendulator has some as well), so I advise you to use those 3 emulators instead. If your program works on all of them, chances are it will work on hardware.

 

Anyway, with the simulator you can make any 6502 program you'd like. Since it just simulates the CPU, you don't have a fancy screen to display stuff, so you have to watch the memory and the registers as they change to make sure your program behaves as expected. The most useful debugging features it has are the memory window and the registers window. You can execute your programs instruction by instruction and watch in real time how they affect registers and memory. This was priceless for me back when I was first learning ASM. Whenever I wasn't sure how an instruction worked I'd write short programs with it and observe it's behavior.

 

Here is something very simple you can try on the simulator (just ask for a new document and paste this - including the TABs, the simulator is picky about them):

 

	.org $8000

clc
lda #$01
adc #$02

After pasting this, hit F7 to assemble and then F6 to debug (you can also click the buttons at the top instead of using the keys). A bunch of windows will show up, but you'll only need the registers window for now, so you can close the others. Hitting F11 will execute a single instruction, and you can see how each one affects the registers. F5 will run the whole program, and in this case you will only be able to see the final outcome. This program just puts the value "1" in the accumulator and then adds "2" to it. When the program ends you'll see that the accumulator holds the correct result, "3".

 

The only thing the simulator requires is an ".org" statement before the instructions, so that it knows where in memory to place your assembled code. I used address $8000 because that's where NES programs usually start. After that you can start writing programs. Variables can be placed before the ".org" statement, once you start using them. Try different programs using the instructions you think you understand, just to make sure you really got them. Once you understand the individual instructions, try to make some more complex operations, such as multiplying numbers and things like that. Experiment with loops, conditional statements and things like that.

 

When you are able to make small programs that make sense, then it's time to look into creating an actual NES program. Then you'll need an actual assembler (I don't like NESASM much, I prefer ASM6 - I even use it for Atari 2600 programs). You'll also need to study the PPU in order to display something with the NES, but it will be much easier to understand the PPU once you know assembly.

 

One last thing: it's probably OK to ask questions here, but if your focus is really the NES, you might have a better chance asking questions at the NESDEV Forums. People over there are usually very helpful.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...