quiz pipelining - tarleton state university · quiz: write an assembly program to subtract 20 10...
TRANSCRIPT
![Page 1: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/2.jpg)
2
Extra-credit QUIZ
![Page 3: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/3.jpg)
Low-level software
Components
Circuits
Gates
Transistors
![Page 4: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/4.jpg)
Abstractions and more abstractions …
4 You are here
![Page 5: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/7.jpg)
Remember: The Fetch-Execute Cycle
7
According to the CPU’s
machine language
![Page 8: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/10.jpg)
Extra-credit
10
![Page 11: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/13.jpg)
13
Explain the
address format!
16 bits
24
bits
![Page 14: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/14.jpg)
14
Explain the
address format!
Can you show what
instructions look like
in memory?
![Page 15: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/15.jpg)
Instruction Format
15
![Page 16: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/18.jpg)
18
Immediate and direct addressing modes
![Page 19: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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 - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/21.jpg)
PEP/8 machine instructions
21
![Page 22: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/22.jpg)
22
What does this instruction mean, what is
its hex code, and what exactly does it do?
![Page 23: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/23.jpg)
23
What does this instruction mean, what is
its hex code, and what exactly does it do?
![Page 24: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/24.jpg)
24
What do these instructions mean, what are
their hex codes, and what exactly do they do?
![Page 25: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/25.jpg)
Wait a second ...
25
![Page 26: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/26.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
26 EOL 1
![Page 27: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/27.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.
27
![Page 28: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/28.jpg)
QUIZ: Immediate and direct addressing modes
28
SUB 30 from accumulator A
What exactly am I to
subtract?
![Page 29: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/29.jpg)
29
What do these instructions mean, what are
their hex codes, and what exactly do they do?
![Page 30: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/30.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 31: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/31.jpg)
31
What do these instructions mean, what are
their hex codes, and what exactly do they do?
![Page 32: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/32.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.
32
![Page 33: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/33.jpg)
Immediate and direct addressing modes
33
We have this Pep
instruction:
LOAD 20 (decimal) into
accum. A
What exactly am I to load?
![Page 34: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/34.jpg)
Problem 16 / 189
34
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 35: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/35.jpg)
35
0001 A2
0002 11
0003 00
0004 FF
Instruction
executed:
C1 00 01
![Page 36: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/36.jpg)
Problem 17 / 190
36
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 37: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/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
1100 0001 0000 0000 0000 0010
![Page 38: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/38.jpg)
6.3 Program to write "Hello"
38
Every program ends with this!
![Page 39: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/39.jpg)
Hand Simulation
39
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 40: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/40.jpg)
Hand Simulation
40
What is the fetch/execute cycle here? What ASCII character is this?
0 0 0 0
![Page 41: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/41.jpg)
Your turn!
What does this program do?
1111
0000
1111
1 0000
![Page 42: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/42.jpg)
42
Steps for executing a machine-language
program
Loader
Program
in
memory Execute
Machine
code
program
in a file
on disk
![Page 43: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/43.jpg)
SKIP Pep/8 Simulator
43 EOL 2
![Page 44: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/44.jpg)
Problem 33 / 191
44
The PEP/8 memory 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 45: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/45.jpg)
Fact: Writing programs in machine language sucks!
(i.e. it is time-consuming, boring, error-prone, unintuitive, etc.)
45
![Page 46: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/46.jpg)
… that’s why they invented
assembly language
46
![Page 47: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/47.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
47
![Page 48: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/48.jpg)
48
Steps for executing an assembly-language program
Loader
Program
in
memory Execute
![Page 49: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/49.jpg)
Pep/8 Assembly Language
49
Opcode is 31
Opcode is 38
Opcode is 39
Opcode is 04
![Page 50: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/50.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
50
mnemonic operand addressing
mode comments
What in the
world is this?!
![Page 51: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/51.jpg)
A New Program
51
Problem: Read and sum three
values and print the sum
How would you do it by hand?
![Page 52: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/52.jpg)
Declaring variables in assembly: We simply reserve space in memory for them!
52
Labels – they are just
placeholders for
memory addresses
![Page 53: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/53.jpg)
Assembler directives, a.k.a. pseudo-ops
53
What is the difference between
operations and pseudo operations?
![Page 54: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/54.jpg)
Completed Program
54
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 55: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/55.jpg)
Completed Program
55
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 56: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/56.jpg)
Solution: “Branch” instruction
56
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
See comments on
next slide
![Page 57: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/57.jpg)
57
Completed Program Unconditional
branch!
![Page 58: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/58.jpg)
58
Your turn! Change the program so it adds only two numbers: always 7 + 42
![Page 59: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/59.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
59
EoL4
![Page 60: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/60.jpg)
QUIZ: Write an assembly program to subtract 2010 from 4210 and put the result in memory
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
Take inspiration from the
program we studied last time:
EOL
![Page 61: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/61.jpg)
Decision-making instructions
61
BR Set PC to operand unconditionally
BRLT i Set PC to operand if A < 0
BREQ i Set PC to operand if A = 0
![Page 62: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/62.jpg)
Decision making problem: Same as previous “sum” program, but print the sum only if positive or zero; if negative, print an error message
62
negMsg: CHARO 0x0045,i
BR finish
main: LDA sum,d
…
BRLT negMsg
STA sum,d
DECO sum,d
finish: STOP
What ASCII code is this?
![Page 63: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/63.jpg)
Decision making problem: Same as before, but print the sum only if positive or zero; if negative, print the letter ‘E’ (Error)
negMsg: CHARO 0x0045,i
BR finish
main: LDA sum,d
…
BRLT negMsg
STA sum,d
DECO sum,d
finish: STOP
How many ways are there to reach finish?
ASCII code for 'E'
![Page 64: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/64.jpg)
QUIZ: What does this program do?
64
BR main
a: .BLOCK 2
main: DECI a, d
LDA a, d
SUBA 0x002A, i
STA a, d
DECO a, d
STOP
.END
![Page 65: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/65.jpg)
QUIZ: What does this program do?
65
BR main
a: .BLOCK 2
main: DECI a, d
LDA a, d
SUBA 0x002A, i
STA a, d
BREQ yes
DECO a, d
fin: STOP
yes: CHARO 0x0046, i
BR fin
.END
ASCII code for 'F'
![Page 66: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/66.jpg)
QUIZ: Would the decision program from the first example still work if the negMsg block were placed after the main program instead of before?
66
main: LDA sum,d
…
BRLT negMsg
STA sum,d
DECO sum,d
finish: STOP
negMsg: CHARO 0x0045,i
BR finish
![Page 67: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/67.jpg)
67
What does this program do? (p.173)
CPA must
always be
followed by a
conditional
branch!
![Page 68: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/68.jpg)
QUIZ: PEP Assembly
Write a program that adds the number 3 to a number entered by the user, and prints the result if equal to zero, otherwise it prints nothing.
68
![Page 69: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/69.jpg)
QUIZ: PEP Assembly
Write a program that adds the number 3 to a number entered by the user, and prints the result if less than zero, otherwise it prints nothing.
69
![Page 70: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/70.jpg)
QUIZ: PEP Assembly
Write a program that adds the number 3 to a number entered by the user, and prints the result if greater than zero, otherwise it prints nothing.
70
![Page 71: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/71.jpg)
High-level software (Ch.9)
Algorithms (and data structures)
Low-level software
Components
Circuits
Gates
Transistors
![Page 72: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/72.jpg)
6.5 Algorithms and Pseudocode
Algorithm = A sequence of steps for solving a problem
Muḥammad ibn Mūsā al-Khwārizmī (780-850A.D.)
72
![Page 73: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/73.jpg)
Remember: Decision-making instructions
73
BR Set PC to operand unconditionally
BRLT i Set PC to operand if A < 0
BREQ i Set PC to operand if A = 0
![Page 74: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/74.jpg)
How to describe an algorithm in an intuitive way?
74
Flowcharts!
Not in text
We use decision-making instructions to build:
• branches
• loops
![Page 75: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/75.jpg)
Problems with flowcharts: • They’re hard to follow when they get complex
75
Not in text
![Page 76: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/76.jpg)
Problems with flowcharts: • They’re hard to follow when they get complex
• They’re hard to draw in electronic documents
76
Not in text
![Page 77: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/77.jpg)
Problems with flowcharts: • They’re hard to follow when they get complex
• They’re hard to draw in electronic documents
77
Not in text
Our text uses only pseudocode
![Page 78: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/78.jpg)
6.5 Algorithms and Pseudocode
Pseudocode = A mixture of English and formatting to make the steps in an algorithm explicit
There are no syntax rules in pseudocode!
Pseudocode is not case sensitive!
Example: Repeated-division algorithm (convert base-10 number to other bases):
78
While ( the quotient is not zero )
Divide the decimal number by the new base
Make the remainder the next digit to the left in the answer
Replace the original decimal number with the quotient
![Page 79: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/79.jpg)
Algorithms can also be described in natural language!
79
![Page 80: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/80.jpg)
… but pseudocode is more precise
80
IF concerned about cholesterol
Put butter substitute in a pot
ELSE
Put butter in a pot
Turn on burner
Put pot on the burner
WHILE (NOT bubbling)
Leave pot on the burner
Put other ingredients in the blender
Turn on blender
WHILE (more in pot)
Pour contents into lender in slow steam
Turn off blender
![Page 81: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/81.jpg)
Draw the flowchart for this pseudocode
81
IF concerned about cholesterol
Put butter substitute in a pot
ELSE
Put butter in a pot
Turn on burner
Put pot on the burner
WHILE (NOT bubbling)
Leave pot on the burner
Put other ingredients in the blender
Turn on blender
WHILE (more in pot)
Pour contents into lender in slow steam
Turn off blender
![Page 82: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/82.jpg)
Pseudocode functionality
Pseudocode has all of the concepts encountered in any high-level programming language, only the syntax is informal:
– Variables
– Assignment
– I/O
– Selection / decision
– Repetition / loop
– Boolean expressions
82
![Page 83: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/83.jpg)
To do for next time
Read pp.175-179 of the text, referring to your Python experience
83
![Page 84: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/84.jpg)
We can test a pseudocode algorithm w/pencil & paper, a.k.a. “desk checking”
84
What is 93 in base 8?
93/8 gives 11 remainder 5
11/8 gives 1 remainder 3
1/ 8 gives 0 remainder 1
answer 1 3 5
While ( the quotient is not zero )
Divide the decimal number by the new base
Make the remainder the next digit to the left in the answer
Replace the original decimal number with
![Page 85: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/85.jpg)
85
Organizing the solution in a computer-like way gives us
better idea of what is required for the computer to
execute it, e.g. two numbers need to be entered, etc.
![Page 86: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/86.jpg)
86
QUIZ: Desk-check the repeated division algorithm
with decimalNumber = 242, and newBase = 8
![Page 87: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/87.jpg)
87
Answer: 362
![Page 88: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/88.jpg)
Translating a pseudocode algorithm
88
How we translate depends on the
language into which we are translating!
The text example (pp.184-5) is with
translation into PEP assembly, but in class
we’re translating the repeated division alg.
into Python!
![Page 89: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/89.jpg)
Develop this code step-by-step!
89
![Page 90: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/90.jpg)
SKIP 6.6 Testing
90
![Page 91: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/91.jpg)
Read and take notes in notebook:
Software Piracy and Copyrighting
Have you every "borrowed" software
from a friend?
Have you ever "lent" software to a
friend?
Did you know that about 100,000 jobs are
lost in the US every year due to such
"borrowing" and "lending?"
91
![Page 92: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/92.jpg)
Chapter Review Questions
• List the operations that a computer can perform
• Describe the important features of the Pep/8 virtual machine
• Distinguish between immediate addressing mode and direct addressing mode
• Write a simple machine-language program
• Distinguish between machine language and assembly language
92
![Page 93: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/93.jpg)
Chapter Review Questions
• Describe the steps in creating and running an assembly-language program
• Write a simple program in assembly program
• Distinguish between instructions to the assembler (a.k.a. directives) and instructions to be translated into machine code (a.k.a. executable instructions)
• Distinguish between following an algorithm and developing one
93
![Page 94: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/94.jpg)
Chapter Review Questions
• Describe the pseudocode constructs used in expressing an algorithm
• Use pseudocode to express and algorithm
• Distinguish between black-box and clear-box testing
94
![Page 95: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/95.jpg)
Homework Due Friday, Apr. 8
End of chapter exercises
10, 11, 12, 13, 14, 15
18, 20, 27, 34, 36, 41
Correction in 20: use E1 instead of E0
Hint for 34: machine code 31 means decimal input
Hint for 41: How are integers represented in Pep/8?
44, 45
![Page 96: QUIZ Pipelining - Tarleton State University · QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory 60 BR main sum: .WORD 0x0000 num1: .BLOCK](https://reader034.vdocuments.us/reader034/viewer/2022050120/5f5077e1deafa07a5f383c4c/html5/thumbnails/96.jpg)
All PEP instructions, with machine codes 00 Stop STOP
04 Branch unconditional BR
08 Branch if Less Than BRLT
0A Branch if equal BREQ
31 Decimal Input Direct DECI
38 Decimal Output Immediate DECO
39 Decimal Output Direct DECO
49 Char. Input Direct CHARI
50 Char. Output Immediate CHARO
51 Char. Output Direct CHARO
70 Add to A Immediate ADDA
71 Add to A Direct ADDA
80 Subtract from A Immediate SUBA
81 Subtract from A Direct SUBA
C0 Load into A Immediate LDA
C1 Load into A Direct LDA
E1 Store A Direct STA 96