Docsity

Mips Addressing Mode, Lecture notes of Computer Architecture and Organization

Partial preview of the text

Download Mips Addressing Mode and more Lecture notes Computer Architecture and Organization in PDF only on Docsity!

Addressing Modes

Addressing modes are concerned with

how the CPU accesses the operands used

by its instructions

Register Direct Addressing

Register direct addressing is the simplest addressing

mode in which the source or destination of an operand is

a data register or an address register. The contents of the

specified source register provide the source operand.

Similarly, if a register is a destination operand, it is

loaded with the value specified by the instruction. The

following examples all use register direct addressing for

source and destination operands.

MOVE.B D0,D3 Copy the source operand in register D0 to register D SUB.L A0,D3 Subtract the source operand in register A0 from register D CMP.W D2,D0 Compare the source operand in register D2 with register D ADD D3,D4 Add the source operand in register D3 to register D

The destination operand

  • M O V E B D 0 , D - D - 2 5 D
    • is data register D

M O V E. B D 0 , D 1

D 1

2 5 D 0

The effect of this instruction is to copy the contents of data register D0 in to data register D

Immediate Addressing

In immediate addressing the actual operand forms

part of the instruction. An immediate operand is also

called a literal operand. Immediate addressing can be

used only to specify a source operand.

Immediate addressing is indicated by a # symbol in

front of the source operand.

For example, MOVE.B #24,D0 uses the

immediate source operand 24.

M O V E. B # 4 , D 0

D 0

The instruction MOVE.B #4,D uses a literal source operand and a register direct destination operand

M O V E. B # 4 , D 0

D 0

The destination operand is a data register

M O V E. B # 4 , D 0

4 D 0

The effect of this instruction is to copy the literal value 4 to data register D

M O V E. B 2 0 , D 0

D 0

2 0 4 2 M e m o r y This instruction has a direct source operand The source operand is in memory The destination operand uses data register direct addressing

M O V E. B 2 0 , D 0

D 0

2 0 4 2 M e m o r y The address of the operand forms part of the instruction Once the CPU has read the operand address from the instruction, the CPU accesses the actual operand This is the actual operand

Summary of Fundamental

Addressing Modes

Consider the high-level language example: Z = Y + 4

The following fragment of code implements this construct

ORG $400 Start of code MOVE.B Y,D ADD #4,D MOVE.B D0,Z ORG $600 Start of data area Y DC.B 27 Store the constant 27 in memory Z DS.B 1 Reserve a byte for Z

The Assembled Program

1 00000400 ORG $

2 00000400 103900000600 MOVE.B Y,D

3 00000406 06000018 ADD.B #24,D

4 0000040A 13C000000601 MOVE.B D0,Z

5 00000410 4E722700 STOP #$

7 00000600 ORG $

8 00000600 1B Y: DC.B 27

9 00000601 00000001 Z: DS.B 1

10 00000400 END $

Summary

Register direct addressing is used for variables that can

be held in registers

Literal (immediate) addressing is used for constants

that do not change

Direct (absolute) addressing is used for variables that

reside in memory

The only difference between register direct addressing

and direct addressing is that the former uses registers

to store operands and the latter uses memory

Address Register Indirect Addressing In address register indirect addressing , the instruction specifies one of the 68000โ€™s address registers; for example, MOVE.B (A0),D0. The specified address register contains the address of the operand. The processor then accesses the operand pointed at by the address register.