Final Study

4 problems

1. Cache Design and Virtual Memory

2. Connect RAM, ROM to processor (HW5-2)

3. Processor state after instruction execution (HW4-1, HW5-1)

4. Write main program and subroutine with correct parameter passing (HW4-3)


1) Look at quizlet


2)

Consider the following processor system:

A 68HC11 is connected to 3 memory chips: 1 RAM, 1 EEPROM, and 1 ROM.

The RAM is mapped to the address space: $0000 - $0FFF

The EEPROM is mapped to the address space: $4000 - $5FFF

The ROM is mapped to the address space: $C000 - $FFFF


a) (6 points) Calculate the size (number of memory cells in KiloBytes (KiB)) of each memory chip.

b) (6 points) How many address lines does each memory chip have?


RAM: $0FFF - $0000 + 1 = $1000 = 4098 cells = 4KiB. 4098 = 2^12 = 12 address lines

EEPROM: $5FFF - $4000 + 1 = $2000 = 8196 cells = 8KiB. 8196 = 2^13 = 13 address lines

ROM: $FFFF - $C000 + 1 = $4000 = 16384 = 16KiB. 16382 = 2^14 = 14 address lines


c) (12 points) Come up with the Boolean equations for the CE (Chip Enable) lines for the RAM,

EEPORM, and ROM chips:


RAM: 0000 1111 1111 1111

         0000 0000 0000 0000


CE = E * A15Not * A14Not * A13Not * A12Not


EEPROM: 0101 1111 1111 1111

                 0100 0000 0000 0000


CE= E * A15Not * A14 * A13Not


ROM: 1111 1111 1111 1111

           1100 0000 0000 0000


CE= E * A15 * A14


3)

A. RTS

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $ABCD $01F4 $4455 $11 $22 $33 $44 $55


B. PSHX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $ABCD 01F001F0 $1235 $11 $AB $CD $44 $55


C. Specify the contents of the registers after the following instructions are executed:

DES

PULX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $3344 $01F3 $1236 $11 $22 $33 $44 $55


D. Specify the contents of the registers after the following instructions are executed:

INS

TSX

STX 0,X

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $01F4 $01F3 $1238 $11 $22 $33 $44 $01


A. Specify the contents of the registers after the following instructions are executed:

PSHX

RTS

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $CDEF $01F1 $CDEF $CD $EF $33 $44 $55


B. PULX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $3344 $01F3 $1235 $11 $22 $33 $44 $55


C. Specify the contents of the registers after the following instructions are executed:

INS

PSHX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $CDEF $01F0 $1236 $11 $CD $EF $44 $55


D. Specify the contents of the registers after the following instructions are executed:

INS

TSX

LDX 0,X

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $4455 $01F2 $1238 $11 $22 $33 $44 $55


4)

3. Consider the following main program variable declarations:

ORG $B000 (Main Program Data Section)

DATA1 FCB 5

DATA2 FCB 6

RESULT RMB 1


A) (10 points) Write the main program that will call the subroutine SUB and will pass data items DATA1 and DATA2 to that subroutine using “call-by-value over the stack”. The subroutine will pass back a 1-byte data item through “call-by-value in register”. The main program will then store the data item passed back from the subroutine into RESULT (do not forget to initialize any crucial processor registers).



B) (10 points) Write the subroutine SUB that will retrieve the data items passed by the main program using “call-by-value over the stack” (that you implemented in A) and pass the 1-byte sum of those data items through “call-by-value in register” back to the main program. The subroutine must not use the labels DATA1, DATA2, or RESULT. Also, make sure that the stack will not grow infinitely or will suffer from underflow in case the subroutine is called multiple times. PUSH/PULL instructions are allowed.






take 2


Consider the following processor system:

A 68HC11 is connected to 3 memory chips: 1 RAM, 1 EEPROM, and 1 ROM.

The RAM is mapped to the address space: $0000 - $0FFF

The EEPROM is mapped to the address space: $4000 - $5FFF

The ROM is mapped to the address space: $C000 - $FFFF


RAM: $0FFF - $0000 +1 = $1000 = 4098 = 4KiB. 4098 = 2^12 = 12 address lines

CE = E * A15Not * A14Not * A13Not * A12Not

EEPROM: $5FFF - $4000 + 1 = $2000 = 8196 = 8KiB. 8196 = 2^13 = 13 address lines

CE = E * A15Not * A14 * A13Not

ROM: $FFFF - $C000 + 1 = $4000 = 16384 = 16KiB. 14 address lines

CE = E * A15 * A14



A. RTS

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $ABCD $01F4 $4455 $11 $22 $33 $44 $55


B. PSHX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $ABCD $01F0 $1235 $11 $AB $CD $44 $55


C. Specify the contents of the registers after the following instructions are executed:

DES

PULX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $3344 $01F3 $1236 $11 $22 $33 $44 $55


D. Specify the contents of the registers after the following instructions are executed:

INS

TSX

STX 0,X

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $ABCD $01F2 $1234 $11 $22 $33 $44 $55

After $01F4 $01F3 $1238 $11 $22 $33 $44 $01


A. Specify the contents of the registers after the following instructions are executed:

PSHX

RTS

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $CDEF $01F1 $CDEF $CD $EF $33 $44 $55


B. PULX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $3344 $01F3 $1235 $11 $22 $33 $44 $55


C. Specify the contents of the registers after the following instructions are executed:

INS

PSHX

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $CDEF $01F0 $1236 $11 $CD $EF $44 $55


D. Specify the contents of the registers after the following instructions are executed:

INS

TSX

LDX 0,X

X SP PC ML($01F0) ML($01F1) ML($01F2) ML($01F3) ML($01F4)

Initial $CDEF $01F1 $1234 $11 $22 $33 $44 $55

After $4455 $01F2 $1238 $11 $22 $33 $44 $55