Transcript Write "e"

Chapter 7
Low-Level Programming
Languages
Features in Pep/7
Figure 7.1 Pep/7’s architecture
2
Instruction Format
Figure 7.2 The Pep/7 instruction format
3
Instruction Format
Figure 7.3 Difference between immediate-mode and direct-mode addressing
4
Some Sample Instructions
Figure 7.3 Subset of Pep/7 instructions
5
Sample Instructions
6
Sample Instructions
7
Sample Instructions
8
Sample Instructions
9
Algorithms
Write "H"
Write 48 (hex)
Write "e"
Write 65 (hex)
.
.
.
Write "o"
Write 6F (hex)
10
A Program Example
11
Hand Simulation
12
Hand Simulation
13
Hand Simulation
14
Pep/7 Simulator
15
Pep/7 Simulator
16
Pep/7 Assembly Language
17
Pep/7 Assembly Language
18
Assembly Process
19
A New Program
Reading and adding three numbers
Set sum to 0
Read num1
Add num1 to sum
Read num2
Add num2 to sum
Read num3
Add num3 to sum
Write sum
20
Our Completed Program
21
Decision Making
22
Decision Making
Write "Error" if sum is negative.
…
Add num3 to sum
If sum is negative
Write "Error"
Else
Write sum
23
Decision Making
Add num3 to sum
If status bit N is 1
Go to NegMsg
Write sum
Quit: STOP
NegMsg: Write the message and go to Quit
24
Decision Making
Read limit
Set sum to 0
While (limit is not zero)
Read number
Set sum to sum + number
Set limit to limit - 1
25
Decision Making
Set the accumulator to limit
Subtract one from the accumulator
Compare accumulator to zero
If status bit Z is 1
go to Quit
Else
go to Read
26
Decision Making
27
What do you think?
Suppose the government no longer required
physical crash tests for new cars. What
factors might you consider before buying a
car that was crash tested only by
computer simulation?
28