Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DAYS OF THE WEEK 3.1 Problem Statement Write a program in LC-3 assembly language

ID: 3601049 • Letter: D

Question

DAYS OF THE WEEK 3.1 Problem Statement Write a program in LC-3 assembly language that keeps prompting for an integer in the range 0-6, and each time it outputs the corresponding name of the day. Ifa key other than '0' through 6" is pressed, the program exits 3.1.1 Inputs At the prompt "Please enter number;" a key is pressed. 3.1.2 Outputs If the key pressed is '0' through '6', the corresponding name of the day of the week appears on the screen. Precisely, the correspondence is according to this table: Code Day 0 Sunday Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday When the day is displayed, the prompt "Please enter number: ” appears again and the program expects another input. If any key other that'0' through '6' is pressed, the program exits.

Explanation / Answer


. . .

;R3 a l r e a d y   c o n t a i n s the numerical code of the day i

LEA R0 , DAYS ;Address of ” Sunday ” in R0

ADD R3 , R3 , x0 ; To be able to use c o n d i t i o n codes

; The loop (4 i n s t r u c t i o n s ) implements R0 R0 + 10 * i

LOOP BRz DISPLAY

ADD R0 , R0 , #10 ; Go to next day

ADD R3 , R3 , #1      ;Decrement loop v a r i a b l e

BR LOOP

DISPLA PUTS
. . .

HALT
. . .
DAYS .STRINGZ ”Sunday   ”
     .STRINGZ ”Monday   ”
     .STRINGZ ”Tuesday ”
     .STRINGZ ”Wednesday”
     .STRINGZ ”Thursday ”
     .STRINGZ ”Friday   ”
     .STRINGZ ”Saturday "