BiD 07
BiD 07
Nizamettin AYDIN
naydin@yildiz.edu.tr
http://www.yildiz.edu.tr/~naydin
C Fortran Ada etc. Basic Java
Compiler
Compiler Compiler
Compiler
Assembler
Assembler Interpreter
Interpreter
Executable
HW HW HW
Implementation 1 Implementation 2 Implementation N
Instruction Set
• Instruction: Language of the machine
• Machine Code
— machine readable
— Binary(example: 1000110010100000)
—Main memory
—Virtual memory
—Cache
—CPU register
—I/O device
Instruction Representation
• In machine code each instruction has a
unique bit pattern
• For human consumption a symbolic
representation is used (assembly language)
• Opcodes are represented by abbreviations,
called mnemonics indicating the operation
— ADD, SUB, LDA, BRP, ...
• In an assembly language, operands can also
be represented as following
—ADD A,B (add contents of B and A and save
the result into A)
Simple Instruction Format
• Following is a 16 bit instruction format
• So...
—What is the maximum number of instructions
in this processor?
—What is the maximum directly addressable
memory size?
Instruction Set Classification
• One way
—Number of operands for typical arithmetic
instruction
add $s1, $s2, $s3
3
—What are the possibilities?
• Example: a = b + c;
• Example: a = b + c;
LOAD b # ACC b
ADD c # ACC ACC + c
STORE a # a ACC
VVM
Two Address Machine (1)
• a.k.a. Register-Memory Instruction Set
• One operand may be a value from
memory
• Machine has n general purpose registers
—$0 through $n-1
• Example: a = b + c;
• Example: a = b + c;
• Example: a = b + c;
• Example: a = b + c;
• Fewer addresses
—Less complex (powerful?) instructions
—More instructions per program
—Faster fetch/execution of instructions
Types of Operand
• Addresses
—Operand is in the address
• Numbers (actual operand)
—Integer or fixed point
—floating point
—decimal
• Characters (actual operand)
—ASCII etc.
• Logical Data (actual operand)
—Bits or flags
Pentium Data Types
• Data Transfer
• Arithmetic
• Logical
• Conversion
• I/O
• System Control
• Transfer of Control
Data Transfer
• Need to specify
—Source
—Destination
—Amount of data
• For example:
—Binary to Decimal conversion
Input/Output
• Privileged instructions
• Skip
—e.g. increment and skip if zero
—ISZ Register1
—Branch xxxx
—ADD A
• Subroutine call
—c.f. interrupt call
Branch Instruction
Nested Procedure Calls
Use of Stack
Types of
Operation
Types of
Operation
CPU Actions for Various Types of Operations
Pentium Operation
Types
Pentium Condition Codes
Pentium Conditions for Conditional Jump and
SETcc Instructions
MMX
Instruction Set
PowerPC
Operation Types
PowerPC Operation Types
Byte Ordering
• Some conventions
—Sun’s, Mac’s are “Big Endian” machines
– Least significant byte has highest address
—Alphas, PC’s are “Little Endian” machines
– Least significant byte has lowest address
Byte Ordering Example
• Big Endian
—Least significant byte has highest address
• Little Endian
—Least significant byte has lowest address
• Example
—Variable x has 4-byte representation
0x01234567
—Address given by &x is 0x100
Big Endian 0x100 0x101 0x102 0x103
01 23 45 67