Assembly Language Programming by James and Jarrod Parkes Abstract
Total Page:16
File Type:pdf, Size:1020Kb
Technical Course Curriculum and Annotated Bibliography CS308: Assembly Language Programming By James and Jarrod Parkes Abstract At the University of Alabama in Huntsville, the Computer Science (CS) Department is facing a decreased student interest in their CS 308 assembly language course. As a result, this new course curriculum and annotated bibliography have been created to restore excitement into the program. Since today's students are seeking innovative applications for programming, this curriculum teaches the 6502 assembly language with a focus on the Nintendo Entertainment System (NES)--a vintage video game console. While linearly covering the required assembly language material, this curriculum incorporates interactive examples from classic NES titles such as Super Mario and The Legend of Zelda. With this curriculum, CS professors are also given the tools to guiding students through the development of their very own NES video games. By the end of the curriculum, professors will be fully equipped to teach the 6502 assembly language while providing students the rewarding experience of game development. Additionally, the annotated bibliography includes supplementary texts and online articles to help reinforce topics for professors and students. Source: Google Images ii Table of Contents Introduction to the Assembly Language Course....................................................... 1! What is an Assembly Language? .................................................................................. 1! How is this Course Structured?.................................................................................... 2! Chapter 1 – The Class Project......................................................................................... 3! 1.1 – Requirements ......................................................................................................... 3! 1.2 – Deliverables ............................................................................................................ 4! Chapter 2 – Number Systems and Data Representation.......................................... 5! 2.1 – The Binary Number System................................................................................. 5! 2.2 – Data Representation ............................................................................................. 5! 2.3 – Converting Data..................................................................................................... 6! 2.4 – Example Problems ................................................................................................. 8! Chapter 3 – The 6502 Instruction Set.........................................................................10! 3.1 – Registers and Addresses....................................................................................10! 3.2 – Arithmetic Instructions......................................................................................11! 3.3 – Logical Operators and Comparison Instructions..........................................11! 3.4 – Jumps, Branches, and Flags...............................................................................13! 3.5 – Shifts and Rotates ...............................................................................................14! 3.6 – 6502 Instructions Set Wallpaper ......................................................................15! 3.7 – Example Problems ...............................................................................................17! Chapter 4 – Assemblers and Related Tools ..............................................................18! 4.1 – Source Code Editor: Notepad++........................................................................18! 4.2 – Assembler: NES Assembler................................................................................18! 4.3 – Graphics Editor: Graphics Gale.........................................................................20! 4.4 – Graphics Viewer: NES Screen Tool ...................................................................21! 4.5 – Example Problems ...............................................................................................22! Chapter 5 – NES Hardware Basics................................................................................23! 5.1 – NES CPU .................................................................................................................23! 5.2 – NES PPU..................................................................................................................24! 5.3 – Vertical Blanking..................................................................................................24! 5.4 – Pattern Tables ......................................................................................................25! 5.5 – Attribute Tables...................................................................................................26! 5.6 – Palettes ..................................................................................................................26! 5.7 – NES APU.................................................................................................................26! 5.8 – Example Problems ...............................................................................................27! Chapter 6 – The Game Loop ..........................................................................................28! 6.1 – Game Loop Structure..........................................................................................28! 6.2 – Optimizations.......................................................................................................29! 6.3 – Closing Remarks..................................................................................................29! 6.4 – Example Problems ...............................................................................................29! Annotated Bibliography .................................................................................................30! iii List of Illustrations Introduction to the Assembly Language Course ......................................................1 Figure 0.1 – Funny Computer Comic ..........................................................................2 Chapter 1 – The Class Project ........................................................................................3 Figure 1.1 – Battle Kid Box Art .....................................................................................4 Figure 1.2 – Battle Kid Instruction Manual ................................................................4 Figure 1.3 – Battle Kid Title Screen ............................................................................. 4 Table 1.4 – Class Project Deliverables ........................................................................4 Chapter 2 – Number Systems and Data Representation .........................................5 Figure 2.1 – Traffic Light Binary Numbers ................................................................5 Figure 2.2 – How the NES Graphics Processor creates Color Palettes .................6 Figure 2.3 – Weight Decimal Notation for Base-10 ..................................................7 Figure 2.4 – Weight Decimal Notation for Base-2 and Base-16 .............................7 Table 2.5 – Binary, Decimal, and Hexadecimal Numbers .......................................8 Chapter 3 – The 6502 Instructions Set ......................................................................10 Table 3.1 – Register Transfer, Load, and Store Instructions ...............................10 Figure 3.2 – The Legend of Zelda Health Paradigm .............................................. 12 Figure 3.3 – NES Controller with Button Layout .................................................... 12 Figure 3.4 – NES Rotate Instruction ..........................................................................15 Figure 3.5 – Nintendo 6502 Assembly Instruction Set Quick Reference ..........16 Chapter 4 – Assemblers and Related Tools .............................................................18 Figure 4.1 – Batch Process (double-click file to execute) ..................................... 19 Figure 4.2 – Compile from Command Line .............................................................20 Figure 4.3 – Character Sprite Animation ................................................................. 21 Figure 4.4 – NES Screen Tool ......................................................................................21 Chapter 5 – NES Hardware Basics ...............................................................................23 Figure 5.1 – NES CPU Memory Map ...........................................................................23 Figure 5.2 – NES PPU Memory Map ........................................................................... 24 Figure 5.3 – Dragon Warrior Pattern Table ............................................................. 25 Figure 5.4 – NES Global Palette ..................................................................................26 Chapter 6 – The Game Loop .........................................................................................28 Annotated Bibliography ................................................................................................30 iv Page%1% Introduction to the Assembly Language Course In the last half-century, programming experience in high-level languages—like C/C++, Java, and Python—has eclipsed all other basic requirements