Op Code Instruct
Op Code Instruct
Dr Philip Leong
[email protected]
A := B + C Assignment Statement
Int: A,B,C
Declare Variables
- Specify name and other properties
A := B + C
A: Allocate 1 word
B: Allocate 1 word Allocate memory for
C: Allocate 1 word Variables.
Memory
M x 16-Bit words, Word addressed
Length of an Instruction?
8-bits, 10-bits, 16-bits, 18-bits, 24-bits, 32-bits?
Instruction length =
Opcode Bits + Reg Bits + Operand(s) Bits
Computer Architecture (P. Leong) Instruction execution (page 8)
The Fetch-Execute Cycle - repeat forever
¾ Fetch the Instruction (=load or read from memory)
¾ Repeat Forever
Instruction Fields
¾ OPeration CODE (Selects CPU Instruction)
¾ REGister (Specifies 1st Operand for Instruction)
¾ ADDRESS (Specifies 2nd Operand for Instruction)
MEMORY
Computer Architecture (P. Leong) Instruction execution (page 16)
Memory Placement (Data)
Assembly Data Memory
Instruction Address
MEMORY
Computer Architecture (P. Leong) Instruction execution (page 17)
CPU Organisation
CPU AX 000
BX Address 001
CX Bus 002
I 003
DX n
t
ALU e
Input Reg1 Data
r Bus
Output Reg RAM
n
Input Reg2 a
l
Control
Program Counter B Bus
u
Instr. Decoder Instr. Register s
3FD
3FE
Control Unit 3FF
ALU
RAM
080H
080H
PC 080H 0
Instr. Decoder
0 3FD
0 3FE
Control Unit 3FF
1
Computer Architecture (P. Leong) Instruction execution (page 19)
MOV CX,[201H] CX:=Memory[201H]
CPU 000
001
080H 002
CX 003
ALU
RAM
PC 080H + 1 0
Instr. Decoder
3FD
3FE
Control Unit 3FF
2
Computer Architecture (P. Leong) Instruction execution (page 20)
MOV CX,[201H] CX:=Memory[201H]
CPU 000
001
080H 002
CX 003
ALU
RAM
0
PC 081H
Instr. Decoder
3FD
3FE
Control Unit 3FF
3
Computer Architecture (P. Leong) Instruction execution (page 21)
MOV CX,[201H] CX:=Memory[201H]
CPU 000
001
080H
CX
080 1A01H
1A01
081 3A02H
ALU 082 2A00H
RAM
200 0000
0 201 0009
PC 081H 202 0006
Instr. Decoder
3FD
3FE
Control Unit 3FF
4
Computer Architecture (P. Leong) Instruction execution (page 22)
MOV CX,[201H] CX:=Memory[201H]
CPU 000
001
201H
CX
080 1A01H
081 3A02H
201H
ALU 082 2A00H
1A01H 1A01
RAM
1A01H
200 0000
201 0009
PC 081H 0 202 0006
1A01H
1A01H 1A01H
0 3FD
1, 2, 201H 201H 3FE
1, 2, 201H 3FF
0 5
Computer Architecture (P. Leong) Instruction execution (page 23)
MOV CX,[201H] CX:=Memory[201H]
CPU 000
201H 001
0009 201H
CX 0009
080 1A01H
081 3A02H
0009
ALU 082 2A00H
0009 0009
RAM
200 0000
0 201 0009
PC 081H 0 202 0006
1A01H
3FD
3FE
1, 2, 201H 3FF
6
Computer Architecture (P. Leong) Instruction execution (page 24)
ADD CX,[202H] CX:=CX+Memory[202H]
CPU 000
001
081H
CX 0009
080 1A01H
081 3A02H
081H
ALU 082 2A00H
RAM
200 0000
081H 201 0009
PC 081H 0 202 0006
0 3FD
0 3FE
3FF
7
Computer Architecture (P. Leong) Instruction execution (page 25)
ADD CX,[202H] CX:=CX+Memory[202H]
CPU 000
001
081H
CX 0009
080 1A01H
081 3A02H
ALU 082 2A00H
RAM
200 0000
201 0009
PC 081H + 1 0 202 0006
3FD
3FE
3FF
8
Computer Architecture (P. Leong) Instruction execution (page 26)
ADD CX,[202H] CX:=CX+Memory[202H]
CPU 000
001
202H 081H
0009
CX 0009
0009
202H 0009
080 1A01H
081 3A02H
3A02
ALU 0009 082 2A00H
0009 3A02H 3A02H
RAM
3A02H
200 0000
201 0009
PC 082H 0 0 202 0006
3A02H
3A02H 3A02H
0 3FD
3, 2, 202H 202H 3FE
3, 2, 202H 3FF
0 9
Computer Architecture (P. Leong) Instruction execution (page 27)
ADD CX,[202H] CX:=CX+Memory[202H]
CPU 000
001
000FH 202H 202H
CX 000FH
0009
000FH
080 1A01
081 3A02
ALU 082 2A00
0009 0006 0006
000FH ADD RAM
000FH
0006
000FH 0006
200 0000
201 0009
PC 082H 0 0 202 0006
3A02H
3FD
3FE
3, 2, 202H 3FF
10
Computer Architecture (P. Leong) Instruction execution (page 28)
MOV [200H],CX Memory[200H]:=CX
CPU 000
001
082H
CX 000FH
080 1A01H
081 3A02H
082H
ALU 082 2A00H
RAM
200 0000
082H 201 0009
PC 082H 0 202 0006
0 3FD
0 3FE
3FF
11
Computer Architecture (P. Leong) Instruction execution (page 29)
MOV [200H],CX Memory[200H]:=CX
CPU 000
001
082H
CX 000FH
080 1A01H
081 3A02H
ALU 082 2A00H
RAM
200 0000
201 0009
PC 082H + 1 0 202 0006
3FD
3FE
3FF
12
Computer Architecture (P. Leong) Instruction execution (page 30)
MOV [200H],CX Memory[200H]:=CX
CPU 000
001
200H 082H
000FH
CX 000FH
200H 000FH
000F
080 1A01H
081 3A02H
ALU 082 2A00H
2A00
000FH 2A00H
RAM
2A00H
200 0000
201 0009
PC 083H 1 1 202 0006
2A00H
2A00H 2A00H
1 3FD
2, 2, 200H 200H 3FE
2, 2, 200H 3FF
1 13
Computer Architecture (P. Leong) Instruction execution (page 31)
MOV [200H],CX Memory[200H]:=CX
CPU 000
200H 200H 001
CX 000FH
080 1A01H
081 3A02H
ALU 082 2A00H
00FH 00FH
RAM
200 000FH
0000
1 1 201 0009
PC 083H 202 0006
3FD
3FE
3FF
14
Computer Architecture (P. Leong) Instruction execution (page 32)
The Fetch-Execute Cycle - repeat forever
¾ FI - Fetch the Instruction (=load or read from memory) and Increment the
Program Counter
¾ IR <- MEM[PC], PC <- PC + 1
11. What would an instruction with the new addressing mode mean
if applied to the unconditional Jump?