Upload
raine
View
36
Download
0
Embed Size (px)
DESCRIPTION
Program Execution. Preparation. The assembly language version is assembled into a machine language executable The executable is copied into main memory The Program Counter Register is loaded with the address of the first instruction in the program. Woody's instruction cycle. - PowerPoint PPT Presentation
Citation preview
Program Execution
Preparation
The assembly language version is assembled into a machine language executable
The executable is copied into main memory
The Program Counter Register is loaded with the address of the first instruction in the program
Woody's instruction cycle
1. Copy the word referred to by the Program Counter into the Instruction Register
2. Add 1 to the address in the Program Counter
3. Decode and execute the contents of the Instruction Register
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00000000
ProgramCounter
00000
DataRegister
00000000
Input Unit Output Unit
Initial state of memory after loading program and setting PC to 00000
1
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00000000
ProgramCounter
00000
DataRegister
00000000
Input Unit Output Unit
1. Copy word referred to by PC into Instruction register
2
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00000000
ProgramCounter
00000
DataRegister
00000000
Input Unit Output Unit
1. Copy word referred to by PC into Instruction register
3
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00000
DataRegister
00000000
Input Unit Output Unit
1. Copy word referred to by PC into Instruction register
4
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
00000000
Input Unit Output Unit
2. Add 1 to the Program Counter
5
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
00000000
Input Unit Output Unit
3. Decode and Execute instruction
6
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
00000000
Input Unit Output Unit
3. Decode and Execute instruction – 000 is op code for CopyFrom
7
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
00000000
Input Unit Output Unit
3. Decode and Execute instruction – 01001 is address to copy from
8
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
00000000
Input Unit Output Unit
3. Decode and Execute instruction – 01001 is address to copy from
9
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
10000001
Input Unit Output Unit
3. Decode and Execute instruction – Instruction execution is complete
10
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001001
ProgramCounter
00001
DataRegister
10000001
Input Unit Output Unit
Repeat: 1. Copy word referred to by PC to IR
11
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00001
DataRegister
10000001
Input Unit Output Unit
Repeat: 1. Copy word referred to by PC to IR
12
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00010
DataRegister
10000001
Input Unit Output Unit
2. Add 1 to PC
13
00000 00001001 CopyFrom 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00010
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction
14
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00010
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction – 110 is the op code for IfNegGoTo
15
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00010
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction – Check value in data register
16
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00010
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction – DR value is -1
17
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00010
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction – Copy rightmost 5 bits of IR to PC
18
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00101
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction – execution is complete
19
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11000101
ProgramCounter
00101
DataRegister
10000001
Input Unit Output Unit
1. Copy word referred to by PC to IR
20
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00101
DataRegister
10000001
Input Unit Output Unit
1. Copy word referred to by PC to IR
21
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00110
DataRegister
10000001
Input Unit Output Unit
2. Add 1 to PC
22
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00110
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction
23
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00110
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction – 000 is op code for CopyFrom
24
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00110
DataRegister
10000001
Input Unit Output Unit
3. Decode and execute instruction
25
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00110
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction – copy value to DR. Execution complete.
26
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00001010
ProgramCounter
00110
DataRegister
00000110
Input Unit Output Unit
1. Copy word referred to by PC to IR.
27
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00110
DataRegister
00000110
Input Unit Output Unit
1. Copy word referred to by PC to IR.
28
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
2. Add 1 to PC
29
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction
30
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction – 011 is Subtract
31
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction – data register is first operand
32
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction – data register is first operand
33
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction – word at 01100 is second operand
34
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction – word at 01100 is second operand
35
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction: (6 – 1) = 5. Result is stored in DR.
36
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000110
Input Unit Output Unit
3. Decode and execute instruction: (6 – 1) = 5. Result is stored in DR.
37
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction: (6 – 1) = 5. Result is stored in DR.
38
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
01101100
ProgramCounter
00111
DataRegister
00000101
Input Unit Output Unit
1. Copy word referred to by PC to IR.
39
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
00111
DataRegister
00000101
Input Unit Output Unit
1. Copy word referred to by PC to IR.
40
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
2. Add 1 to PC
41
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction
42
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction – 001 is CopyTo
43
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction – 01010 is target location
44
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000101 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction – value in DR copied to memory
45
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000101 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00101010
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
1. Copy word referred to by PC to IR
46
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000101 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11100000
ProgramCounter
01000
DataRegister
00000101
Input Unit Output Unit
1. Copy word referred to by PC to IR
47
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000101 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11100000
ProgramCounter
01001
DataRegister
00000101
Input Unit Output Unit
2. Add 1 to PC
48
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000101 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11100000
ProgramCounter
01001
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction
49
00000 00001001 CopyFrom 10000 00000000
00001 11000101 IfNegGoTo 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 CopyFrom 10101 00000000
00110 01101100 Subtract 10110 00000000
00111 00101010 CopyTo 10111 00000000
01000 11100000 11000 00000000
01001 10000001 11001 00000000
01010 00000101 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
11100000
ProgramCounter
01001
DataRegister
00000101
Input Unit Output Unit
3. Decode and execute instruction – 111 is op code for Stop
50
Key points• Only programs for which the instructions
and data are in the appropriate machine language format can be executed by a computer.
• Assembly language substitutes meaningful names for instructions and conventional notation for numeric values
• Assembly language programs can be mechanically translated to machine language
Is Assembly Language a "real" language?
Is Assembly Language a "real" language?
• Computers don't understand the instructions or data used in AL programs
Is Assembly Language a "real" language?
• Computers don't understand the instructions or data used in AL programs
• Assembly language is a useful abstraction that helps humans interact with the computer.
Is Assembly Language a "real" language?
• Computers don't understand the instructions or data used in AL programs
• Assembly language is a useful abstraction that helps humans interact with the computer.
• The concept of memory locations is a useful abstraction for grids of transistors
Is Assembly Language a "real" language?
• Computers don't understand the instructions or data used in AL programs
• Assembly language is a useful abstraction that helps humans interact with the computer.
• The concept of memory locations is a useful abstraction for grids of transistors
• Maps are useful abstractions of the physical world.
The usefulness of computers is a direct result of the usefulness of the abstractions we have created for them.
00000 00001001 10000 00000000
00001 11000101 10001 00000000
00010 00001010 10010 00000000
00011 01001011 10011 00000000
00100 11100000 10100 00000000
00101 00001010 10101 00000000
00110 01101100 10110 00000000
00111 00101010 10111 00000000
01000 11100000 11000 00000000
01001 00000001 11001 00000000
01010 00000110 11010 00000000
01011 00000100 11011 00000000
01100 00000001 11100 00000000
01101 00000000 11101 00000000
01110 00000000 11110 00000000
01111 00000000 11111 00000000
Main MemoryCPU
InstructionRegister
00000000
ProgramCounter
00000
DataRegister
00000000
Input Unit Output Unit
Exercise: trace the execution of this program.