CSC 230 Assignment 5 Spring 2020
This assignment has two parts:
1) Part 1: Three functions: get_message, display and msg. Each passes parameters using a
different mechanism, in registers, on the software stack and on the hardware stack. Submit part 1 via the Assignments link on the Connex site on or before March 26, 2020 well before 1:00 am. (Earns: 40% of the assignment grade)
2) Part 2: The complete program will be submitted via the Assignments link on the Connex site on or before April 1, 2020 well before 1:00 am. (Earns: 60% of the assignment grade)
3) Demonstration: No, just cannot do that without face-to-face interaction!
Objectives
Gain confidence with assembly language programming.
Create effective subroutines/functions with parameters.
Use peripherals: the LCD and buttons. (Cannot be done on the simulator.) Become familiar with the use of busy-waiting.
Become familiar with the use of interrupts.
Academic Integrity
Prior to submitting your assignment, learn about the University policy on Academic Integrity: https://www.uvic.ca/current-students/home/academics/academic-integrity/index.php.
If you do are not sure if the something you are doing is a violation of the academic integrity policy, please ask. A plagiarism detection tool will be used on assignment submissions.
Assignment 5 Description
Please note for all programing assignments, you must include your name and student number and edit the documentation appropriately. Make sure the submitted work is yours and not someone else.
This assignment, as originally posted, requires the use of the M2560 board, which most class
members do not own. With the change of the course from face-to-face to remote, this version
of the assignment is designed to be completed using only the Atmel simulator tool.
The due
dates have been adjusted.
The LCD and Buttons
Sadly, it is not possible to simulate the LCD. Instead a “LCD screen cache” will be created in the
DSEG memory area. The LCD screen cache will hold the characters that should be displayed on
the LCD of a (non-simulated) system.
In addition, it is not possible to simulate Buttons. Instead timer interrupts (as in lab 9) will be
used to change the content of the LCD screen cache, simulating the scrolling through messaged,
as described in the original assignment.
Description: LCD Moving Message Sign
LCD advertising signs often move written messages on a screen and flash. The movement and the flashing are very effective at attracting attention. The goal of this programming task will be to display messages, using timer interrupts to scroll between them in various directions, scrolling up and scrolling down. Since the simulator does not simulate the LCD screen, the data that would be sent to the screen will be placed, instead, into the LCD screen cache in the memory area. Through this assignment, you will practice writing subroutines with parameters (passing in various modes) and using interrupts.
In particular, the program will need to:
a. Create two messages that will be displayed on the screen. For example, assume:
msg1 = “LillAnne Jackson ”
msg2 = “Teaches Assembly ”
(Be sure to use two messages personalized for yourself that contain 17 characters!)
b. Using the messages (msg1 and msg2) create another two messages that contain the
same characters, but in reverse order. Using the above example messages, the messages, called msg3 and msg4, would be:
msg3 = ” noskcaJ ennAlliL”
msg4 = ” ylbmessA sehcaeT”
c. The sign will scroll (cycle) through msg1, msg2, msg3, and msg4, displaying them on
the LCD screen, using the specifications below:
i. When the program starts, both rows of the LCD screen will be completely filled
with asterisk or star “*” characters.
ii. Using the timer interrupts (described in lab 9), change the screen every second, such that the characters on the 2nd line of the screen move up to the 1st line and the next message will appear on the 2nd line. (After the start up screen msg1 appears, followed by msg2 then msg3 then msg4.) For example, starting from the initial start up screen, 5 timer interrupts, one per second, would “scroll up” yielding:
1 second timer interrupt:
*****************
*****************
*****************
LillAnne Jackson
1 second timer interrupt: 1 second timer interrupt: 1 second timer interrupt: 1 second timer interrupt:
iii. Every 10 seconds change the direction of the scroll; it in the opposite direction, i.e., the characters on the 1st line of the screen move down to the 2nd line and the next message will appear on the 1st line. For example, starting from the last message above , 5 timer interrupts, one per second would “scroll down” yielding:
1 second timer interrupt: 1 second timer interrupt: 1 second timer interrupt: 1 second timer interrupt: 1 second timer interrupt:
LillAnne Jackson
Teaches Assembly
Teaches Assembly
noskcaJ ennAlliL
noskcaJ ennAlliL
ylbmessA sehcaeT
ylbmessA sehcaeT
LillAnne Jackson
noskcaJ ennAlliL
ylbmessA sehcaeT
Teaches Assembly
noskcaJ ennAlliL
LillAnne Jackson
Teaches Assembly
ylbmessA sehcaeT
LillAnne Jackson
noskcaJ ennAlliL
ylbmessA sehcaeT
As in lab 9: the only way to see the effect of interrupts in a simulation is by setting breakpoints
throughout your code and using the “Debug->Continue (F5)” approach. You should set
breakpoints inside each of the subroutines and inside the ISR, at the very first instruction (when
the subroutine protects its first register) and at the very last instruction (when the subroutine
returns).
The instructor’s solution uses the following the data:
; sample strings
; These are in program memory
msg1_p: .db “LillAnne Jackson “, 0 msg2_p: .db “Teaches Assembly “, 0
.dseg
; note message length = 17 characters + the null character (0) .equ msg_length = 18
; The program copies the strings from program memory ; into data memory.
;
msg1: .byte msg_length
msg2: .byte msg_length
; These strings contain characters to be displayed on the LCD.
; Each time through, the characters are copied into these memory locations. line1: .byte msg_length
line2: .byte msg_length
line3: .byte msg_length
line4: .byte msg_length
; LCD Cache: contains a copy of the 2 lines to be displayed on the screen LCDCacheTopLine: .byte msg_length
LCDCacheBottom: .byte msg_length
With these data definitions, the main loop of the application looks like:
display(startup screen) i.e., (“*” characters) on lcd
copy the strings from program to data memory
create the two reversed strings, store in data memory startString = “******************”
line1 = startString
line2 = startString
display(line1,line2)
msg_counter=0
direction = 0
busy wait i.e., use done: jmp done
when a timer interrupt occurs: if direction is 0:
msg_counter += 1 remainder 4 line1 = line2
line2 = msg(msg_counter) display(line1, line2)
if direction is 1:
msg_counter -= 1 remainder 4 line2 = line1
line1 = msg(msg_counter) display(line1, line2)
function display(lineA, lineB):
copy string from lineA to line 1 of LCD screen cache memory copy string from lineB to line 2 of LCD screen cache memory
function msg(counter): ; returns address of line 1, 2, 3 or 4 return addressOf(line1) + msg_length * counter
function reverse(message, location):
reverse the string found at message and store at location
function get_message (prog_loc, data_loc)
copies copies a string of characters from prog_loc in program
memory into data_loc in data memory
You should make additional functions, where suitable, in your code.
Part 1:
Submit part 1 via the Assignments link on the Connex site on or before March 26, 2020 well before 1:00 am. (Earns: 40% of the assignment grade)
Startthisworkbywritingandtestingthetwofunctions:get_message (prog_loc, data_loc) and reverse(message, location). Next write and test the function display(lineA, lineB). These three functions together with a main loop that calls all three are required for the Part 1 submission.
Specifications for these three functions:
get_message (prog_loc, data_loc)
The parameter prog_loc is an address in program memory and must be passed to the function in registers (use Z). The parameter data_loc is an address in data memory and must be passed to the function in registers (use Y).
reverse(message, location)
The parameter message is an address in data memory that references the start of the string that will be reversed and must be passed to the function on the hardware stack. The parameter location is the address in data memory where the reversed string will be stored. It must be passed to the function on the hardware stack.
display(lineA, lineB)
The parameter lineA is the address in program memory of the first line ed and and lineB is the address in program memory of the second line to be displayed. Both must be passed to the function using the software stack.
Part 2:
Submit part 2 via the Assignments link on the Connex site on or before April 1, 2020 well before 1:00 am. (Earns: 60% of the assignment grade).
The part 2 submission is the completed work, tested and appropriately documented.