QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which...
Transcript of QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which...
![Page 1: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/1.jpg)
QUIZ Pipelining
A computer pipeline has 4 processors, as shown above. Each processor takes 15 ms to execute, and each instruction must go sequentially through all 4 processors.
A program has 10 instructions. Calculate how long it takes to run it:
• without pipelining
• with pipelining
1
![Page 2: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/2.jpg)
Extra-credit QUIZ Pipelining -due next time-
2
![Page 3: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/3.jpg)
Low-level software
Components
Circuits
Gates
Transistors
![Page 4: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/4.jpg)
Abstractions and more abstractions …
4 You are here
![Page 5: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/5.jpg)
6.1 Computer Operations
Computer = programmable electronic device that can store, retrieve, and process data
Von Neumann architecture:
• Data and instructions to manipulate the data are represented in the same way (binary) and are stored in the same place (memory)
• For processing, both data and
instructions have to be brought
into the CPU (fetch-execute cycle)
5
![Page 6: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/6.jpg)
6.2 Machine Language
Machine language = The language made up of binary coded instructions built into the hardware of a particular computer and used directly by the computer
Why would anyone use machine language?
(Hint: they had no choice. Why?)
6 Image source: http://www.alpcentauri.info/chapter_18.html
![Page 7: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/7.jpg)
Remember: The Fetch-Execute Cycle
7
According to the CPU’s
machine language
![Page 8: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/8.jpg)
Characteristics of machine language:
– Every processor type has its own set of specific machine instructions
– The relationship between the processor and the instructions it can carry out is completely integrated
– Each machine-language instruction does only one very low-level task
8
![Page 9: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/9.jpg)
Pep/8 Virtual Computer
Virtual computer
A hypothetical machine designed to contain the important features of a real machine
Pep/8
A virtual computer designed by Stanley Warford that has 39 machine-language instructions
(We’re going to cover only a few of them!)
9
![Page 10: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/10.jpg)
Pep/8 Virtual Computer
Virtual computer
A hypothetical machine designed to contain the important features of a real machine
Pep/8
A virtual computer designed by Stanley Warford that has 39 machine-language instructions
(We’re going to cover only a few of them!)
10
Extra-credit for next time: Figure out what “Pep” and “8” stand for!
![Page 11: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/11.jpg)
Pep/8 Registers
– The program counter (PC) (contains the address of the next instruction to be executed)
– The instruction register (IR) (contains a copy of the instruction being executed)
– The accumulator (register A)
The memory unit is made up of 65,636 Bytes of storage
11
Can you figure out how long the Pep/8 address is?
![Page 12: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/12.jpg)
QUIZ
The previous version of Pep, Pep/7, could use only 12 bits for memory addresses.
How many Bytes of memory could Pep/7 address?
12
![Page 13: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/13.jpg)
13
Explain the
address format!
16 bits
24
bits
![Page 14: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/14.jpg)
14
Explain the
address format!
Can you show what
instructions look like
in memory?
![Page 15: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/15.jpg)
Instruction Format
15
![Page 16: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/16.jpg)
Instruction Format
Operation code, a.k.a. opcode Specifies which instruction is to be carried out Register specifier Specifies which register is to be used (only use A in
this chapter) Addressing-mode specifier Says how to interpret the operand part of the
instruction: • Direct • Immediate
16
Say that again?!?
![Page 17: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/17.jpg)
Instruction Format
Addressing-mode specifier Says how to interpret the operand part of the
instruction: • Direct • Immediate 2 + 3 Immediate A + B Direct
17
??
![Page 18: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/18.jpg)
18
Immediate and direct addressing modes
![Page 19: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/19.jpg)
Immediate and direct addressing modes
19
Example:
ADD 42 to accumulator A
What exactly am I to add?
![Page 20: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/20.jpg)
Instruction Format
20
Addressing modes:
• immediate
• direct
Is there something we are not telling you
about Pep’s addressing modes?
![Page 21: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/21.jpg)
QUIZ Pipelining
A computer pipeline has 5 stages.
Each stage takes 12 ns (nanosec.) to execute, and each instruction must go sequentially through all 5 stages.
A program has 20 instructions. Calculate how long it takes to run it:
• without pipelining
• with pipelining 21
![Page 22: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/22.jpg)
QUIZ
• Name all the 4 parts of the “fetch-execute” cycle.
• What do IR, A, and PC stand for in the computer’s architecture?
• Name and explain the 2 addressing modes we’ve covered.
22
![Page 23: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/23.jpg)
QUIZ: Immediate and direct addressing modes
23
SUB 31 from accumulator A
What exactly am I to
subtract?
![Page 24: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/24.jpg)
PEP/8 machine instructions
24
![Page 25: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/25.jpg)
25
What does this instruction mean, what is
its hex code, and what exactly does it do?
![Page 26: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/26.jpg)
26
What does this instruction mean, what is
its hex code, and what exactly does it do?
![Page 27: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/27.jpg)
27
What do these instructions mean, what are
their hex codes, and what exactly do they do?
![Page 28: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/28.jpg)
Wait a second ...
28
![Page 29: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/29.jpg)
Conclusions It is useless to write operands into IR.
IR should be written only in the FETCH stage of the Fetch-Execute cycle, when the 3 bytes of the instruction are brought from memory.
Operands can be written only to:
• Accumulator
• Memory
Some instructions cannot have the immediate addressing mode
29
![Page 30: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/30.jpg)
30
What do these instructions mean, what are
their hex codes, and what exactly do they do?
![Page 31: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/31.jpg)
Why is there only one on this page?
What does this instruction mean, what is
its hex code, and what exactly does it do?
![Page 32: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/32.jpg)
32
What do these instructions mean, what are
their hex codes, and what exactly do they do?
![Page 33: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/33.jpg)
QUIZ
• Name all the 4 parts of the “fetch-execute” cycle.
• What do IR, A, and PC stand for in the computer’s architecture?
• Name and explain the 2 addressing modes we’ve covered.
33
![Page 34: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/34.jpg)
Trick QUIZ: Immediate and direct addressing modes
34
We have this Pep
instruction:
LOAD 20 (decimal) into
accum. A
What exactly am I to load?
![Page 35: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/35.jpg)
Problem 16 / 189
35
The PEP/8 memory has the following contents:
0001 A2
0002 11
0003 00
0004 FF
What are the contents of reg. A after this instruction
is executed:
C1 00 01
![Page 36: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/36.jpg)
36
0001 A2
0002 11
0003 00
0004 FF
Instruction
executed:
C1 00 01
![Page 37: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/37.jpg)
Problem 17 / 190
37
The PEP/8 memory has the following contents:
0001 A2
0002 11
0003 00
0004 FF
What are the contents of reg. A after this instruction
is executed:
C1 00 02
The first step is …
![Page 38: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/38.jpg)
Problem 17 / 190
38
The PEP/8 memory has the following contents:
0001 A2
0002 11
0003 00
0004 FF
What are the contents of reg. A after this instruction
is executed:
C1 00 02
1100 0001 0000 0000 0000 0010
![Page 39: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/39.jpg)
6.3 Program to write "Hello"
39
Every program ends with this!
![Page 40: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/40.jpg)
Hand Simulation
40
What is the fetch/execute cycle?
How much is the PC incremented?
0 0 0 0
0000 50
0001 00
0002 48
0003 50
What ASCII character is this?
![Page 41: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/41.jpg)
Hand Simulation
41
What is the fetch/execute cycle here? What ASCII character is this?
0 0 0 0
![Page 42: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/42.jpg)
Your turn!
What does this program do?
1111
0000
1111
1 0000
![Page 43: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/43.jpg)
43
Steps for executing a machine-language
program
Loader
Program
in
memory Execute
Machine
code
program
in a file
on disk
![Page 44: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/44.jpg)
SKIP Pep/8 Simulator
44
![Page 45: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/45.jpg)
Problem 33 / 191
45
The PEP/8 computer has the following program in
memory (in hex):
0001 49
0002 00
0003 08
0004 51
0005 00
0006 08
0007 00
Convert the program to binary and
explain in your own words what it does.
![Page 46: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/46.jpg)
Problem 33 / 191
46
The PEP/8 computer has the following program in
memory (in hex):
0001 49
0002 00
0003 08
0004 51
0005 00
0006 08
0007 00 0008 ??
ASCII code of character
entered by user
Character input, direct mode, to
memory address 0x0008
Character output, direct mode, from
memory address 0x0008
STOP
![Page 47: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/47.jpg)
47
0001 49
0002 00
0003 08
0004 51
0005 00
0006 08
0007 00
0008 ?? ASCII code of character
entered by user
Character input, direct mode, to
memory address 0x0008
Character output, direct mode, from
memory address 0x0008
STOP
Code (
instr
uctions)
data
Remember: In a Von Neumann architecture,
code and data are stored in the same memory!
![Page 48: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/48.jpg)
Fact: Writing programs in machine language sucks!
(i.e. it is time-consuming, boring, error-prone, unintuitive, etc.)
48
![Page 49: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/49.jpg)
… that’s why they invented
assembly language
49
![Page 50: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/50.jpg)
6.4 Assembly Language
Assembly language
A language that uses mnemonic codes to represent machine-language instructions
Assembler A program that reads each of the instructions in mnemonic form and translates it into the machine-language equivalent
50
![Page 51: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/51.jpg)
51
Steps for executing an assembly-language program
Loader
Program
in
memory Execute
![Page 52: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/52.jpg)
Pep/8 Assembly Language
52
Opcode is 31
Opcode is 38
Opcode is 39
Opcode is 04
![Page 53: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/53.jpg)
“Hello” program in assembly
CHARO 0x0048, i ;Outputs character 'H'
CHARO 0x0065, i
CHARO 0x006C, i
CHARO 0x006C, i
CHARO 0x006F, i
STOP
.END
53
mnemonic operand addressing
mode comments
What in the
world is this?!
![Page 54: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/54.jpg)
A New Program
54
Problem: Read and sum three
values and print the sum
How would you do it by hand?
![Page 55: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/55.jpg)
Declaring variables in assembly: We simply reserve space in memory for them!
55
These are labels. They are placeholders for memory
addresses - the assembler will replace them with numeric
addresses when generating the machine code!
![Page 56: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/56.jpg)
Assembler directives, a.k.a. pseudo-ops
56
What is the difference between
operations and pseudo operations?
![Page 57: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/57.jpg)
Completed Program
57
sum: .WORD 0x0000
num1: .BLOCK 2
num2: .BLOCK 2
num3: .BLOCK 2
main: LDA sum,d
DECI num1,d
ADDA num1,d
DECI num2,d
ADDA num2,d
DECI num3,d
ADDA num3,d
STA sum,d
DECO sum,d
STOP
.END
![Page 58: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/58.jpg)
Completed Program
58
sum: .WORD 0x0000
num1: .BLOCK 2
num2: .BLOCK 2
Num3: .BLOCK 2
main: LDA sum,d
DECI num1,d
ADDA num1,d
DECI num2,d
ADDA num2,d
DECI num3,d
ADDA num3,d
STA sum,d
DECO sum,d
STOP
.END
Houston, we have a problem! How does the CPU know that the program starts here?
![Page 59: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/59.jpg)
Solution: “Branch” instruction
59
BR main
sum: .WORD 0x0000
num1: .BLOCK 2
num2: .BLOCK 2
num3: .BLOCK 2
main: LDA sum, d
DECI num1, d
ADDA num1, d
DECI num2, d
ADDA num2, d
DECI num3, d
ADDA num3, d
STA sum, d
DECO sum, d
STOP
.END
![Page 60: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/60.jpg)
QUIZ: Show the memory contents!
60
BR main
sum: .WORD 0x0000
num1: .BLOCK 2
num2: .BLOCK 2
num3: .BLOCK 2
main: LDA sum, d
DECI num1, d
ADDA num1, d
DECI num2, d
ADDA num2, d
DECI num3, d
ADDA num3, d
STA sum, d
DECO sum, d
STOP
.END Memory map on next slide
![Page 61: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/61.jpg)
61
![Page 62: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/62.jpg)
62
BR
LDA
DECI
ADDA
sum num1
num2
num3
DECI
![Page 63: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/63.jpg)
63
BR
LDA
DECI
ADDA
sum num1
num2
num3
DECI
Challenge: Write all the machine code (in hex)
![Page 64: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/64.jpg)
64
BR
LDA
DECI
ADDA
sum num1
num2
num3
DECI
Extra-credit
![Page 65: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/65.jpg)
65
Your turn! Change the program so it adds up four numbers
![Page 66: QUIZ Pipelining - Faculty Website Listing · Operation code, a.k.a. opcode Specifies which instruction is to be carried out ... Specifies which register is to be used (only use A](https://reader031.fdocuments.in/reader031/viewer/2022020319/5c878a4209d3f24c348c35aa/html5/thumbnails/66.jpg)
We have covered sections 6.1, 6.2, 6.3, and part
of 6.4.
• Read the text carefully and make sure you can explain in your own words what each instruction accomplishes.
Individual work (to do in notebook for next time):
16, 17, 19, 21-26
66
EoL2