Machine Language
Machine Language
Introduction
It determines the Operation of the Processor
16 bit word
Floating point
◦ IEEE 754
◦ Single or double precision
Operand -Source
Main or Virtual Memory
Processor Register
Immediate
I/O Device
Instruction Representation
OpCode Operand Reference Operand Reference
(4 bits) (6 bits) (6 bits)
Instruction Types
Assume X = X + Y
◦ Load the register with value X
◦ Add the contents of register to the value Y
◦ Store the contents in the address of X
Data Processing – Arithmetic and Logical Instruction
Data Storage - Movement of data into or out of register and or
memory location
Data Movement – I / O instruction
Control – Test and Branching instruction
Number of Addresses
Zero Address – e.g. Break, End
Data Types
Instruction Format
Registers
Addressing
Types of Operands
Addresses
Numbers
◦ Binary Integer or fixed point
◦ Binary Floating Point
◦ Decimal
Characters
◦ ASCII, EBCDIC in IBM mainframe
Logical Data
Types of Operations
Data Transfer
Arithmetic
Logical
Conversion
I/O
System Control
Transfer of Control
Data Transfer – Processor Activities
Data transfer from one memory location to another
Check Cache
Store
Load
Exchange
Clear
Set
Push
Pop
Arithmetic – Processor Activities
Data Transfer before and/or after
Subtract
Multiply
Divide
Absolute
Negate
Increment
Decrement
Arithmetic – Single Operand
Absolute
Negate
Increment
Decrement
Logical
And
Or
Not
Ex-OR
Test
Compare
Rotate
Conversion
Type Conversion – Convert
◦ TR R1 (L), R2
Input / Output & System Control
Issue Command to I/O Module
Input (read)
Output (write)
Start I/O
Test I / O
Branch
◦ Conditional or Unconditional
Skip
◦ Skip if Zero (ISZ)
Procedure Call
◦ Reentrant Procedure, one type is Recursive Procedure Call
Transfer of Control
Transfer of Control
Use of Stack
Stack Frame Growth -Sample Procedures P and Q
System Control
Commands executed under privileged mode
184 12 78
185 34 56
186 56 34
186 78 12
The system on the left has the least significant byte in the lowest
address is called big-endian
The system on the right has the least significant byte in the
highest address is called little-endian
Example of C Data Structure
Alternative View of Memory Map
Standard…What Standard?
Pentium (80x86), VAX are little-endian
IBM 370, Moterola 680x0 (Mac), and most RISC are big-endian
Internet is big-endian
ADDRESSING MODE
Addressing Mode
Mode in which operands are addressed
Immediate
Direct
Indirect
Register
Register Indirect
Displacement
Stack
Immediate Addressing
Operand is part of instruction
e.g. ADD 5
◦ 5 is operand
Fast
Limited range
Immediate Addressing Diagram
Instruction
Opcode Operand
Addressing modes - Immediate
Direct Addressing
Address field contains address of operand
e.g. ADD A
Opcode Address A
Memory
Operand
Addressing modes - Direct
Indirect Addressing
Memory cell pointed to by address field contains the address of
(pointer to) the operand
EA = (A)
◦ e.g. EA = (((A)))
Hence slower
Indirect Addressing Diagram
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Addressing modes - Indirect
Register Addressing
Similar to direct addressing
EA = R
◦ Shorter instructions
◦ N.B. C programming
register int a;
Register Addressing Diagram
Instruction
Operand
Addressing modes - Register Direct
Register Indirect Addressing
Similar to indirect addressing
EA = (R)
Registers
@R
Displacement Addressing
Combines capability of direct and register indirect addressing
EA = A + (R)
◦ A = base value
◦ or vice versa
Displacement Addressing Diagram
Instruction
Registers
EA = A + (PC)
R = displacement
EA = A + R
◦ EA = A + R
◦ R++
AutoIndexing
Combinations
Postindex
EA = (A) + (R)
Preindex
EA = (A+(R))
Addressing modes - Indexed
Stack Addressing
Last in First Out
e.g.
Base register acts as index register for preindex and postindex addressing
Includes opcode
Number of operands
Address range
Address granularity
Instruction Set Architecture
Instruction set
Register set
Memory access information
ISA Attributes
Completeness
Orthogonality
Register set design
ISA Requirements
Backward compatibility
Data types/sizes
Interrupts
Conditional instructions
A Relatively Simple ISA - Registers
Accumulator AC
General purpose register R
Flag Z
The 8085 ISA - Instruction Set
Data movement instructions
The 8085 ISA - Instruction Set
Data operation instructions
The 8085 ISA - Instruction Set
Program control instructions
The 8085 ISA - Instruction Formats
Example 8085 Program
n
1 2 ... n, or i
i 1
1. i = n, sum = 0
2. sum = sum + i, i = i - 1
3. IF i 0 THEN GOTO 2
4. total = sum
Example 8085 Program Code
Example 8085 Program Trace
Comparison
Number of processors Only one processor is used More than one processor is used.
Additional processor (external) can
also be employed
201 DAT 2
202 DAT 3
203 DAT 4
204 DAT 0
Assembler Program
Label Operation Operand
FORMUL LDA I
ADD J
ADD K
STA N
I DATA 2
J DATA 3
K DATA 4
N DATA 0