Download Lecture 26

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Computer Organization I
Lecture 25: Basics on Instruction Sets
Overview
Characteristics and Functions of General Instruction
Set, and specific instruction set of M68HC11
Objectives
To understand the main characteristics and functions of
basic instruction set.
What is an Instruction Set?
• The complete collection of instructions that are
understood by a CPU
• Machine Code
• Binary
• Usually represented by assembly codes
Elements of an Instruction?
• Operation code (Op code)
– Do this
• Source Operand reference
– To this
• Result Operand reference
– Put the answer here
• Next Instruction Reference
– When you have done that, do this..., usually the next
instruction to be fetched immediately follows the
current instruction
Instruction Cycle State Diagram?
Instruction Representation
• In machine code each instruction has a unique
bit pattern
• For human consumption (well, programmers
anyway) a symbolic representation is used
– e.g. ADD, SUB, LOAD
• Operands can also be represented in this way
– ADD A,B
Simple Instruction Format
Number of addresses (a)
• 3 addresses
– Operand 1, Operand 2, Result
– a = b + c;
– Not common
– Needs very long words to hold everything
Number of addresses (b)
• 2 addresses
– One address doubles as operand and result
–a=a+b
– Reduces length of instruction
– Requires some extra work
• Temporary storage to hold some results, e.g. register
Number of addresses (c)
• 1 address
– Implicit second address
– Usually a register (accumulator)
– Common on early machines
Number of addresses (d)
• 0 (zero) addresses
– All addresses implicit
– Uses a stack
– e.g. push a
–
push b
–
add
–
pop c
–c=a+b
Design Program using Machine Instructions
• Operation repertoire, e.g. using M68HC11
– How many ops?
– What can they do?
– How complex are they?
• Data (operand) types: addresses, numbers, characters, logic data
• Instruction formats
– Length of op code field
– Number of addresses
• Registers
– Number of CPU registers available
– Which operations can be performed on which registers
Type of Operation
•
•
•
•
Data Transfer
Arithmetic
Logical
Transfer of Control
Data Transfer
Almost all activities involve transferring data from memories into the CPU
or transferring results from the CPU into memory.
•Specify
– Source
– Destination
•May be different instructions for different movements
Data Transfer
– e.g. M68HC11
Arithmetic
Add, Subtract, Multiply, Divide
Arithmetic
on HC11 instruction set, the arithmetic instructions support operations
on a variety of operands;
Arithmetic
For example: the adding instructions
• The ADD family adds either a register, or memory value to an
accumulator
– ABA - add acc. B to acc. A
– ABX - add acc. B to index reg. X
– ABY - add acc. B to index reg. Y
• ADDA #$13 - add the number $13 to acc. A
• ADDB $64 - add mem[$64] to acc. B
• ADDD 10,Y - add mem[10+Y],[10+Y+1] to acc. D
• If Y = 30 and mem[40] = $12, mem[41]=$A2, then
$12A2 is added to D
Logical
Logical
In M68HC11, the logical instructions are used to perform the Boolean
logical operations AND, OR, exclusive OR, and one’s complement.
Shift and Rotate Operations Logical
Shift and Rotate Operations
Shift and Rotate Operations
In M68HC11, all the shift and rotate functions involve the carry bit in the
condition code register in addition to the 8- or 16-bit operand in the
instruction, which permits easy extension to multiple-word operands.
Summary
• Characteristics and functions of Instruction Set
Thank you
Q&A