CIS*2030 Fall 2005
Assignment #3
Due: Monday, November 21, 2005 in class, or earlier at Reynolds 215
Please staple all sheets together and print your name and student id number on the top of each sheet.
1.
(a) Explain the effect on the hardware stack of the 68000 instruction MOVEM.W D0-D2/A1,-(SP). Include in your explanation the order in which the registers involved are processed. (b) How might an instruction like this be useful for ensuring subroutine transparency? When would it be necessary to use the long (.L) version of the instruction for that purpose?
2.
(a) Use a small binary sum to illustrate how 2n-bit addition or subtraction may be achieved by means of two separate n-bit operations. Make sure that you carefully explain the role of the carry bit linking the two operations. (b) Write a fragment of 68000 assembler that uses ADD.L and ADDX.L (these instructions both operate on 32 bits) to take two 64-bit numbers from memory and store their sum as another 64-bit number in memory. Explain the significance of the term big-endian in this context. (c) Why does ADDX make use of the X (extend) flag and not the C (carry) flag? [Hint: How would you address (b) using only one register, and what is the effect of MOVE on the CCR?]
3.
(a) What two representations of negative numbers correspond to the instructions NEG and NOT? (b) Can the instruction NEGX be used instead of either? (c) Why do you think there is only one corresponding BCD instruction, NBCD?
4.
(a) What is wrong with the attempt at parameter-passing represented below?
MOVE D0,-(A7) ; push D0 onto stack for subroutine
BSR SUBR
...
SUBR MOVE (A7)+,D1 ; pop parameter off stack to use in D1
...
RTS
(b) Suggest how it could be modified so as to work and still to keep the stack operations balanced (i.e. the same number of pushes as pops).
5.
(a) Explain the differences between BSR and TRAP. (b) Why is the latter instruction particularly useful for access to operating system functions? (Give at least two reasons.)
6.
(a) Write down an instruction that would clear the S bit in the status register. (b) How could you modify this instruction to set instead of clear the bit? Explain.
7.
(a) What is the effect on address register A7 of changing the privilege state (i.e. the value of the S bit)? (b) Can a supervisor-mode program access the user-mode hardware stack pointer? If so, how? (c) Does entering user mode protect the supervisor stack from being corrupted? Explain.
8.
(a) Describe, in general terms, how a Memory Management Unit (MMU) may be used to control a program's access to memory. (b) If, in particular, the intention is to prevent user-mode programs from writing to system memory, which processor signal lines does the MMU need to be connected to? Explain how it would make use of these signals. (You do not need to mention the control signals involved in ordinary operation of the address bus.)