ELET2100- MICROPROCESSORS I - COURSE TEST #1

WED.17th OCT.2007 - [ SOLUTIONS ]- (3:00 - 4:00 )PM

( 1 )Data byte 28H is stored in Register B and data byte 97H is stored in the

Accumulator. Show the contents of registers B, C, and the Accumulator

after the execution of the following two instructions:

MOVA, B

MOV C, A[2]

MOV A, B ; copies the value 28h into register A

MOV C, A ; copies the value 28h into register C

After execution of the two instructions, all three registers (A, B, & C) contain the value 28h.

( 2 )Write Assembly Language (AL) code to add the following two Hex numbers.

Both numbers should be saved for future use and the sum should be saved in

the Accumulator.

Numbers are: A2H and 18H[3]

MOVB, 18h ; copy the value 18h into register B (for storage)

MOVC, 0A2h ; copy the value A2h into register C (for storage)

MOVA, C ; copy the value A2h in register A

ADIA, 18h ; add the value 18h to the contents of register A (18h + A2h)

Register A has the sum/result (BAh), register B has 18h, & register C has A2h

( 3 )If the internal clock frequency of an 8085 CPU is 4 MHz, how much time is

required to execute an instruction of 18 states ?[2]

Internal clock frequency = 4 MHz = 4 x 106 Hz

Clock period = 1/f = 0.25 x 10 -6 s

18 states (clock periods) = 18 x 0.25 x 10 -6 s = 4.5 x 10 -6 s = 4.5 µs

( 4 )If your CPU has an address bus consisting of 20 pins, what is the highest

address in the memory system (in decimal) ?[1]

Size of bus = 220 = 1,048,576

Ranges of addresses = 0 – 1,048,575

Highest address = 1,048,575

( 5 )The 8085 CPU executes the following code:

.

09FDLXISP, 20FFH

1000MVIA, 79H

1002RAR

1003CALL Hello

1006RST5

1007DCRA

.

(a) sketch a diagram showing the contents of the Stack[2]

The SP points to 20FFh after LXI SP, 20FFh instruction.

The first instruction to affect the Stack is CALL Hello.

The CPU decrements the SP (by 2)& saves the contents

of the PC (1006). When the CALL instruction is completed

, it RETurns to 1006 and continues execution AFTER

incrementing the SP (by 2) and copying off the Stack contents.

( b ) what is the value in the Stack Pointer (SP) after

executing RST 5 ?[1]

SP = 20FFh

( c ) where does the CPU go after executing RST 5 ?[1]

The CPU goes to 5 x 8 = 0040 = 0028h

( 6 )Specify the output at PORT1 if the following code is executed:

MVI B,82H

MOV A,B

MOV C,A

MVI D, 37H

OUT PORTI

HLT

[ Assume POTR1 is already initialized as an Output port ][3]

The OUT PORT1 instruction will send the contents of register A out to port PORT1.

Register A contain 82h (from line 2)thus, the output at PORT1 is 82h.

( 7 )Specify the register contents and the status of the flags shown, after the following

Instructions are executed:

A C S Z CY

XX XX 0 0 0(initial values)

MVI A, 5EH5E XX 0 0 0

ADI A2H00 XX 0 1 1

MOV C,A00 00 0 1 1

HLT[5]

( 8 )Indicate whether the following statements are (T) or (F)alse:

( a ) if the 8085 CPU is interrupted while executing a 3-byte instruction, it will

acknowledge the request immediately before completion of the instruction.

FALSE – it will complete the instruction first.

( b ) when the 8085 CPU is Reset, all interrupts are disabled, including TRAP.

FALSE – TRAP cannot be disabled.

( c ) RST 6.5 has a higher priority than INTR.

TRUE – INRT has the lowest priority.

( d ) the instruction, EI, is necessary to enable the TRAP interrupt.

FALSE – TRAP is always enabled (it cannot be disabled).

( e ) the execution of instructions MVI A, 10H, then SIM, will enable all three

Interrupts (7.5, 6.5, and 5.5).[5]

FALSE – this will remove the ‘mask’ but the Interrupt Enable bit (bit 3)must be set.

( 9 )The SDK-85 kit in the lab is equipped with:

( i ) 8-LED’s on Port 00

( ii ) 8-switches on Port 01

Write AL code, with comments, to initialize the ports, read the status of the switches,

Count the number switches that were ON (set), turn ON that number of LED’s. [5]

MVIA, 0FFh ; Port 00, all bits = Outputs

OUT02; do it

MVIA, 00; Port 01, all bits = Inputs

OUT03; do it

IN00; read Switches to register A

MVIC, 0; “# of set bits” counter

MVIB, 8; loop counter

Here:RAL; msb into Carry flag

JNZOver; skip next line if Carry = 0

INRC; increment “set bits” counter

Over:DCBB; decrement “loop counter”

JNZHere; checked all bits ? if not, loop to Here

MOVA,C; # set switches = ON to register A

OUT01; send it to LED’s

HLT

Bonus mark:

How many seats across are there in the first row of seats, in the SLT? (± 1 seat).

9 seats.

Maximum mark = 30