M3

10
FACULTY OF ELECTRICAL ENGINEERING UNIVERSITI TEKNOLOGI MARA STUDENT KIT LAB MODULE TM 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 1 st Revision : Date : 2 nd Revision : Date : Endorsement by Center of Studies Chair : Date : Signature :

Transcript of M3

Page 1: M3

FACULTY OF ELECTRICAL ENGINEERING

UNIVERSITI TEKNOLOGI MARA

STUDENT KITLAB MODULETM

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 :

Signature :

Page 2: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

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 loopIn 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

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.

Page 3: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

Table 1. Branch instructions

Instruction DescriptionBNE Branch if not equalBEQ Branch if equalBGE Branch if greater or equalBGT Branch if greater thanBLE Branch if less or equalBLT 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

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

Page 4: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

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 thatb. score three categories of marks.

4. Student marks

5. Memory locations

6. Above 90 7. $4006008. 50 - 89 9. $40060110. 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.

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.

Page 5: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

REPORT SECTION

FACULTY OF ELECTRICAL ENGINEERING

UNIVERSITI TEKNOLOGI MARA

STUDENTLAB REPORT

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.

Group : Lab Date : Submission Date :

Lab Instructor :

Page 6: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

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/ Memory Locations

Contents Registers/ Memory Locations

Contents

D0

D1

A0

A1

SR

$400450

:

$400600

Verification by Instructor

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

DISCUSSIONS:

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.

Page 7: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

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

Page 8: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

GRADING SECTION

FACULTY OF ELECTRICAL ENGINEERING

UNIVERSITI TEKNOLOGI MARA

STUDENTLAB GRADE

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%)

Discussions (30%)

Group : Date : Total Marks (100%)

COMMENTS:

Page 9: M3

MICROPROCESSOR MODULE – LOOP & SUBROUTINE ECE501

Assessor: Signature: