Starting from:
$100

$94

Assignment 5 Solution

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:




 
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!)

 
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"




 
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:







LillAnne Jackson Teaches Assembly










Teaches Assembly noskcaJ ennAlliL










noskcaJ ennAlliL ylbmessA sehcaeT







ylbmessA sehcaeT LillAnne Jackson






 
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:




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.

More products