0% found this document useful (0 votes)
10 views

HF Low Level Programming (Half)

The document discusses machine language and assembly language. It describes a virtual computer called Pep/8 and its instruction set. Sample machine language and assembly language programs are shown that can be run on a Pep/8 simulator.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

HF Low Level Programming (Half)

The document discusses machine language and assembly language. It describes a virtual computer called Pep/8 and its instruction set. Sample machine language and assembly language programs are shown that can be run on a Pep/8 simulator.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

The way computers are

programmed at machine level:


Machine Language and Assembler
CHAPTER 6
` Describe the important features of the
Pep/8 virtual machine
` Distinguish between immediate mode
addressing and direct addressing
` Convert a simple algorithm into a machine-
language program
` Describe the Pep/8 simulator, and use it to
run machine language programs
` Distinguish between machine language and
assembly language
` Convert a simple algorithm into an assembly
language program
` Distinguish between instructions to the
assembler and instructions to be translated
` Use the Pep/8 simulator to assemble and
run simple assembly language programs.
Computer
A stored instruction electronic device that can
store, retrieve, and process data

Data and instructions to manipulate the data


are logically the same and can be stored in
the same place
Machine language
The language made up of binary coded
instructions built into the hardware of a
particular computer and used directly by the
computer
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
Virrtual computer
A hypothetical machine designed to
demonstrate the important features of a real
computer that we want to illustrate
Pep/8
A virtual computer designed by Stanley Warford
that has 39 machine-language instructions
Pep/8’s

Pep/8’s

FFFE
FFFF
Pep/8 Registers & Status Bits
◦ 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 (A register)
◦ Status bit N (1 if register A is negative; 0
otherwise)
◦ Status bit Z (1 if the register A is 0; and 0
otherwise)
The memory unit is made up of 65 536 (164) bytes
` Specify the OPERATION required e.g.
◦ STOP the program
◦ ADD values
◦ STORE a value in memory
◦ FIND something in memory
` Specify WHERE the action is to take place e.g.
◦ Which register
` Specify WHERE the value is to be found or
stored in memory…or specify the value itself.
WHAT to do

WHERE or WHAT it is
WHAT to do

WHERE or WHAT it is
Operation code
Specifies which instruction is to be carried
out
Register specifier
Specifies which register is to be used (we
only use A)
Addressing-mode specifier
Says how to interpret the operand part of the
instruction
0 0 0

0 0 1
0000
1100
1110
0111
1000
01001
01010
0000 STOP EXECUTION 0 0 0 0 0 0 0 0

1100 LOAD OPERAND into the A REGISTER


` Immediate addressing case:
Instruction specifier: 1 1 0 0 0 0 0 0

Operand specifier: 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

What happens?
` Direct addressing case:
Instruction specifier: 1 1 0 0 0 0 0 1

Operand specifier: 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

What happens now?


0000
1100
What do these 1110
0111
Instructions do? 1000
01001
01010
0 1 1 1 0 0 0 0

1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1

0 1 1 1 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1

0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0000
1100
What do these 1110
0111
Instructions do? 1000
01001
01010
1 1 1 0 0 0 0 1

0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0

1 1 1 0 0 0 0 0

0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0
0000
1100
What do these 1110
0111
Instructions do? 1000
01001
01010
0 1 0 0 1 0 0 1

0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0

0 1 0 1 0 0 0 0

0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1

0 1 0 0 1 0 0 1
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1
A Program to 0000
ask for 1100
1110
Help! 0111
1000
01001
01010
0 1 0 1 0 0 0 0 50
0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 00 48

0 1 0 1 0 0 0 0
50
0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 00 65
0 1 0 1 0 0 0 0 50
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 00 6C
0 1 0 1 0 0 0 0 50
0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 00 48

0 1 0 1 0 0 0 0 50
0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 00 65
0 1 0 1 0 0 0 0 50
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 00 6C

0 1 0 1 0 0 0 0 50
0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 1 00 70
0 1 0 1 0 0 0 0
50
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 00 21

0 0 0 0 0 0 0 0 00
Pep/8 Simulator
A program that behaves just like the Pep/8 virtual
machine behaves

To run a program
Enter the hexadecimal code, byte by byte with blanks
between each

Terminate by inserting zz

Load the program

Run Object Code


` Download the Pep/8 Simulator from:

` http://code.google.com/p/pep8-1/

` Pep813Win.zip

` Now loaded on lab machines.


Program to 0000
Add Numbers 1100
1110
0111
1000
00110
01001 Read in a decimal number
00111
01010 Read out a decimal number

1 1 0 0 0 0 0 0 C0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 00

0 0 1 1 0 0 0 1
31
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 00 12
0 1 1 1 0 0 0 1 71
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 00 12
1 1 0 0 0 0 0 0 C0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 00

0 0 1 1 0 0 0 1 31
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 00 12
0 1 1 1 0 0 0 1 71
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 00 12
0 0 1 1 0 0 0 1 31
0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 00 14
0 1 1 1 0 0 0 1 71
0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 00 14
1 1 1 0 0 0 0 1 E1
0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 00 16
0 0 1 1 1 0 0 1 39
0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 00 16
0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 C0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 00

0 0 1 1 0 0 0 1 31
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 00 30
0 1 1 1 0 0 0 1 71
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 00 30
0 0 1 1 0 0 0 1 31
0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 00 38
0 1 1 1 0 0 0 1 71
0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 00 38
1 1 1 0 0 0 0 1 E1
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 00 40
0 0 1 1 1 0 0 1 39
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 00 40
0 0 0 0 0 0 0 0

You might also like