COMP 228: System Hardware Summer 2021
Assignment 2
Due 23h59, June 18th, 2021
The year is 1987, you are asked to write a program to find the ROT-13 letter substitution cipher for the then popular Commodore 64 home computer.
• The ROT-13 letter substitution cipher swaps letters from the first half of the alphabet with the last half of the alphabet and vice versa. Characters that are not letters should pass through unaffected. For example, the string “HELLO, WORLD!” becomes “URYYB, JBEYQ!”.
• Your program must accept text from the keyboard and write the converted result to the screen. Your program must be written in assembler language and be sufficiently commented and readable. You may choose to read your string first and then print out the results or simply output your results as keys are pressed.
• The Commodore 64 has a built-in operating system consisting of the KERNAL for input and output and a BASIC interpreter for writing in the BASIC programming language. You may make use of the KERNAL to handle input and output in your program but may not make use of the built-in BASIC interpreter. The KERNAL provides two relevant subroutines for input and output.
o At address FFD2, there is a subroutine to print a character to the screen. The character code to print is expected in register A.
o At address FFE4, there is a subroutine to read a character from the keyboard. The character code read from the keyboard will be placed in register A when the subroutine completes.
This is an individual assignment. You must design and implement a program meeting the above requirements.
Your submission must include the code source. Your name and student number must appear in the comments at the top of the file.
References
• https://en.wikipedia.org/wiki/ROT13
• https://www.masswerk.at/6502/6502_instruction_set.html • https://archive.org/details/c64-programmer-ref
Suggested Tools
• VICE Commodore 64 Emulator
• CC65 6502 toolchain
Writing and Editing your Code
You can use any text editor you are comfortable with to create and edit assembler files. If you are unsure which text editor to use, Microsoft Visual Studio Code is a popular editor.
Using the Assembler and Running the Code
CC65 comes with several applications, including cl65 which we will use. CC65 is used entirely from the command line. The following command will assemble a file called hello.asm and produce a file called hello.prg.
cl65 -t c64 -C c64-asm.cfg hello.asm -o hello.prg
If you are using windows, you may need to include the location of where you downloaded and extracted cc65 when running the command. For example, the following command assumes the package was extracted to your working directory.
.\cc65-win32-snapshot\bin\cl65 -t c64 -C c64-asm.cfg hello.asm -o
hello.prg
From the VICE package, use the x64sc application to run the Commodore 64 Emulator which can then load the output file such as hello.prg from the assembler. To open assembled file, use the File menu and then select Smart attach disk/tape/cartridge and then open your file or drag and drop the file into the window.
If you need assistance, contact your instructor of your tutorial leader.