Académique Documents
Professionnel Documents
Culture Documents
4.1.1 INTRODUCTION
Instructions?
Instruction set
Elements of an Instruction
ADD,SUB,MUL,,,,,,,,,
Addresses (operands)
May include:
void main()
{
main:
int a,b,c; 0567
ADD c,a,b
c = a+b; Compiler Assembler
Defines the layout of the bits of an instruction in terms of its constituent fields (What does each
field represent and how many bits is it?)
1. Zero operand:
Opcode
2. One operand:
Opcode Address
3. Two operands:
Opcode Address1 Address2
4. Three operands:
Opcode Add.1 Add.2 Add.3
Instruction Representation
In machine code each instruction has a unique bit pattern
Opcodes are represented by abbreviations, called mnemonics that indicate the operation. Common
examples include
ADD Add
SUB Subtract
MUL Multiply
DIV Divide
ADD A,B
Number of Addresses
One of the traditional ways of describing processor architecture is in terms of the number of
addresses contained in each instruction
Logical
Input/output
System control
Data transfer
Copy values from one location to another
PUSH source
POP destination
DEC destination
MUL source
logical
Operate on a bit-by-bit basis
Input /output
Instructions to read data from an input module and to write data to an output module
Transfer of control
Instructions discussed so far execute sequentially
Transfer of control instructions change the sequence of execution (update value of the
program counter (PC))
Common transfer of control instructions
a. Jump instructions
There are two types of jump, unconditional and conditional in unconditional jump, as the
instruction is executed, the jump always takes place to change the execution sequence.
Unconditional jump
JZ label
Immediate
Direct
Register
Register indirect
Displacement
Stack
The operand is part of the instruction instead of the contents of a register or a Memory location
Advantage
Does not require extra memory reference to fetch the operand
Drawback
Only a constant can be supplied
The number of values is limited by the size of the operand field
99 78
E.g. MOV R1, [100] 100 96
CPU
101 0
Memory address R1 96
Advantage
Can address a limited number of memory locations (relatively smaller address space)
Register Address
Memory Address
Advantage
Can address larger number of memory locations compared with direct addressing
Displacement value
Direct
Register Indirect
Displacement
Indexed
Based