Changes

Jump to: navigation, search

6502 Assembly Language String Lab

630 bytes added, 16:02, 3 February 2020
Techniques
== Techniques ==
* 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 operationsso that it does not affect binary math (use the SED and CLD instructions).** Decimal mode does not affect all operations -- for example, it only affects add and subtract operations (ADC) but not increment (INCand SBC).
* To indicate the cursor position, you may want to use reverse video, which is available in the [[6502 Emulator|emulator]] by ORing a printable ASCII code with $80 to turn on the high bit.
* It is recommended that you run the emulator at its highest speed (move the Speed slider to the right).
== Lab 4 ==
=== Pick Two Options ===
Pick and implement two of the following options for this lab. Requirements:* Use the emulator's [[6502_Emulator#ROM_Routines|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 it 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.
* Optional challenge: extend to more than 2 digits and add a running total capability with a clear key.
==== Option 2: Data Input Form ====
1750 Finch Ave E
Toronto ON M2J 2X5
 
* Optional challenge: validate the province/territory and the postal code format.
==== 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. Decide how the data will be returned by this subroutine.
# Using this subroutine, ask the user for a starting address and a length (in bytes), 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.
* Optional challenge: add a display of ASCII data on the right-hand side, similar to the output of the linux command <code>od -A x -t xz -v ''filename''</code>
==== Option 4: Screen Colour Selector ====
# Create a subroutine which displays on the character display a list of colours available on the bitmapped display, one colour per line, with one of the colours names highlighted in reverse video (white on black). The user may use the up/down arrow keys to change the highlighted row. Return the user's selection as a number in the accumulator (A) register when they press Enter.
# Using this subroutine, get a colour from the user, then fill the bitmap display with this colour, and allow the user to select a different colour.
* Optional challenge: update the colour on the bitmapped display as the user scrolls through the colour-selector list.
=== Write-Up ===

Navigation menu