Open main menu

CDOT Wiki β

Changes

6502 Assembly Language Math Lab

272 bytes removed, 12:32, 28 January 2022
no edit summary
[[Category:SPO600 Labs- Retired]]{{Admon/important|This lab is not used in the current semester.|Please refer to the other labs in the [[:Category:SPO600 Labs|SPO600 Labs]] category.}} {{Admon/lab|Purpose of this Lab|In this lab, you will write code with arithmetic/math in [[6502]] assembly language, in preparation for learning more complex x86_64 and AArch64 assembly language.}}
== Resources ==
** The last key pressed is stored in memory location $FF. Clear this location (to 0) after reading it. Printable characters, ENTER, and Backspace are represented by their ASCII codes; the arrow keys are represented by the codes $80-$83 (up/right/down/left).
* Random number generatorFixed-pointA fixed-point value is encoded the same as an integer, except that some of the bits are fractional -- they're considered to be to the right of the "binary point" (binary version of "decimal point" - or more generically, the radix point). For example, binary 000001.00 is decimal 1.0, and 000001.11 is decimal 1.75.An alternative to fixed-point values is integer values in a smaller unit of measurement. For example, some accounting software may use integer values representing cents. For input and display purposes, dollar and cent values are converted to/from cent values.generator
** A random byte is available at memory location $FE.
* Drawing a Line
** To draw a line between two arbitrary points (X<sub>1</sub>,Y<sub>1</sub>)(X<sub>2</sub>,Y<sub>2</sub>) where X<sub>2</sub>-X<sub>1</sub> > Y<sub>2</sub>-Y<sub>1</sub> and all coordinates are positive, calculate the rise/run, then set Y=Y<sub>1</sub> and iterate for X=X<sub>1</sub>:X<sub>2</sub> incrementing Y by the rise/run each step.
** Do something similar with run/rise where X<sub>2</sub>-X<sub>1</sub> < Y<sub>2</sub>-Y<sub>1</sub>
** Suggestion: Use fixed-point math for the rise/run (aka deltaY) value.
=== Setup ===
1. Organize a group of 4-6 students around one of Join the monitor/whiteboard groups in the classroom. Arrange the furniture so that everyone has a comfortable view of the display. 2assigned Breakout Room. Gather these supplies:* HDMI cable* Whiteboard markers
32. Select one person to be the "Driver", who will type/operate the computer for the group. That person should connect a device (laptop, table) to the HDMI display will share their screen and open the [[6502 Emulator]] at [http://6502.cdot.systems] as well as this Lab page. It's a good idea to ensure that the Speed slider on the emulator is at its lowest setting (left) and that the Text Screen is turned off (unchecked).
{{Admon/tip|Sharing Results|Decide how group results will be shared between the members of the group. (Suggestion: consider using a git repository).}}
=== Pick an Option ===
43. Select and complete one of these options for this lab:
==== Option I1: Bouncing Graphic ====
# Create a simple graphic in a square that is 5x5 or 7x7 pixels in size. Use the colours available in the emulator's bitmapped display. The graphic could be a ball, a happy face, a logo, an emoji, or anything else (appropriate!) that you want to use.
# Encode that graphic in bytes using DCB (declare constant byte) instructions.
# Write code to make the graphic bounce around the screen, reflecting off the edges when it hits. Note: for simplicity, it is OK if the object always bounces at 45-degree angles.
# Make the speed keyboard-adjustable (faster/slower) and perturb the object's path once in a while(add a glitch - adjust the angle or nudge the obect by a pixel at random intervals).
Challenge: randomize the starting position, and make the object bounce at angles other than 45 degrees.
==== Option 2: Numeric Display ====
# Create or find (under an appropriate license) the Obtain bitmapped font patterns for the digits 0-9 on an 8x8 pixel matrix.:#* Use [[8x8 Bitmap Patterns for Digits|pre-defined bitmap patterns]], or#* Find alternate patterns on the web, or#* Design your own font patterns# Encode the font patterns for these characters using DCB (declare constant byte) instructionsdirectives.
# Write code to display a 2-digit unsigned decimal number (0-99). The + and - keys should increment and decrement this number.
Challenge: extend the code to suppress leading zeros and display a signed number (-99 to +99).
==== Option 3: Pong ====
# Create a single-user version of the classic [https://en.wikipedia.org/wiki/Pong Pong] game: one paddle, controlled by the keyboard, and one single-pixel ball that bounces off the paddle plus the three sides of the screen not guarded by the paddle. The game is over if the ball hits the fourth side of the screen. (The screen may optionally have lines drawn on the three sides on which the ball bounces).
Challenge: extend the code to play a game similar to [https://en.wikipedia.org/wiki/Breakout_(video_game) Breakout].; or, add a display of the score as a digit, with the game ending when five balls have been missed
==== Option 4: Kaleidoscope ====