Day 1: I started the "Easy 6502" tutorial
Writing my very first assembly program
Thank you for tuning in, my dear new reader. ^-^
Firstly as a short introduction, I am not a developer by trade. I appreciate the art of writing software a ton, but my only programming experience has been with the nice and easy to use GameMaker. This time however, I’m curious about approaching it from the complete opposite end.
I challenge myself to learn assembly programming
Just for fun! I’ve always wondered about it! It’s like an intimidating puzzle that my brain may or may not be able to grasp. I’m curious if I can do it, and I’d like to take you along for the ride. Even if I don’t get anywhere, I hope my struggles may be interesting to you.
Being fond of the NES and SNES, and also being curious about the PC Engine, deciding on the 6502 family of processors seemed like a sensible enough choice to me.
After expressing my newfound wish, I was soon recommended the Easy 6502 tutorial. It has a built-in miniature 6502 environment, and this is what I’ll be referring to in the next days of getting started. Its rules are described like this:
$fecontains a new random byte on every instruction. Memory location
$ffcontains the ASCII code of the last key pressed.
$5ffmap to the screen pixels. Different values (
$0-$f) will draw different color pixels.
What I learned from the first tutorial section
Going in, I know that computer processors know of values, and registers to put these values into. The way the values and registers are manipulated is through instructions written as short mnemonic names in assembly language. Hardware has registers that will act on whatever you put into them, which is super enticing to me when I think of games hardware.
One of the only things I know about the 6502 is that it has an “Accumulator”, which I understood as that feature calculators have where they keep track of the previous answer, which you are then able to use for your next calculation.
In the first section of the tutorial, “Our first program”, I can see that two instructions are used:
LDA #$01 STA $0200 LDA #$05 STA $0201 LDA #$08 STA $0202
Apparently they stand for LoaD Accumulator and STore Accumulator respectively. Putting a value into a specific register seems to take these two instructions. LDA defines the value and stores it into register
A (I suppose for Accumulator), and STA defines where it is stored. I feel like I remember seeing this done on a single line when looking at other assembly code, so I wonder about that.
I never knew that values (“literal number values”) were written as
$xxxx portrays a register value.
Thanks for reading Cyanne’s Debug Room! Subscribe for free to receive new posts and support my work.
Playing with my first two instructions
The example program draws three differently colored pixels.
Once I started playing around with the values and got the hang of the screen position and color values, I couldn’t help try to draw something on the black screen. The end result is these blue beams shooting out of laser guns, I guess!
Finally, I noticed this section includes challenges.
Try changing the color of the three pixels.
Add more instructions to draw extra pixels.
Change one of the pixels to draw at the bottom-right corner (memory location
Oh, let me do that.
There you go, that’s no trouble for us now! ^-^
And that is all for today. Thank you for reading!
If my understanding is wrong on this or anything else in my posts, then please do not hesitate to correct me by posting a comment.