chapter 7 low-level programming languages. 2 features in pep/7 figure 7.1 pep/7’s architecture

28
Chapter 7 Low-Level Programming Languages

Upload: lynne-hoover

Post on 14-Dec-2015

221 views

Category:

Documents


2 download

TRANSCRIPT

Chapter 7

Low-Level Programming Languages

2

Features in Pep/7

Figure 7.1 Pep/7’s architecture

3

Instruction Format

Figure 7.2 The Pep/7 instruction format

4

Instruction Format

Figure 7.3 Difference between immediate-mode and direct-mode addressing

5

Some Sample Instructions

Figure 7.3 Subset of Pep/7 instructions

6

Sample Instructions

7

Sample Instructions

8

Sample Instructions

9

Sample Instructions

10

Algorithms

Write "H"Write 48 (hex)

Write "e"Write 65 (hex)

.

.

.Write "o"

Write 6F (hex)

11

A Program Example

12

Hand Simulation

13

Hand Simulation

14

Hand Simulation

15

Pep/7 Simulator

16

Pep/7 Simulator

17

Pep/7 Assembly Language

18

Pep/7 Assembly Language

19

Assembly Process

20

A New Program

Reading and adding three numbersSet sum to 0Read num1Add num1 to sumRead num2Add num2 to sumRead num3Add num3 to sumWrite sum

21

Our Completed Program

22

Decision Making

23

Decision Making

…Add num3 to sumIf sum is negative

Write "Error"Else

Write sum

Write "Error" if sum is negative.

24

Decision Making

Add num3 to sumIf status bit N is 1

Go to NegMsgWrite sumQuit: STOPNegMsg: Write the message and go to Quit

25

Decision Making

Read limitSet sum to 0While (limit is not zero)

Read numberSet sum to sum + numberSet limit to limit - 1

26

Decision Making

Set the accumulator to limitSubtract one from the accumulatorCompare accumulator to zeroIf status bit Z is 1

go to QuitElse

go to Read

27

Decision Making

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