User Tools

Site Tools


spo600:6502_program_lab
You were redirected here from spo600:6502_math_and_strings_lab.

6502 Program Lab

In this lab, you will write code with arithmetic/math and strings in 6502 assembly language, including text output, graphical output, and keyboard input, in preparation for learning more complex x86_64 and AArch64 assembly language.

Resources

Tips and Techniques

  • Keyboard
  • Random number generator
    • A random byte is available at memory location $FE.
  • Drawing a Line
    • To draw a line between two arbitrary points (X1,Y1)(X2,Y2) where X2-X1 > Y2-Y1 and all coordinates are positive, calculate the rise/run, then set Y=Y1 and iterate for X=X1>X2 incrementing Y by the rise/run each step.
    • Do something similar with run/rise where X2-X1 < Y2-Y1
    • Suggestion: Use fixed-point math for the rise/run (aka deltaY) value.

Lab 3

Decide What to Write

For this lab, write a program that meets these criteria:

  1. Your program must work in the 6502 Emulator
  2. You must output to the character screen as well as the graphics (bitmapped) screen.
  3. You must accept user input from the keyboard in some form.
  4. You must use some arithmetic/math instructions (to add, subtract, do bitwise operations, or rotate/shift)

For example, you could write a simple game:

  • A drawing program
  • A maze
  • A number guessing game (try to guess a random number in the shortest number of tries, getting feedback of “too high” or “too low” for each wrong guess)
  • Or any other type of game…

Or a calculator/converter:

  • An adding or subtracting calculator
  • A decimal-to-binary or hexidecimal-to-decimal converter
  • A inches-and-feet to centimeter converter
  • A resistor colour band calculator
  • A program to draw bar or line graphs based on user input
  • Or any other type of calculator or converter…

Or anything else that meets the criteria above

You can interact with the user using either display. For example:

  • The main interaction could be on the graphical display, and instructions could be printed on the text display (which keys to use to move, for example); or
  • The main interaction could be on the text display, and an appropriate pattern could be shown on the bitmap display (for example, a version of hangman could display the words on the text display and the victim on the bitmapped display, or a calculator could use the text display for input and show a binary representation or a colour code on the graphical display (such as green for positive numbers, yellow for negative numbers, red for bad input)).

Tip: Keep it really simple! Assembly language is hard. Start simple, you can always add features later.

Write it!

Write the code for your selected program in the 6502 Emulator.

It can be helpful and fun to write this code with one or two other people in a live session. Acknowledge each person's input, and add your own customizations or tweaks.

Remember to save your work periodically, either by pasting the text into a file, or using the Save button. Tip: the Save/Load/Chose File buttons work really well with a directory that is managed by Git.

Acknowledge Other's Code - Feel free to incorporate other people's code into your program with their permission, but you must acknowledge the source of any incorporated code (include a link to the source(s)), identify how you attained permission to use the code (for example, if the code is distributed under an open source license, show which license applies) and clearly identify exactly which parts of the code you wrote (recommendation: colour-code your portion in the blog post).

Important: Failure to fully comply with the terms under which others have shared code with you, failure to fully acknowledge the source and license terms of all code which you incorporate from other sources, or failure to accurately identify exactly which portions of the code were written by you will be considered a violation of Seneca's Academic Integrity Policy.

You must write at least half (50%) of the code in this lab, counted by lines of code. Do not take an existing program and just make minor changes to messages or colours.

Blog it

Write up your adventures in your blog. Remember to include the source code, some narrative about how it went, perhaps a screenshot of the program running, a reflection on the experience, and some ideas for further enhancement of the program.

Ensure that your program works and is free from major bugs. Document any limitations or remaining minor bugs.

Make sure that others (including your prof!) can run you code by pasting it into the emulator or loading it from a file (e.g., public git repository or downloadable file).

Remember to follow the Blog Guidelines as you write.

Examples

For some examples of games and demos, see the Resources section above, and also take a look at the http://txt3.de/ website - which uses an earlier version of the 6502 emulator used in this course. The “Open Project” control on that page provides access to some interesting and inspiring code (check out “Skier”, for example). You can copy-and-paste any of those examples into our SPO600 6502 Emulator. Be sure to check for permission (or licensing terms) before copying any code from that site (or any other source) and incorporating it into your code.

spo600/6502_program_lab.txt · Last modified: 2024/09/24 19:31 by chris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki