Please enable JavaScript.
Coggle requires JavaScript to display documents.
T4: Microprocessor System - Coggle Diagram
T4: Microprocessor System
Machine Instruction Set 机器指令集
From the designer's point of view
the machine instruction set provides the functional requirements for the CPU
implementing执行 the CPU is a task that in large part involves implementing the machine instruction set
From the user's side
becomes aware of the register and memory structure, the types of data directly supported by the machine, and the functioning of the ALU
Machine instruction characteristic
The operation of the processor is determined by the instructions it executes, referred to as machine instructions or computer instructions
The collection of different instructions that the processor can execute is referred to as the processor’s instruction set
Each instruction must contain the information required by the processor for execution
Elements of Machine Instructions
Operation code
Specifies the operation to be performed (e.g. ADD, I/O)
The operation is specified by a binary code, known as the operation code, or opcode
Source operand reference
The operation may involve one or more source operands, that is, operands that are inputs for the operation
Result operand reference
The operation may produce a result
Next instruction reference
This tells the CPU where to fetch the next instruction after the execution of this instruction is complete
The next instruction to be fetched is located in main memory or a virtual memory system [either main memory or secondary memory (disk)]
In most cases, the next instruction to be fetched immediately follows the current instruction
In those cases, there is no explicit reference to the next instruction
Source and result operands can be in one of three areas
Main or virtual memory
As with next instruction references, the main or virtual memory address must be supplied
CPU register
With rare exceptions, a CPU contains one or more registers that may be referenced by machine instructions.
If only one register exists, reference to it may be implicit隐式.
If more than one register exists, then each register is assigned a unique number, and the instruction must contain the number of the desired register.
I/O device
The instruction must specify the I/O module and device for the operation
If memory-mapped I/O is used, this is just another main or virtual memory address
Instruction Representation
Each instruction is represented by a sequence of bits. The instruction is divided into fields, corresponding to the constituent elements of the instruction
During instruction execution, an instruction is read into an instruction register (IR) in the CPU
Machine instructions or opcodes are represented by abbreviations, called mnemonics, which indicate the operation
Common examples
ADD - Add
SUB - Substract
MPY - Multiply
DIV - Divide
LOAD - Load data from memory
STOR - Store data to memory
Operands are also represented symbolically
e.g. ADD M - mean add the value contained in data location M to the contents of register A. In this example, M refers to the address of a location in memory
Example: X = X + Y
Assume that the variable X and Y correspond to locations 513 and 514
Operations:
Add the contents of memory location 514 to the register.
Store the contents of the register in memory location 513
Instruction Type
Data processing
Arithmetic and logic instructions
Data storage (main memory)
Memory instructions
Data movement (I/O)
I/O instructions
Program flow control
Test and branch instructions
Adressing Modes of 8085
Immediate Addressing
The data is specified in the instruction itself
The data will be a part of the program instruction
An immediate is transfered directly to another register
Example:
MVI B, 3EH - Move the data 3EH given in the instruction to B register
LXI H, 2700H
Direct Addressing
The address of the data is specified in the instruction
The data will be in memory
The program instructions and data can be stored in different memory
Example:
LDA 1050H - Load the data available in memory location 1050H in to accumulator
SHLD 3000H
Data is directly copied from the given address to register
Indirect Addressing
The instruction specifies the name of the register in which the address of the data is available.
Here the data will be in memory and the address will be in the register pair
The data is transfered from the address pointed by the data in a register to other register
Example:
MOV A, M - The memory data addressed by HL pair is moved to A register
LDAX B
STAX D
Register Addressing
The instruction specifies the name of the register in which the data is available
Data is copied from one register to another register
Example:
MOV A, B - Move the content of B register to A register
SUB B
ADD C
Implied Addressing
The instruction itself specifies the data to be operated
Example:
CMA - Complement the content of accumulator
RAL
XCHG
Assembly Language
Introduction
Below is an example of a machine language program to add two numbers
However, machine language was simply too slow to program and tedious for most programmers
Instead of using strings of numbers that computers could directly understand, programmers began using English like abbreviations to represent elementary operations
These abbreviations form the basis of low level language
In low level language, instructions are coded using mnemonics such as DIV, ADD, SUB, and MOV
Assembly language ia an example of a low level language
Microprocessor understands the language of 0’s and 1’s only
This language is called machine language
Assembly Language
An assembly language is specific to a particular CPU architecture (as opposed to most high-level languages, which are usually portable).
For e.g. assembly language of 8085 is different than that of Motorola 6800 microprocessor
The abbreviations缩写 or the mnemonics助记符 which are defined by the hardware manufacturer, help the programmer remember individual instructions, registers, etc
Below is an example of an assembly language program to add two numbers
A utility program called an assembler is used to translate assembly language statements into the target computer's machine code
The assembler performs a more or less isomorphic translation (a one-to-one mapping) from mnemonic statements into machine instructions and data
This is in contrast with high-level languages, in which a single statement generally results in many machine instructions
Today, assembly language is used primarily for direct hardware manipulation, access to specialized processor instructions, or to address critical performance issues
What's Right with AL
Speed
Assembly language programs are generally the fastest programs around
Machine language created by compilers is usually longer and slower
Space
Assembly language programs are often the smallest
Capability
You can do things in assembly which are difficult or impossible in HLLs.
Applications requiring access to low level machine capability are often written in assembly language
e.g. device drivers
Knowledge
Your knowledge of assembly language will help you write better programs, even when using HLLs
Assembly language requires learning the architecture of the specific machine on which assembly language is used
High-Level (HLL) vs. Low-level languages (LLL)
An LLL requires long sequences of instructions to perform a complex task
An HLL provides complex statements that perform complex jobs
ex. the for loop in C or other languages
An LLL is machine dependent. Every microprocessor has its own assembly language. (Instruction set dependent)
Programmers must know the internal structure of the microprocessor
ex. number of registers, and how to use them
An HLL provides a high level of abstraction from the hardware details. Hides the internal structure of the processor
Reduced Instruction Set Computers (RISC) vs. Complex Instruction Set Computer (CISC)
Characteristics of CISC (ex. VAX)
Large number of instructions.
Some instructions that perform specialized tasks and are used infrequently.
Large variety of addressing modes.
Variable length instruction format.
Instructions that manipulate operand in memory.
Characteristics of RISC (ex. SPARC)
Few instructions.
Few addressing modes.
Memory access limited to load/store instructions.
All operations done within the registers.
Fixed length instruction format.
Single cycle instruction execution