DocumentM1

Embed Size (px)

Citation preview

FACULTY OF ELECTRICAL ENGINEERING UNIVERSITI TEKNOLOGI MARA Program: EE250 Ownership : FKE Doc.ID : Center of Computer Engineering Studies (CCES)

STUDENT KIT LAB MODULE Sem : 4

TM

Date Issued : 2009

COMPUTER ENGINEERING LABORATORY COURSE CODE: ECE501MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS (M1)

AuthorsPrepared by : Ihsan Mohd Yassin 1st Revision : Assoc. Prof. Datin Dr. Wahidah Mansor 2nd Revision :

Date : June 2009 Date : July 2009 Date :

Endorsement by Center of StudiesChair :

Date :

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

Signature :

MODULE OUTCOMES:Upon completion of this experiment, students should be able to: MO1: Write simple assembly language programs for the MC68000 CPU using data transfer instructions and execute the programs on the MC68000 trainer MO2: Write simple programs to assign data to memory and registers using various addressing modes.

THEORETICAL BACKGROUND:The Motorola MC68000 Central Processing Unit is capable of accessing a linear address space of 16 Mbytes. Like other microprocessor system, the MC68000 Trainer Board consists of two types of memory; ROM and RAM. All resources available on the Trainer Board are controlled by the monitor program that is stored in ROM. The ROM occupies memory locations 000000H07FFFFH. The program that is written by a user is stored in RAM. This memory occupies specific addresses, for example 400400H up to 43FFFFH. Therefore, user programs should be started at an address 400400H. The programming model of the CPU describes the register set and the number of bits that can be held by the registers. This programming model needs to be understood before writing assembly language programs for the MC68000 CPU.

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

Figure 1 68000 Programming model Figure 1 shows the MC68000 programming model This processor has eight data registers; D0 to D7, eight address registers; A0 to A7, a program counter (PC) and status register (SR). All registers except for the status register can hold a maximum of 32 bit data. The function of the data registers is to store information (data) within the MC68000 CPU itself whereas the address registers are used to store the location (memory address) of the data stored in the external memory chips. There are four types of data transfer instructions provided by the 68000 microprocessor: a) register to register c) register to memory b) memory to register d) memory to memory Data transfer instructions involve instructions such as MOVE, MOVEA, MOVEM, MOVEQ, SWAP etc to copy or move data between the various locations. M68k Addressing Modes Addressing modes are an important aspect in assembly language. An addressing mode specifies the way the microprocessor defines the address of the operand. The 68000 provides two main categories of addressing modes; register addressing mode and memory addressing mode. The register addressing mode is further divided into data register direct and address register direct. Memory addressing mode include address register indirect (ARI), ARI with postincrement, ARI with pre-decrement, absolute addressing, immediate data and others, as shown in Figure 1.

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

Figure 1: M68k addressing modes Data Register Direct and Address Register Direct addressing modes are used to address data registers and address registers. Table 1 shows the assembler syntax of some commonly used addressing modes for transferring data. Table 1 Addressing modes and assembler syntax Addressing modes Immediate addressing Data register direct Address register direct Absolute addressing Address register Indirect ARI with post increment ARI with displacementNote:

Assembler syntax MOVE.s #n, Dn MOVE.s #nn, Dn MOVEA.s #nn, An MOVE.s Dn, Dn MOVEA.s An, An MOVE.s nn, Dn MOVE.s Dn, (An) MOVE.s (An), Dn MOVE.s Dn, (An)+ MOVE.s (An)+, Dn MOVE.s Dn, d(An) MOVE.s d(An), Dn

n is an 8-bit; nn is a 16-bit number s is size (B - byte, W - word or L - long-word) Dn is data register (D0, D1, D2, D3, D4, D5, D6, D7) An is address register (A0, A1, A2, A3, A4, A5, A6, A7) d is displacement value.

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

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 simple programs using different addressing modes and data movement instructions. In this prelab 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. 1. The following program shows how data is created in data register. START ORG $400400 MOVE.B #$46, D1 ; write data $46 into D1 MOVE.W #$7823, D2 ; write data $7823 into D2 MOVE.L #$98AB73FF, D3 ; write data $98AB73FF into D3 END START Assemble this program, execute it and observe the results. 2. The following program shows how data is created in address register. START ORG $400400 MOVEA.W #$7823, A1 ; write address $7823 into A1 MOVEA.L #$400600, A2 ; write address $400600 into A2 END START Assemble this program, execute it and observe the results. 3. Execute the following program and state the contents of the affected registers and the memory location. Explain the function of the program. START ORG MOVE.W MOVE.W MOVE.B MOVE.W END $400400 #$9854, D1 D1, $400460 $400460, D4 $400460, D6 START

4. Write a program that will store $A4, $2B65 in two data registers and copy these values in memory locations $400650 and $400652 respectively. 5. Execute the following program and state the contents of the affected registers and the memory location. Explain the benefit of using this addressing mode in a program. ORG MOVE.W LEA MOVE.W MOVE.B MOVE.W END $080C00 #$3846, D1 $400460, A1 D0, (A1) (A1), D2 (A1), D5

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

6. Execute the following program and explain the result of each instruction. ORG NUM1 EQU NUM2 EQU MOVE.W MOVE.W MOVEA.L MOVE.B MOVE.W ORG DC.W END Verification by Instructor ..................PLEASE SIGN............................. (Name: ) $400400 $69C3 $E72B #NUM1, D0 #NUM2, D1 #$400450, A0 (A0), D1 (A0), D0 $400450 $B243

EXPERIMENTAL WORK:Apparatus: A Personal computer installed with the MC68000 CPU Editor/Assembler and Simulator software, EASy68K. MC68000 CPU Trainer Board (Kaycomp II or Flight Model). Exercises: 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. 1. Write a 68K assembly language program that will store $A2345600 in a data register and copy the content of this data register to another data register using a. Byte movement b. Word movement c. Long word movement. a.

b.

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

2. Two types of instructions can be used to load a value into an address register, LEA andMOVEA. Set the value of A1 to $400400 and $ABCD using the following instructions a. LEA. b. MOVEA.L c. MOVEA.W 3. Write a program that will store 16 bit data in two registers and exchange the contents of these registers using EXG instruction.

4. Write a program that stores the value of $12345678 into a data register and copy theHIGH WORD in location $400450 and the LOW WORD in memory location $400600. 5. Locations $400440 and $400441 contain a word number. Write a program which will load the contents of these memory locations in a data register and copy the content of these memory into memory locations $400450 and $400451 respectively using the following modes of addressing: a) b) Absolute addressing mode Indirect addressing mode

6. Location $400450 contains a long word number. Write a program which will load thecontents of this memory location in a data register and copy the content of this memory into memory location $400454 using the following addressing modes:

a) b)

Address register indirect with post increment Address register indirect with displacement

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

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

COMPUTER ENGINEERING LABORATORY COURSE CODE: EEE501MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

NOTE: SUBMIT REPORT IMMEDIATELY AFTER THE LAB SESSION! Prepared by : 1. 2. 3. 4. 5. Group : Lab Instructor : Lab Date : Submission Date : Student ID :

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

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 Registers/ Memory Locations D0 D1 A0 A1 SR $400450 : $400600 Contents After Program Execution Registers/ Memory Locations Contents

Verification by Instructor ..........PLEASE SIGN ................................ (Name: )

DISCUSSIONS:1) Discuss the results obtained in the experiment for each exercise. 2) Explain the difference between the MOVEA.W and MOVEA.L instructions.

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

QUIZ:A set of questions will be presented by lab instructor and students are expected to answer all questions before concluding the experiment. This could be in the form of written or oral quiz.

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. J. L. Antonakos, The 68000 Microprocessor: Hardware and Software Principles &Applications, 5th Ed., Pearson Prentice-Hall, 2004, pp. 63-69. 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 ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

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

COMPUTER ENGINEERING LABORATORY COURSE CODE: ECE501MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

NOTE: RETURN THE GRADED REPORT TO THE RESPECTIVE LAB (DUE 2 WEEKS AFTER SUBMISSION DATE) Parameter Pre-Lab Work (15%) Results (30%) Discussions (30%) Group : Date : Total Marks (100%) Marks Parameter Quiz (15%) Conclusion (10%) Marks

MICROPROCESSOR MODULE ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS

ECE501

COMMENTS:

Assessor:

Signature: