Saturday 24 October 2009

Assembly Language Programming



So last week in Console Development we began looking at some assembly code for the games based on whatever consoles we had opened up in the first week of the module, which in my case was the NES.

I must say looking at some assembly code for the very first time was pretty daunting. I found it really difficult to make little sense from any of the code in the files that I had read. Unfortunately non of the assembly source I obtained was official Nintendo assembly code, however it would seem there are quite a few NES development hobbyists out there. Thanks to them I was able to take a look at some assembly code for the NES. The below is some example assembly for the 6502 processor..

lda #$3F sta $2006 lda #$00 sta $2006 lda #$21 ;background [powder blue] sta $2007 lda #$30 ;cloud inside [white] sta $2007 lda #$11 ; highlight [blue] sta $2007 lda #$0d ;outline [black] sta $2007 lda #DELAYSCROLL sta $21 lda #NTShow sta $22 lda #SCROLL sta $24

The above apparently loads up some colour values in memory. The assembly code was programmed by Cory Arcangel whom had hacked a Mario Brothers NES cartridge, you can check it out at http://www.21cmagazine.com/issue2/cory_clouds.html

This week and the last had also been spent learning and researching the MIPS assembly programming language! For you that haven't met MIPS assembly yet..



What? Yes well to begin with MIPS assembly doesn't seem very friendly and it's syntax is very alien. However after giving a little time and effort over the past week in learning MIPS assembly, I found it easier to understand and the syntax less alien. I have provided some of my MIPS assembly code I've done this week with comments on each line of code to roughly describe what's going on (it's pretty trivial). If you have any trouble viewing the code it's probably because the image has been resized, simply click on the picture to get a larger view.


Here are the values in there designated registers after the program had finished executing..





No comments:

Post a Comment