====== 6502 Math Lab ====== In this lab, you will continue learning some of the basics of [[6502]] assembly language, in preparation for learning more complex x86_64 and AArch64 assembly language. ===== Resources ===== * Background knowledge * [[Computer Architecture]] basics * [[Assembly Language]] vs [[Machine Language]] * [[Assembler Basics]] * [[6502]] - Basic information about the processor * [[6502 Addressing Modes]] * [[6502 Instructions]] * [[6502 Jumps, Branches, and Procedures]] * [[6502 Math]] * [[6502 Emulator]] * Opcode/Instruction References * On this Wiki * [[6502 Instructions]] * [[6502 Addressing Modes]] * External * [[https://www.pagetable.com/c64ref/6502/?tab=2|6502 instructions via the "Ultimate Commodore 64 Reference" site]] * [[http://www.6502.org/tutorials/6502opcodes.html|6502 Opcodes with Register Definitions]] * [[https://www.masswerk.at/6502/6502_instruction_set.html|6502 Opcodes with Detailed Operation Information]] * [[https://docs.google.com/spreadsheets/d/1a1-ZZ1opY8xcuUHNxj3YW75dxOPynSuP2-QGSvZGzYY/edit?usp=sharing|Spreadsheet of bitmapped display memory locations]] ===== Lab 2 ===== ==== In-Class Lab: Mob Programming ==== //Mob Programming// is an extended form of [[https://en.wikipedia.org/wiki/Pair_programming|Pair Programming.]] Follow these steps: - You will be assigned to a Zoom breakout group. Within the group, select someone to be the initial "Driver" - the person who will be typing. - Within the group, select someone who is not driving to be the "Presenter" - the person that will present your group's results to the class. - Decide on how you're going to share the code between members of your group. This might be as simple as pasting it into the Zoom chat (Caution!), or you could use a Pastebin, e-mail attachment, or Git repository, or any other scheme that everyone agrees upon. - Have the Driver share their screen with the group. - Collaborate with the Driver using audio and/or video. In Pair or Mob Programming, most of the coding suggestions come from those observing the Driver, not the Driver themselves. - Feel free to switch the driver periodically as you see fit. - Perform the lab as outlined below. ==== Setup ==== 1. Have the Driver open the [[6502 Emulator]] at http://6502.cdot.systems in another tab or window, keeping this lab open. Important: The emulator **does not** save your work automatically. Remember to periodically save it to a file (copy-and-paste the code or use the ''Save'' button to create local files). Recommendation: save your files to a directory, and use [[https://git-scm.com/|git]] to manage that directory. ==== Initial Code ==== 2. The following code moves a graphic around the screen: ; ; draw-image-subroutine.6502 ; ; This is a routine that can place an arbitrary ; rectangular image on to the screen at given ; coordinates. ; ; Chris Tyler 2024-09-17 ; Licensed under GPLv2+ ; ; ; The subroutine is below starting at the ; label "DRAW:" ; ; Test code for our subroutine ; Moves an image diagonally across the screen ; Zero-page variables define XPOS $20 define YPOS $21 ; Set up the data structure ; The syntax # 3. Test the code by pressing the Assemble button, then the Run button. If the there are any errors assembling (compiling) the code, they will appear in the message area at the bottom of the page. Make sure the code is running correctly and that you understands how it works. Don't be afraid to experiment! ==== Bouncing Graphic ==== 4. Select a starting location for the graphic where X and Y have different values. 5. Select an X increment that is -1 or +1, and a Y increment that is -1 or +1. 6. Successively move the graphic by adding the X and Y increments to the graphic's X and Y position. 7. Make the graphic bounce when it hits the edge of the bitmapped screen, both vertically (when it hits the top/bottom) and vertically (when it hits the left/right edge). ---- **========== This is the end of the in-class portion of the lab. ==========** Continue the remaining portion of the lab on your own. ---- ==== Challenges (Optional, Recommended) ==== Try these experiments: - Permit values other than -1 and +1 for the X and Y increments. - Permit fractional values for the X and Y increments (e.g., +1.5 or -0.75) - Change the graphic each time it bounces. ==== Write-Up ==== Post an entry on your blog describing your experiments in this lab. Follow the [[Blog Guidelines]]. Include code as text (and not screenshots), but feel free to include screenshots of the bitmapped display. Include in your blog post: - An introduction, so that someone who happens across your blog will understand the context of what you're writing about. - The results from the lab, including the code, a description of how the code works, and the results produced. - The results of the Challenge section(s), if you performed them, including your code. - Your experiences with this lab -- your impressions of Assembly Language, what you learned, and your reflections on the process. Remember that labs are marked on a scale of 0-3: * 0 - Lab not completed, or significant errors. * 1 - Very basic completion, or some small errors. * **2 - Satisfactory completion of the lab.** (This is the default mark for lab completion). * 3 - Lab completed with additional experiments, investigation, research, or explanation. For example, you could do some of the optional sections in this lab, and include those in your blog writeup -- or you could create your own experiments. Remember to follow the [[Blog Guidelines]] as you write. The labs in SPO600 do not have specific due dates, but: - All labs must be completed to pass the course, and - Completing each lab will help you to understand the following topics in the course Therefore it is **strongly** recommended that you keep up with the labs. If you have partially or mostly completed the lab, write a blog post about what you've done, and you can supplement this with an additional blog post at a late date when you complete the lab -- multiple blog posts about one lab are completely acceptable.