Beruflich Dokumente
Kultur Dokumente
General details
Almost always, one operand is held in a register.
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-1
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-2
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-3
Example
ADD means add 32 bit numbers
ADDB means add 8 bit numbers
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-4
Immediate Addressing
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-5
Instruction
Operation
Memory address
Memory location
Operand
slides3.fm-6
100
Registers
Memory
100
R2
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-7
100
Registers
Memory
100
R2
slides3.fm-8
slides3.fm-9
Immediate Addressing
The operand is held in the instruction:
Instruction
Operation
Operand
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-10
;R2 = 123
Processor
Instruction
MOV
2
123
Registers
R2
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-11
For example:
High level code
int x = 123;
MOV R1,123
a = b + 34;
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-12
Instruction
Operation
Register no.
Register
Operand
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-13
;R3 = R2
Processor
Instruction
MOV
3
Registers
R3
R2
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-14
For example:
High level code
x = y;
MOV R1,R2
a = b + c;
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-15
Register no.
Register
Memory address
Memory location
Operand
slides3.fm-16
Registers
120
R3
R2
120
slides3.fm-17
ptr, a pointer
integer variable in memory, say location 120
b = &a;
b = address of a
MOV R1,120
*b = 123;
LD [R1],123
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-18
Instruction
Operation
Register no.
Address
Register
Offset
Operand
Memory location
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-19
Memory
100
Registers
220
R3
R2
120
+
In this example,
R2 holds the number 120
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-20
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-21
C code
i
R2
100
Instruction
3
2
1
0
x = a[i];
a[i]
Assembly language
LB R1,100[R2]
a[0]
Load byte
Here, compiler uses R1 for x, R2 for i and starting address for array
a is location 100. (a[] assumed a character array in figure. If a[] is
an integer array, would use LD and need to multiply index by 4.
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-22
Implied Addressing
Some operations have an implicit location for the operand and its
address need not be specified.
operations later.
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-23
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-24
Instruction
Operation
Addressing mode
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-25
Instruction
Operation
Size of transfer
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-26
Quiz
1. Identify the addressing mode of each of the following hypothetical
machine instructions.
LD R2, [R3]
LD R2, [100]
LD R2, 100[R3]
MOV R2, 6
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-27
x = 5;
if x is held in a register, say R1? Give an illustrative example.
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-28
LD R10, 100[R2]
LD R11, 104[R2]
ST 100[R2],R11
ST 104[R2],R10
(This is not an efficient sequence for a pipelined processor. It can be written better -- we
will see why much later.)
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-29
; R1 = R1 - R1
; R1 = R1 + 5
; R1 = R1 / 2
; R1 = R1 * 2
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-30
Barry Wilkinson 2008. This material is for sole and exclusive use of students enrolled at UNC-Charlotte. It is not to be sold, reproduced, or generally distributed.
slides3.fm-31