ECE/CS 252: Introduction to Computer Engineering

Spring 2007

 

Homework Assignment #8

 

The following homework requires you to use the LC-3 simulator. Please follow instructions from HW #5 problem 8 for opening the LC-3 simulator and instructions from HW #6 for submitting screenshots of your code.

 

Problem 1

Which is more efficient, interrupt-driven I/O or polling? Explain.

 

Problem 2

Regarding "RFID Inside" on RFID implants http://www.cs.wisc.edu/~markhill/cs252/Spring2007/handouts/spectrum07_rfid_ethics.pdf

a)      Give two different reasons why an employer should be able to require that employees have RFID implants.

b)      Give two different reasons why an employer should NOT be able to require that employees have RFID implants.

        

Problem 3

The following code reads two numbers from the memory and finds if they have the same absolute value. If the absolute values are equal, 1 is stored in R3; otherwise 0 is stored in R3. The subroutine starting at the label “ABS” finds the absolute value of the argument.

     

         .ORIG        x3000              ; Instructions start at x3000

; Initialization

         AND          R3, R3, #0

         LD             R1, VAL1

         LD             R2, VAL2

 

         …………………..            ; Prepare argument VAL1        

         ST              R3, SaveR3      ; Save R3 before calling subroutine

         JSR            ABS                 ; Call subroutine ABS

         LD             R3, SaveR3      ; Restore R3

         …………………..            ; Store Abs(VAL1) in R5

 

         ADD          R0, R2, #0       ; Copy R2 to R0

         ST              R3, SaveR3

         JSR            ABS                 ; Call subroutine ABS

         LD             R3, SaveR3

 

         NOT          R0, R0            

         ADD          R0, R0, #1      

         ADD          R5, R5, R0       ; Find R5 - R0

         BRnp         STOP

         ADD          R3, R3, #1

STOP        HALT

 

; Subroutine for absolute value

                                                   ; Argument is passed in register ______ (fill)

ABS           ADD          R0, R0, #0       ; Set condition code based on R0

         BRzp          ENDABS

         NOT          R3, R0            

         ADD          R0, R3, #1

ENDABS   RET                                   ; Value is returned in register ______ (fill)

 

; Values

SaveR3      .FILL         x0000             

VAL1        .FILL         x000A

VAL2        .FILL         xFFF6

         .END

 

a)Some of the lines in the code are missing. Fill in the missing lines. Also fill in the blanks in the two comment lines as indicated.

b)      Execute the completed program by setting a breakpoint at the HALT instruction, and submit screenshots of your solution

 

Problem 4

An LC-3 program is provided below:

         .ORIG        X3000

         LD             R0, ASCII

         LD             R1, NEG

AGAIN      LDI            R2, DSR

         BRzp          AGAIN

         STI                        R0, DDR

         ADD          R0, R0, #1

         ADD          R3, R0, R1

         BRn           AGAIN           

         HALT

 

ASCII      .FILL          x0041

NEG          .FILL         xFFB6                        

DSR           .FILL         xFE04              ; Address of DSR

DDR          .FILL         xFE06              ; Address of DDR

         .END

a)      What does this program do?

b)      What is the purpose of the Display Status Register (DSR)?

c)      Execute the program in the LC-3 simulator and submit a screenshots of the LC-3 simulator, as well as the LC3 Console.