COA Tutorial

Computer Organization and Architecture Tutorial Basic Terminologies Related to COA Digital Number System Computer Organization and Architecture Data Formats Fixed and Floating-Point Number IEEE Standard 754 Floating Point Numbers Control Unit Organization Data Path, ALU and Control Unit Micro-Operations CPU Registers Addressing Modes COA: Interrupt and its types Instruction Cycle: Computer Organization and Architecture Instruction Pipelining and Pipeline Hazards Pipelining: Computer Organization and Architecture Machine Instructions 8085 instructions set 8085 Pin Configuration Addressing mode in 8085 microprocessor Advantages and Disadvantages of Flash Memory BCD to 7 Segment Decoder Biconnectivity in a Graph Bipartite Graph CarryLook Ahead Adder Control Signals in 8155 Microprocessor Convert a number from base 2 to base 6 Ethernet Frame Format Local Broadcast Address and loopback address Microprocessor classification Use Case Diagram for the online bank system 8086 Microprocessor Pin Configurations 8255 Microprocessor Operating Modes Flag Register of 8086 Microprocessor Data Transfer and Manipulation 8085 Arithmetic Instructions Assembly Language Register What is Cache Associativity? Auxiliary Memory in COA Associative Memory in Computer Architecture SCSI Bus in Computer Architecture What are Registers in Microprocessor What is Associative Memory 1 Persistent CSMA What is Floating-Point Representation in Computer Architecture? What is a Serial Port in a Computer? What is Cluster Computing What is Batch Processing in Computer Advantages of Client Server Architecture Spooling Meaning in Computer System Magnetic Core Memory Magnetic Ink Card Reader Decision Making Tools and Techniques Digital Electronics using Semiconductor Memory What is Internal Chip Organization in Computer Architecture? What is Hardwired Control Unit? Definition of Diodes in Electronics Advantages of FSK Web Server Architecture How the OS interfaces between the user, apps, hardware? Discuss the I/O Interface in Computer Architecture Difference between Internal Fragmentation and External Fragmentation MDR in Computer Architecture

Machine Instructions

What is a Digital Computer?

A computer that takes input in a binary form and produces output in binary form.

Machine Instructions

The question arises of what kind of input the computer takes or what kind of input’s required for the computer to work on. So inputs are two things Programs + data, programs are the Machine instructions, and to execute these instructions, data is required. The computer understands only binary form, all the instructions should be in the binary, but instruction cannot be written in binary directly by the user. The program is written in High-level language, and translated with the help of a compilation processor program. So with a language translator, the program is compiled into an equivalent program in binary form. This is called a low-level program or machine code, Byte code, object code.

Program (instructions) written in High-level language are called programming statements. Instructions are the statements which CPU understands, and the CPU understands only binary, so instructions are compiled into binary bits that are understandable by the CPU.

Machine Instructions

Definition of Instruction: A group of bits that instruct the computer to perform some operation. Binary bits statements instruct the computer to execute the program.

The general format of instruction

Instruction can contain two types of information.

Machine Instructions
  1. Operation – It denotes what kind of operation the instruction wants to perform. The first few bits will inform the CPU that this operation to be performed to execute this instruction. Operations like ADD, MUL, SUB, MOVE, STORE, LOAD etc. So, the starting part of the operation will indicate operation, and it is called Operation Code, or in short, it is called OpCode.
  2. Operands – It is the remaining part of the instruction that tells the CPU about the operand’s data on the basis of which an operation is executed.

For example: A CPU has 8 Bits instruction, 3 bits are for the opcode, and the remaining 5 bits are for operand information.

Maximum combination for opcode- 23 =8(0000, 0001, 0010, 0011…1111)

It means 8 distinct types of instruction CPU can support.

Let's take two instructions ADD R1, R2, R3 and ADD R1, R3, R5. Here both have ADD type instruction operands that may be different, but the instruction type is the same.

Note: One opcode denotes one single operation within the CPU. During designing CPU, number of opcodes are decided by architecture. The compiler generates distinct types of instructions that are generated by the CPU. 

Instruction Set Architecture (ISA)

The collection of all those types of instructions that the CPU can support is known as Instruction set architecture. For the above example, size of ISA is 8.

Types of Instruction (Based on Operations)

  • Data Transfer: MOV, LDA, IN, OUT, PUSH, XLAT, XCHG, POP, LEA
MOVMove byte or word to memory.
XLATTranslate byte using a look-up table
PUSHPush data/word into the stack
POPPop word out of the stack
INInput byte
OUTOutput word to port
LEALoad effective address
LDSLoad pointer using data segment
XCHGExchange byte/ word
  • Arithmetic and Logic: ADD, SUB, AND, OR
ADD, SUBAddition and Subtraction of byte
CMPCompare byte/ word
NEGNegate byte/word
INC, DECIncrement and Decrement
IMULInteger multiply
IDIVDivide Byte
CBWConvert byte to word
CWDConvert word to double word
  • Machine Control: EI, DI, PUSH, POP
 EIEnable instruction
DIDisable instruction
PUSHPut the word into the stack.
POPPut the word out of the stack.
  • Iterative: LOOP, LOOPE, LOOPZ
LOOPThe logic of Object-Oriented Programming
LOOPZLOOP While Zero
LOOPLOOP While Equal
  • Branch: JMP, CALL, RET, JZ, JNZ
JMPJump
CALLProduce call
RETReturn instruction
JZJump If Zero
JNZJump If Not Zero

Types of Instruction( Based on Operand information)

  • 4- Address Instruction
Machine Instructions

Within each instruction, maximum of 4- addresses can be specified.

The opcode is the mandatory part of the instruction; we have 4 addresses in which staring three addresses specify operands and last address specify the address of next instruction. The program counter is not present in CPU having 4- address instruction format. Nowadays, it is not used in computers due to disadvantages.

Disadvantage

  • Larger size instruction
  • Larger size program in memory
  • Relocation is not easy.
  • Instruction fetch takes more time.
  • 3- Address Instruction
Machine Instructions

The modern computer uses this 3- address instruction format. Within each instruction, maximum of 3- addresses can be specified.

The opcode is the mandatory part of the instruction; we have 3 addresses that specify operands, and the program counter is used in CPU. Intermediate code generation, 3- address code is generated because CPU can Implement 3- address code in terms of instruction directly, and CPU is also using 3- address instruction code. All those disadvantages in 4- address instruction is eliminated here.

  • 2- Address Instruction
Machine Instructions

Maximum 2 addresses can be specified within an instruction. One operand is used as source and destination. Both means instruction is taken from R2, and the result is copied to R2.

The disadvantage of 2-Address instruction

  • More number of instructions for a program as compare to 3-address instruction format. So it requires more memory.
  • 1- Address Instruction
Machine Instructions

Maximum 1 address can be specified within an instruction. Here apart from opcode, we have only one operand, but we also require a second operand to do the operation, so here second operand value comes from Accumulator. So, it is supported in Accumulator based architecture.

Disadvantage

  • It will have more instruction for a program than 2-address instruction because addresses and more operands are not specified.
  • Here, the number of instructions is reduced, only one operand is used, but we still have more instructions than 2 and 3 address instruction.
  • 0- Address Instruction
Machine Instructions

0-Adress instruction follows stack-based architecture. No addresses can be specified within instruction, and there is only one opcode. So two operands are implicitly taken from the stack. Therefore, 0- address instructions are implemented on stack-based architecture. It is not used in nowadays systems.

Note: If a CPU supports 3-address instruction, then it supports 2-1-0 address instruction also.

If a CPU support 2-address instruction, then it supports 1-0 address instruction also.

If a CPU support 1-address instruction, then it supports 0-address instruction also.

If a CPU supports 0-address instruction, it can only support 0 address instruction.