Vous êtes sur la page 1sur 9

FACULTY OF ELECTRICAL

STUDENT KIT
ENGINEERING
LAB MODULETM

UNIVERSITI TEKNOLOGI MARA


Program: EE250 Sem : 4
Ownership : Center of Computer Engineering Studies (CCES)
FKE Doc.ID : Date Issued : 2009

COMPUTER ENGINEERING LABORATORY


COURSE CODE: ECE501

MICROPROCESSOR MODULE – LOOP & SUBROUTINES


(M3)

Authors

Prepared by : Assoc. Prof Datin Dr. Wahidah Mansor Date : June 2009

1st Revision : Date :

2nd Revision : Date :

Endorsement by Center of Studies

Chair : Date :
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

Signature :

MODULE OUTCOMES:
Upon completion of this experiment, students should be able to:

MO1: Write the MC68000 assembly language programs using looping technique and
subroutines.

THEORETICAL BACKGROUND:
Program loop
In practice, programs consist of a repetition of sections of the routine which is called a loop. The
function of a loop is to allow a solution to be achieved or to complete a control process. A loop
counter is initially set to the number of loops for use by the process. When the loop repeats
itself, the process will be executed repeatedly. The flowchart of generalized loop procedure is
shown in Figure 1.

Figure 1
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

68000 microprocessor provides conditional branch instruction for testing the termination of the
loop. The generalized form of this branch instruction is Bcc, where B represents branch and cc
is the condition. Some commonly used conditional instructions are listed in Table 1.

Table 1. Branch instructions

Instruction Description
BNE Branch if not equal
BEQ Branch if equal
BGE Branch if greater or equal
BGT Branch if greater than
BLE Branch if less or equal
BLT Branch if less than

Subroutine

A subroutine is a part of a larger program that performs a specific task and is independent of the
other code in the program. The advantages of using a subroutine are less memory space for
programs and modular program structure are used and program debugging becomes much
easier.

PRE-LAB WORK:
Read the document, especially the Experimental Work section. Search the internet and grasp
as much as possible the material before going to the lab. Students should be able to write a
simple program by answering the following questions. In this pre-lab work, the Easy68k
software has to be used to enter, edit and execute your programs. Please ensure that your pre-
lab findings are verified by the instructor before you begin your experimental work.

a) Write and execute a program that write five bytes of data starting to memory locations
starting with location $400450H.

b) Write and execute a program that read the contents of memory locations and place the
larger of the contents of memory locations $400460 and $400462 into memory location
$400464.

c) Three hexadecimal numbers are stored in memory locations $400700, $400701 and
$400702. Sort these numbers into ascending order with the smallest number in memory
location $400700.

Verification by Instructor
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

..................PLEASE SIGN.............................
(Name: )

EXPERIMENTAL WORK:
Apparatus:

a.A Personal computer installed with the MC68000 CPU Editor/Assembler and Simulator
software, EASy68K.
b. MC68000 CPU Trainer Board (Kaycomp II or Flight Model).

Procedure:

All the programs in the exercises have to be written and assembled using the EASy68K
simulator. To observe the results, the programs have to be downloaded and executed on the
MC68000 CPU Trainer Board. The contents of the affected registers and memory locations
have to be examined through single stepping or breakpoints setting.

Exercises:

1. Write and execute a program that move eight bytes of data starting from memory
locations $400460 to memory locations starting $400480H. Note: the contents of the
original memory locations must be cleared.

2. Write and execute a program that exchange twelve bytes of data starting from memory
locations $400470 with those store in memory locations starting with $400450H.

3. Locations $400500 - $400510 contain student marks for a microprocessor course. Write
a program which calculates the number of students that score three categories of marks
and store the number in the specified memory locations as shown in table 1.

a. Table 1. Memory locations for storing the number of students that


b. score three categories of marks.

4. Student 5. Memory
marks locations
6. Above 90 7. $400600
8. 50 - 89 9. $400601
10. Below 50 11. $400602

4. Twelve 8-bit numbers are stored in memory locations starting with $400500. Add the
content of these memory locations using indirect addressing with post increment and
loop. Execute the program and explain on the result obtained.

5. Ten 8-bit numbers are stored in memory locations starting with $400450. Sort these
numbers in descending order with the largest number stored in memory location
$400450.
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

6. Write and execute a program that compute the total volume of three rectangular boxes
whose length, width and height are stored in memory locations $400550, $400560 and
$400570 respectively, and save the total volume of these boxes in memory locations
$400580. The calculation process of the volume must be done in a subroutine.

REPORT SECTION

FACULTY OF ELECTRICAL
STUDENT
ENGINEERING
LAB REPORT
UNIVERSITI TEKNOLOGI MARA
Program: EE250 Sem : 4
Ownership : Center of Computer Engineering Studies (CCES)
FKE Doc.ID : Date Issued : 2009

COMPUTER ENGINEERING LABORATORY


COURSE CODE: ECE501
MICROPROCESSOR MODULE – LOOP & SUBROUTINE

NOTE: SUBMIT REPORT IMMEDIATELY AFTER THE LAB SESSION!


Prepared by : Student ID :
1.
2.
3.
4.
5.
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

Group : Lab Date : Submission Date :

Lab Instructor :

RESULTS:

1. For each of the exercise, tabulate the contents of the affected memory locations, status
register, address register and data register before and after program execution as shown in
Table 2.

TABLE 2 Examples of result


Before Program Execution After Program
Execution
Registers/ Contents Registers/ Contents
Memory Memory
Locations Locations
D0
D1
A0
A1
SR
$400450
:
$400600

Verification by Instructor

..........PLEASE SIGN ................................


(Name: )

DISCUSSIONS:
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

1) Discuss the results obtained in the experiment for each exercise.


2) Do the experimental results in consistent with the expected results? Discuss any discrepancies
and explain possible causes. Suggest or recommend how the errors in the program can be
avoided.
3) State the advantages and disadvantages of a loop.

CONCLUSION:
Conclude in detail the findings and the outcomes of this experiment. This should include the
summary of knowledge gained, comments and discussion of the results, errors and their
possible sources and how this experiment can be improved.

REFERENCES:

1) Antonakos, J.L., The 68000 Microprocessor: Hardware and Software Principles &
Applications, Prentice-Hall, latest edition.
2) Subbarao, W.V., 16/32 Bit Microprocessors 68000/68010/ 68020. Mac Millan, latest edition.
3) Mimar, T., Programming and Designing with 68000 Family, Prentice-Hall, latest edition.

END
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

GRADING SECTION

FACULTY OF ELECTRICAL
STUDENT
ENGINEERING
LAB GRADE
UNIVERSITI TEKNOLOGI MARA
Program: EE250 Sem : 4
Ownership : Center of Computer Engineering Studies (CCES)
FKE Doc.ID : Date Issued : 2009

COMPUTER ENGINEERING LABORATORY


COURSE CODE: ECE501

MICROPROCESSOR MODULE – LOOP & SUBROUTINE

NOTE: RETURN THE GRADED REPORT TO THE RESPECTIVE LAB


(DUE 2 WEEKS AFTER SUBMISSION DATE)

Parameter Marks Parameter Marks


Pre-Lab Work (15%) Quiz (15%)
Results (30%) Conclusion (10%)
MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

Discussions (30%)
Group : Date : Total Marks (100%)
COMMENTS:

Assessor: Signature:

Vous aimerez peut-être aussi