Vous êtes sur la page 1sur 12

FACULTY OF ELECTRICAL

STUDENT KIT
ENGINEERING
LAB MODULE TM

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 – ADDRESSING MODES


& DATA MOVEMENT INSTRUCTIONS
(M1)

Authors

Prepared by : Ihsan Mohd Yassin Date : June 2009

1st Revision : Assoc. Prof. Datin Dr. Wahidah Mansor Date : July 2009

2nd Revision : Date :

Endorsement by Center of Studies

Chair : 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 000000H-
07FFFFH. 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 post-
increment, 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 Assembler syntax


Immediate addressing MOVE.s #n, Dn
MOVE.s #nn, Dn
MOVEA.s #nn, An
Data register direct MOVE.s Dn, Dn
Address register direct MOVEA.s An, An
Absolute addressing MOVE.s nn, Dn
Address register Indirect MOVE.s Dn, (An)
MOVE.s (An), Dn
ARI with post increment MOVE.s Dn, (An)+
MOVE.s (An)+, Dn
ARI with displacement MOVE.s Dn, d(An)
MOVE.s d(An), Dn
Note: 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 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.

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 $400400


MOVE.W #$9854, D1
MOVE.W D1, $400460
MOVE.B $400460, D4
MOVE.W $400460, D6
END 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 $080C00
MOVE.W #$3846, D1
LEA $400460, A1
MOVE.W D0, (A1)
MOVE.B (A1), D2
MOVE.W (A1), D5
END
MICROPROCESSOR MODULE -
ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS ECE501

6. Execute the following program and explain the result of each instruction.

ORG $400400
NUM1 EQU $69C3
NUM2 EQU $E72B
MOVE.W #NUM1, D0
MOVE.W #NUM2, D1
MOVEA.L #$400450, A0
MOVE.B (A0), D1
MOVE.W (A0), D0

ORG $400450
DC.W $B243
END

Verification by Instructor

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

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.


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 and
MOVEA. 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 the
HIGH 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) Absolute addressing mode


b) Indirect addressing mode

6. Location $400450 contains a long word number. Write a program which will load the
contents 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) Address register indirect with post increment


b) Address register indirect with displacement
MICROPROCESSOR MODULE -
ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS ECE501

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: EEE501
MICROPROCESSOR MODULE – ADDRESSING MODES
& DATA MOVEMENT INSTRUCTIONS

NOTE: SUBMIT REPORT IMMEDIATELY AFTER THE LAB SESSION!


Prepared by : Student ID :
1.
2.
3.
4.
5.

Group : Lab Date : Submission Date :

Lab Instructor :
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 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:
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 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 – ADDRESSING MODES & DATA MOVEMENT


INSTRUCTIONS

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%)
MICROPROCESSOR MODULE -
ADDRESSING MODES & DATA MOVEMENT INSTRUCTIONS ECE501

COMMENTS:

Assessor: Signature: