=========================preview======================
(elec254)[2007](f)midterm~PPSpider^_10310.pdf
Back to ELEC254 Login to download
======================================================
HONG KONG UNIVERSITY OF SCIENCE OF TECHNOLOGY
DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING

ELEC 254 Microprocessor Experiments

Midterm (09:15 C 10:45 2 November 2007)

Prof. Kam-Tim WOO

I declare that the answers submitted for this examination are my own work. I understand that sanctions will be imposed, if I am found to have violated the Universitys regulations governing academic integrity.
Name : Answers

Student ID :
Student's Signature :

Remarks :
1. This is an open book examination.
2. Answer all questions in the space provided.
3. Show all your procedures clearly. No marks will be given for unjustified answers.


Questions
Maximum Marks
Marks

1
23


2
10


3
18


4
17


5
10


6
12


7
10


Total
100




Question 1 (23 marks)
An 8051 subroutine is shown below:

SUB: MOV R0, #30H
LOOP: MOV @R0, #0
INC R0
CJNE R0, #60H, LOOP
RET

(3 marks) What does this subroutine do? Please explain in less than 30 words.

This subroutine will clear the content (set to 00) of the internal memory at address 30H to 5FH


(3 marks) How many machine cycles does each instruction execute?
SUB: MOV R0, #30H __1__ cycle(s)
LOOP: MOV @R0, #0 __1__ cycle(s)
INC R0 __1__ cycle(s)
CJNE R0, #60H, LOOP __2__ cycle(s)
RET __2__ cycle(s)

(3 marks) How many bytes long in each instruction?
SUB: MOV R0, #30H __2__ byte(s)
LOOP: MOV @R0, #0 __2__ byte(s)
INC R0 __1__ byte(s)
CJNE R0, #60H, LOOP __3__ byte(s)
RET __1__ byte(s)


(4 marks) How long does this subroutine take to execute? (Assume 12 MHz operation).

Each cycle 1 s , Total cycles = 1 + 4* 48 + 2 = 195 s.

(10 marks)
Re-write this subroutine by using the MODE 1 of TIMER 1.

SUB: MOV TMOD, #10H __2__ cycle(s)

MOV TH1, #0FFH __2__ cycle(s)
MOV TL1, #88H __2__ cycle(s)
SETB TR1 __1__ cycle(s)
JNB TF1, $ __2__ cycle(s)
CLR TR1 __1__ cycle(s)
CLR TF1 __1__ cycle(s)
RET __2__ cycle(s)

Each cycle 1 s, Total cycles = 195 s. C 7 C 4 = 184 s = FF48H or
If using 195 s = FF3DHQuestion 2 (10 marks)
Suppose the following memory locations contain the initial values as follows:

Address
Memory

30H
7FH

78H
00H

7FH
FFH




What are the contents of the memory locations 20H, 78H, and 7FH after the execution of each instruction below?

Assume each instruction is independent of each other.

a) MOV 30H, 78H
Address
Memory

30H
00H

78H
00H

7FH
FFH





b) XRL 78H, #30H
Address
Memory

30H
7FH

78H
30H

7FH
FFH





c) ANL 7FH, #7FH
Address
Memory

30H
7FH

78H
00H

7FH
7FH





d) MOV 7FH, 30H
Address
Me