1,885
edits
Changes
Created page with "Category:SPO600 Labs{{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 c..."
[[Category:SPO600 Labs]]{{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 ==
* [[6502]]
* [[6502 Emulator]]
* [[6502 Emulator Example Code]] - Specifically:
** [[6502_Emulator_Example_Code#Place_a_Graphic_on_the_Screen|Place a Graphic on the Screen]] - for an example of defining a graphic using DCB, and copying a graphic to the screen
** [[6502_Emulator_Example_Code#Etch-a-Sketchtm_Style_Drawing|Etch-a-Sketch Style Drawing]] - for an example of converting (ROW,COL) co-ordinates to a screen address, and reading the keyboard
* Opcode/Instruction References
** [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]
== Lab 2 ==
=== Setup ===
1. Organize a group of 4-6 students around one of the monitor/whiteboard groups in the classroom. Arrange the furniture so that everyone has a comfortable view of the display.
2. Gather these supplies:
* HDMI cable
* Whiteboard markers
3. 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 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).}}
{{Admon/important|Save Your Work|The emulator '''does not''' save your work. Remember to periodically save it to a file (copy-and-paste the code).}}
=== Pick an Option ===
4. Select and complete one of these options for this lab:
==== Option I: 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.
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 bitmapped font patterns for the digits 0-9 on an 8x8 pixel matrix.
# Encode the font patterns for these characters using DCB (declare constant byte) instructions.
# 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.
Challenge: extend the code to play a game similar to [https://en.wikipedia.org/wiki/Breakout_(video_game) Breakout].
==== Option 4: Kaleidoscope ====
# Create code that permits the user to draw pixels on one-quarter of the screen in any of several different colours (for example, the user might position a cursor with the arrow keys and colour a pixel with the a digit from 0-9 which would select the colour for that pixel).
# Mirror the pixel to the other three quadrants of the screen like a kaleidoscope. For example, a pixel drawn at (0,0) should be mirrored to (31,31), (0,31), and (31,0); if a pixel is drawn at (2,10) is should be mirrored to (29,10), (2,21), and (29,21)
Challenge: replay the drawing of the image, i.e., when a key is pressed, the screen is cleared and the pixels are redrawn to the screen in the order in which they were originally added by the user, with the kaleidoscope effect, as an animation.
==== Option 5: Line draw ====
{{Admon/tip|Division|This option typically requires division arithmetic!}}
# Create code that has two pixel-sized cursors, moved by two separate sets of keys (e.g., cursor keys for one cursor, and a/w/s/z for the other cursor).
# Draw a line between the cursors which moves whenever one of the cursors is moved.
Challenge: extend the code to allow a line to be dropped onto the screen, i.e., it will be left behind while the cursors are moved to new locations.
== Write-Up ==
Post an entry on your blog describing your experiments in this lab. Include:
# An introduction, so that someone who happens across your blog will understand the context of what you're writing about.
# The results from the two ''Writing Code'' portions of the lab, including the code, a description of how the code works, and the results produced. Credit other sources appropriately (i.e., font/graphics data, code snippets).
# Your experiences with this lab -- your impressions of the Assembly Language, what you learned, and your reflections of the process.
Remember to follow the [[Blog Guidelines]] as you write.
== Resources ==
* [[6502]]
* [[6502 Emulator]]
* [[6502 Emulator Example Code]] - Specifically:
** [[6502_Emulator_Example_Code#Place_a_Graphic_on_the_Screen|Place a Graphic on the Screen]] - for an example of defining a graphic using DCB, and copying a graphic to the screen
** [[6502_Emulator_Example_Code#Etch-a-Sketchtm_Style_Drawing|Etch-a-Sketch Style Drawing]] - for an example of converting (ROW,COL) co-ordinates to a screen address, and reading the keyboard
* Opcode/Instruction References
** [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]
== Lab 2 ==
=== Setup ===
1. Organize a group of 4-6 students around one of the monitor/whiteboard groups in the classroom. Arrange the furniture so that everyone has a comfortable view of the display.
2. Gather these supplies:
* HDMI cable
* Whiteboard markers
3. 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 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).}}
{{Admon/important|Save Your Work|The emulator '''does not''' save your work. Remember to periodically save it to a file (copy-and-paste the code).}}
=== Pick an Option ===
4. Select and complete one of these options for this lab:
==== Option I: 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.
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 bitmapped font patterns for the digits 0-9 on an 8x8 pixel matrix.
# Encode the font patterns for these characters using DCB (declare constant byte) instructions.
# 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.
Challenge: extend the code to play a game similar to [https://en.wikipedia.org/wiki/Breakout_(video_game) Breakout].
==== Option 4: Kaleidoscope ====
# Create code that permits the user to draw pixels on one-quarter of the screen in any of several different colours (for example, the user might position a cursor with the arrow keys and colour a pixel with the a digit from 0-9 which would select the colour for that pixel).
# Mirror the pixel to the other three quadrants of the screen like a kaleidoscope. For example, a pixel drawn at (0,0) should be mirrored to (31,31), (0,31), and (31,0); if a pixel is drawn at (2,10) is should be mirrored to (29,10), (2,21), and (29,21)
Challenge: replay the drawing of the image, i.e., when a key is pressed, the screen is cleared and the pixels are redrawn to the screen in the order in which they were originally added by the user, with the kaleidoscope effect, as an animation.
==== Option 5: Line draw ====
{{Admon/tip|Division|This option typically requires division arithmetic!}}
# Create code that has two pixel-sized cursors, moved by two separate sets of keys (e.g., cursor keys for one cursor, and a/w/s/z for the other cursor).
# Draw a line between the cursors which moves whenever one of the cursors is moved.
Challenge: extend the code to allow a line to be dropped onto the screen, i.e., it will be left behind while the cursors are moved to new locations.
== Write-Up ==
Post an entry on your blog describing your experiments in this lab. Include:
# An introduction, so that someone who happens across your blog will understand the context of what you're writing about.
# The results from the two ''Writing Code'' portions of the lab, including the code, a description of how the code works, and the results produced. Credit other sources appropriately (i.e., font/graphics data, code snippets).
# Your experiences with this lab -- your impressions of the Assembly Language, what you learned, and your reflections of the process.
Remember to follow the [[Blog Guidelines]] as you write.