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

Write an LC-3 program that will repeatedly read a character from the keyboard. F

ID: 2294180 • Letter: W

Question

Write an LC-3 program that will repeatedly read a character from the keyboard. For each character read in, your program will print a neat message that echoes the input value, and the ASCII character code of the input character in hexadecimal. It will run forever: no HALT or End of processing is required.

For example:

Please press a key:

You pressed 'z' which is x7A

Please press a key:

You pressed '@' which is x40

Please press a key:

You pressed 'O' which is x4F

Please press a key:

You pressed '2' which is x32

Please press a key:

You pressed ' ' which is x20

..

Question 3 (10 marks, programming): Write an LC-3 program that will repeatedly read a character from the keyboard. For each character read in, your program will peint a neat message that echoes the input value, and the ASCII character code of the input character in hexadecimal. It will run forever DO HALT or End of processing is required. For example Please presskey You pressed' ich is x7A Please press akey You pressedich is x40 Please press a key you pressed 'O. which is x4, Please presske You pressed "ich is x32 Please pressakey You pressed ich is x20

Explanation / Answer

Given Data:

Please press a key:

You pressed 'z' which is x7A

Please press a key:
You pressed '@' which is x40
Please press a key:
You pressed 'O' which is x4F
Please press a key:
You pressed '2' which is x32
Please press a key:
You pressed ' ' which is x20

Program:

.ORIG   x3000

        LD R1, NEG     ; Load negative of count to R1

POLL1 (a)LDI R2, KSR    ; Read Keyboard status register into R2

      (b)BRzp POLL1     ; If "ready bit" not set, branch to POLL1

      (c)LDI R0, KDR    ; Read input character from Keyboard data register to R0

       

POLL2 (d)LDI R2, DSR    ; Read Display status register into R2

      (e)BRzp POLL2     ; If "ready bit" not set, branch to POLL2

      (f)STI R0, DDR    ; Write output character from R0 to Display data register

       

        ADD R0, R0, #1 ; Increment the charater

        ADD R1, R1, #1 ; Increment count

        BRn POLL2

        HALT

NEG     .FILL   xFFF6   ; -x000A

KSR     .FILL   xFE00   ; Keyboard status register location

KDR     .FILL   xFE02   ; Keyboard data register location

DSR     .FILL   xFE04   ; Display status register location

DDR     .FILL   xFE06   ; Display data register location

        .END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote