Open main menu

CDOT Wiki β

Changes

6502 Assembly Language String Lab

357 bytes added, 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 string handling and character conversions in [[6502]] assembly language, in preparation for learning more complex x86_64 and AArch64 assembly language.}}
== Resources ==
** [[6502_Emulator#ROM_Routines|ROM Routines]] for character output
* [[6502 Emulator Example Code]] - Specifically:
** [[6502_Emulator_Example_Code#Place_a_Message_on_the_Character_Display|Place a Message on the Character Display]] - for an example of defining a graphic text using DCB, and copying a graphic writing that text to the screenwith and without the ROM routines
* Opcode/Instruction References
** [http://www.6502.org/tutorials/6502opcodes.html 6502 Opcodes with Register Definitions]
== 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 ====