Working on ASM Tutorials! (Episode 4 out now!)

chronosv2

New member
Since Joe and the others are working on making NESMaker a better system for everyone and therefore don't have the time to make some Assembly Language tutorials, I'm working on some content from a beginner's perspective looking specifically at ASM in NESMaker.

By the time I'm done people should be able to read and write ASM, and apply it to NESMaker.
The code might not be efficient but as people learn more in their own next steps it'll get there.

I'm doing it both as a service to the community for being incredible and as a way to strengthen my own knowledge, because I'm having to get reference information for everything I cover.
Currently in the planning/presentation building phase but I'm hoping at least the first few "episodes" are ready sometime next week. I'd have them out this weekend but my schedule doesn't allow for it.

One thing I plan on trying to spend a decent amount of time on are conditions and binary, something I know at least one user has struggled with.

Anyway, just thought I'd let people know what I've got coming down the pipeline. If there's anything in particular people would like me to try and cover, I'll look at it and see what I can do!

Videos so Far (and progress on upcoming videos)
Video 1: https://youtu.be/7RIfN0u6iFE
Video 2: https://youtu.be/gC5UI2k7nI8 *
Video 3: https://youtu.be/ssDbe9QEh20 *
Video 4: https://youtu.be/WliAdpSAHfo * - In the original version of this video there was a major error in the Division code I shared. The slide has been altered to redirect to the post here with a correct version.
Video 5: Will begin working on this after 4.1.0 comes out!

And for episodes with Challenges at the end (marked with an asterisk) you can give the challenges a try at
https://chronosv2.github.io/nm6502/
 

chronosv2

New member
I'm glad I can try and contribute more to this awesome community. I've finally found a group of people outside of my normal circles I can nerd out about coding stuff and darn it I want to contribute as much as I can.
 

Mihoshi20

Member
I like this idea a lot. A few topics to cover would of course be the commonly used opcodes and ways they are used, the difference between $00 and #$00, some simple logic gates like BCS and BEQ along with jumps like JMP and JSR, and some beginner terminology explanations like absolute, accumulator, immediate, indirect, and addressing mode. Before diving directly into breaking down and stepping through 6502 assembly and specific functions of the NES implementation like the reset routine and input handling.
 

chronosv2

New member
Mihoshi20 said:
I like this idea a lot. A few topics to cover would of course be the commonly used opcodes and ways they are used, the difference between $00 and #$00, some simple logic gates like BCS and BEQ along with jumps like JMP and JSR, and some beginner terminology explanations like absolute, accumulator, immediate, indirect, and addressing mode. Before diving directly into breaking down and stepping through 6502 assembly and specific functions of the NES implementation like the reset routine and input handling.

I'm going to try and cover as much as I can, especially the terminology. The only thing in that list...
Well, Indirect Addressing kinda' baffles me. I'm looking at that and going "How would you even use that?"
Once I eventually start covering advanced stuff I'll probably touch on that.
Haha.

I'll be going over the basics of the processor in Part 1.
But yeah, I'll be tearing into some existing code for Part 2.
We'll probably do something for input and sprite drawing in Part 3.
 

Mihoshi20

Member
chronosv2 said:
Mihoshi20 said:
I like this idea a lot. A few topics to cover would of course be the commonly used opcodes and ways they are used, the difference between $00 and #$00, some simple logic gates like BCS and BEQ along with jumps like JMP and JSR, and some beginner terminology explanations like absolute, accumulator, immediate, indirect, and addressing mode. Before diving directly into breaking down and stepping through 6502 assembly and specific functions of the NES implementation like the reset routine and input handling.

I'm going to try and cover as much as I can, especially the terminology. The only thing in that list...
Well, Indirect Addressing kinda' baffles me. I'm looking at that and going "How would you even use that?"
Once I eventually start covering advanced stuff I'll probably touch on that.
Haha.

I'll be going over the basics of the processor in Part 1.
But yeah, I'll be tearing into some existing code for Part 2.
We'll probably do something for input and sprite drawing in Part 3.

Sounds like a good plan to me. Very much looking forward to it as I'm still pretty much an assembly noob and know there's a lot I could benefit from a good tutorial. I learn more and more the deeper into the rabbit hole I go but some things I just can't seem to wrap my head around so we all can benefit from any helping hand we can get.
 

chronosv2

New member
And here we go!
The first two are up. Please view them in order.

I'm really sorry for how much I stumble over my words. I'm not very good at speaking, so I slip up way more than I'm happy with... but I restarted part 1 15 times. I had to tell myself just to get it done or I'd have never published them. If the spoken stuff is too distracting or confusing, you can get the raw presentations in the video descriptions.

Video 1: https://youtu.be/7RIfN0u6iFE
Video 2: https://youtu.be/gC5UI2k7nI8
 

Rob Burrito

New member
seems to work on the easy 6502, any comments welcome! thanks for the tutorials and challenge

Code:
addMagic:
start:
	LDA $0100   ;load magic variable location 
	CLC   ;prep for addition
	ADC #$03   ;add to variable
	CMP #$19   ;check for max value
	BCS end   ;exceeding max value jump to end
	STA $0100   ;store increased value in variable address
	JMP start   ;repeat function 
end: 
	LDA #$19   ;resets values over max to the max 25
	BRK   ;finish
 

chronosv2

New member
Rob Burrito said:
seems to work on the easy 6502, any comments welcome! thanks for the tutorials and challenge

Code:
addMagic:
start:
	LDA $0100   ;load magic variable location 
	CLC   ;prep for addition
	ADC #$03   ;add to variable
	CMP #$19   ;check for max value
	BCS end   ;exceeding max value jump to end
	STA $0100   ;store increased value in variable address
	JMP start   ;repeat function 
end: 
	LDA #$19   ;resets values over max to the max 25
	BRK   ;finish

It seems to loop rather than increase each time you hit Run, but that result is really close!
It does show the process if you use the debugger and step through the code. Wasn't sure if people were going to do that so I didn't ask people to.
In the future, though, if I'm asking you all to use easy 6502 I try to post a template to save everyone a little work.

As for the result: I noticed one issue, but it's really easy to fix.
Code:
end: 
	LDA #$19   ;resets values over max to the max 25
	STA $0100 ;or STA myMagic using the template        <-- Remember to store the number, else the next LDA will replace the #$19
	BRK   ;finish
[/code]
The result of the final step was never saved to myMagic. As said though, I could see that being easy to overlook.
 

Rob Burrito

New member
thanks for the reply! definitely missed that last store if it was max routine good eye. yeah i'm used to the debugger so just wanted to show it worked when it hit 25 as a max, so i looped it haha. worked through the easy6502 already and still couldn't write anything useful for NESmaker, so more insight is really appreciated! had no idea what 6502 was till i got the beta, no programming background either. this time added the 'myMagic' address definition and used it as the reference. to show the limit i just stored a starting value that would run the max routine here, comments again welcomed:

Code:
define myMagic $0100
	LDX #$17   ;a starting number that is within 3 of the max to test branch
	STX myMagic   ; store number near limit as magic variable
addMagic:
start:
	LDA myMagic   ;load magic variable location 
	CLC   ;prep for addition
	ADC #$03   ;add to variable
	CMP #$19   ;check for max value
	BCS max   ;exceeding max value jump to max
	STA myMagic   ;store increased value in variable address
	JMP end  ; end 
max: 
	LDA #$19   ;resets values over max to the max 25
	STA myMagic   ;stores the limited value in magic variable address   
end:
	BRK   ;finish
 

chronosv2

New member
The NESMaker specific stuff will be coming eventually, but a lot of things are going to change in 4.1.0 (coming soon) so I don't want to cover topics that could very well change.
So I decided it'd be better to start with the processor itself, then build into a little basic math and basic decision making.
Next up will be more conditional statements, a little more math, simple multiplication and division... and then when 4.1.0 hits I'll look at what's changed and make tutorials tailored to it. :)
 

chronosv2

New member
And there we go! Enough people seemed to be confused about this that I adapted a fix.
Adapted skilldrick's 6502 ASM Javascript Simulator for non-NESMaker challenges! :D
https://chronosv2.github.io/nm6502/

Each challenge will be listed there, along with a template already filled out so people don't have to figure out the looping or multiple running code, and even better (for me) it's really easy to add new pages for new challenges so it never gets tedious and is easy for me to keep up with.
Now I just need to figure out what the best way to direct people to it in YouTube videos is... I'm not a partner so I can't use Cards to link to external websites. So I guess just the first line under each video...?
 

dale_coop

Moderator
Staff member
Yeah, great ep 2!
The one was too much... theorical, scholar for my taste (but I understand, it is needed... to understand the next ones)
Thanks for yoyr hard work, chronosv2
 

chronosv2

New member
Thank you all for the compliments! Working on the third part now.

dale_coop said:
Yeah, great ep 2!
The one was too much... theorical, scholar for my taste (but I understand, it is needed... to understand the next ones)
Thanks for yoyr hard work, chronosv2

Yeah, I can understand not being fond of the approach in these early episodes. The reason I took that route is because a lot of things may be changing in NESMaker and I don't want to risk teaching someone something only for it to be different in the latest version. So I'm staying generic and working on the building blocks that people will always need so that when the time comes for people to branch off I haven't left any massive holes in the basics.

Basically, tutorials designed so that even an absolute beginner, maybe even never written a line of code in their life, could watch and understand them.
I'll actually start showing how to do things in a code editor once we have the new changes.
 

chronosv2

New member
Rob Burrito said:
thanks for the reply! definitely missed that last store if it was max routine good eye. yeah i'm used to the debugger so just wanted to show it worked when it hit 25 as a max, so i looped it haha. worked through the easy6502 already and still couldn't write anything useful for NESmaker, so more insight is really appreciated! had no idea what 6502 was till i got the beta, no programming background either. this time added the 'myMagic' address definition and used it as the reference. to show the limit i just stored a starting value that would run the max routine here, comments again welcomed:

Code:
define myMagic $0100
	LDX #$17   ;a starting number that is within 3 of the max to test branch
	STX myMagic   ; store number near limit as magic variable
addMagic:
start:
	LDA myMagic   ;load magic variable location 
	CLC   ;prep for addition
	ADC #$03   ;add to variable
	CMP #$19   ;check for max value
	BCS max   ;exceeding max value jump to max
	STA myMagic   ;store increased value in variable address
	JMP end  ; end 
max: 
	LDA #$19   ;resets values over max to the max 25
	STA myMagic   ;stores the limited value in magic variable address   
end:
	BRK   ;finish

That code again works. I never explained "from #$00", and you clearly showed the first time that you understand the addition part of the challenge.
In the future all the challenges will be run through a version of the simulator I've got running on my own page so I can put in all the template code and people just have to fill in the blank with the challenge answer. :)
Less work for you, and takes out the guesswork on what I'm looking for.

The way I actually coded the template is that once you assemble your code every time you hit Run you can watch the myMagic memory address go up by 3, then cap out at $19 when you get that high.
I apparently did a terrible job of telling people where they could get the template and how to use it though, so I've taken steps to fix that. Still no idea how I'm going to make it easy for people to get to... I've got an idea of something I could do though.
 
Top Bottom