6502 Assembly Language String Lab
- 6502 Emulator
- 6502 Emulator Example Code - Specifically:
- Place a Message on the Character Display - for an example of defining a graphic using DCB, and copying a graphic to the screen
- Opcode/Instruction References
- Binary Coded Decimal (BCD) Mode
- To convert a digit into a character, add the value of the ASCII character "0" ($30, 41). For example, $05 + $30 = $35, which is the ASCII code for the digit "5".
- Decimal (BCD) mode may be useful for some of these problems.
- To get the upper digit from a BCD byte, perform LSR four times to shift the upper four bits to the lower four bit locations and zero the upper four bits.
- To get the lower difit from a BCD byte, AND the byte with $0f.
- Remember to turn decimal mode on for operations on BCD bytes, and turn it off for other operations.
- Decimal mode does not affect all operations -- for example, it affects add (ADC) but not increment (INC).
- To indicate the cursor position, you may want to use reverse video, which is available in the emulator by ORing a printable ASCII code with $80 to turn on the high bit.
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  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).
Pick Two Options
Pick and implement two of the following options for this lab. Use the emulator's ROM routines for at least one (and possibly both) problems. In each case, make the software easy to use, with appropriate user prompts and feedback, and ensure that is looks good on the screen.
Option 1: Adding Calculator
- Create a subroutine which enables the user to enter two numbers of up to two digits. Indicate where the cursor is, and allow the user to use the digit keys (0-9), backspace, and enter keys. Return the user's input value in the accumulator (A) register.
- Using this subroutine, write a program which add the two numbers (each of which is in the range 0-99) and print the result.
Option 2: Data Input Form
- Create a subroutine which enables the user to enter a string of up to 40 characters. Decide how the data will be returned from the subroutine. The user should be able to use the left/right cursor keys backspace to edit the text, and to include any printable characters in the entered string, and the cursor location should be visible to the user.
- Write a program which uses this subroutine to collect the user's name, address, city, province, and postal code, and then display this information formatted as a shipping address (for example, as shown below).
Your order will be delivered to: J. Doe 1750 Finch Ave E Toronto ON M2J 2X5
Option 3: Hexdump
- Create a subroutine which enables the user to enter a 4-digit hexadecimal value. Allow the use of the backspace key for editing, and show the user the cursor location.
- Using this subroutine, ask the user for a starting address and length, and then output a hexdump of the specified memory locations, formatted to show address and data information in some layout. If the output is longer than the screen, pause for user input (e.g., "Press ENTER to continue" or something similar) every 20 lines.
Option 4: Screen Colour Selector
- Create a subroutine which displays on the character display a list of colours available on the bitmapped display, with one of the colours highlighted in reverse video (white on black). The user may use the up/down arrow keys change the highlighted row. Return the user's selection as a number in the accumulator (A) register.
- Using this subroutine, get a colour from the user, then fill the bitmap display with this colour.
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) and ensure that you are in compliance with the licenses of any code snippets used.
- 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.