Machine Instruction In Computer Architecture

Machine Instruction

Machine Instruction In Computer Architecture

Definition Of Machine Instruction

In computer architecture , the machine instruction is defined as sequence of bits in binary which directs the computer processor to perform the specific operation.

In computer programming the machine instruction is a low level program instruction in binary. It is also alternately referred to as binary code or simply a machine code.

The computer processor ( CPU ) can decode and execute only low level binary code. The binary code consist of only two digits that is either 0 ( zero ) or 1 ( one ).

Machine Instructions , Machine Code

However , writing the computer program in machine code is very difficult and confusing because it only contains patterns of only binary 0 and 1.

The machine instructions can be directly decoded and executed by the computer microprocessor ( CPU ) and does not need any further processing.

The machine code does not provide any abstraction and the low level commands can be mapped to the instruction set architecture ( ISA ) of the CPU.

Types Of Programming Languages

Let us now discuss the correlation between the high level program instructions and the low level machine instructions.

The programming languages are often referred to as either high level or low level programming language. The programming language level depends upon the level of abstraction.

Low Level Program

The low level programs consist of machine instructions that can be directly executed by the computer processor. The low level program instruction does not provide any abstraction and consist of patterns of binary code ( 0 and 1 ).

The machine code is not considered to be human friendly because it is difficult to interpret the program code that just contains patterns of binary  0 and 1 .

However, the machine language programming is considered very machine friendly. Because the machine ( computer ) can directly execute the machine instructions in the fastest manner.

Types Of Programming Language

The assembly language is also considered as low level language that needs a very little processing. The low level programs can work at high speed and need little memory.

Most system software programs are developed using low level languages. The system software components are mainly used by the computer to communicate with various hardware components.

High Level Program

The high level programs are developed using a human friendly programming languages such as such as C language , C++ , Java , Python and so on.

The program code written in any high level language contains words that are similar to English language. And therefore, it becomes much easier for programmers to develop software using high level languages.

However , all high level programs are converted to machine code using a special software called compiler. The compiler converts the high level program to its equivalent low level program that can be executed by the processor.

Program Compilation Interpreter
Program Compilation

Most of the application programs are first written in any high level programming language such as C language , C++ , Java , Python and so on.

The high level program is than compiled to build platform specific an executable file ( dot exe file ). The compiled executable file is a platform dependent  program.

After compilation the high level program is converted to low level machine code. The machine code consist of set of machine instructions.

Machine Instruction Format

The machine instructions are program instructions in binary that can be directly executed by the computer processor ( CPU ).

Each machine instruction provides direction to the CPU about the operation to be performed ( Operation Code – OPCODE ) and the data or reference to the data ( address of the data – OPERAND ) .

The microprocessor design is based on its instruction set architecture ( ISA ). The instruction set architecture is a set of machine instructions that can be directly decoded and executed by the processor.

The addressing mode part of the machine instruction directs the CPU in locating the data referenced in the OPERAND.

Instruction Format 16 Bits , Instruction Register

Machine Instruction And Program compilation

Due to hardware architecture, the CPU can decode and execute only machine instructions in binary. And therefore, all high level computer are compiled to generate the low level machine code.

In binary code all program instructions are represented in binary.

Computer Program Compilation And Linking

Assembly Language

In the initial phase of the evolution of computing , the programming in binary was a very difficult task . Because it contains sequence of only 0 and 1.

Hence , a more human friendly version of the low level machine language called assembly language was introduces.

The assembly language code contains mnemonic code which is a symbolic codes for common operation codes contained in the machine instruction.

The assembly language is low level programming and an assembler is required to convert this code into executable machine code.

Assembly Language

Program Instructions In Assembly Language

Machine Language

Machine Instructions In Binary

Types Of Machine Instructions

Computer program consists of different types of instructions and each instruction performs a specific task. Machine instructions can be grouped into three types depending up on the type of operation performed as following:

  1. Data Transfer instructions.
  2. Data Manipulation Instructions.
  3. Program Control Instructions.

Data Transfer instructions

During the program execution the data is frequently transferred between the memory and the processor. The data transfer instructions are used to transfer the data from main memory to processor registers and processed data is again sent to the main memory.

The data transfer instructions simply allow the transfer of data to be transferred from one place to another without altering its content.

Data Transfer Instruction

Instruction Details

LOAD

LOAD Instruction transfer of data from memory into the CPU register.

IN

IN instructions receive data from an input device.

MOVE

Move instructions transfer data between CPU registers.

OUT

OUTPUT instructions outputs data from the register.

PUSH

PUSH Instruction pushes the data from a register towards the top of the stack.

STORE

STORE instruction transfers of data from the register to the main memory RAM.

POP

POP Instruction fetches top data from register or stack memory.

XCHG

XCHG instruction transfers data between registers and main memory.

Data Manipulation Instructions

These machine instructions are also referred as computation instruction. The data manipulation instructions perform various arithmetic and Logical operations as per the program Instructions. These instructions direct the processor to perform specific arithmetic and logical operations.

  1. Arithmetic Instructions.
  2. Logical and Arithmetic Instructions.
  3. Logical Instructions.

Arithmetic Instructions

These instructions perform operations such as addition, subtraction , multiplication, division, increment and decrement operations.

For instance, ADD, INC, MUL, DEC, SUB, DIV, etc.

Logical and Arithmetic Instructions

These instructions perform arithmetic + shift left and arithmetic + shift right bit shift  operations.

Logical Instructions

The logical instructions allow processor to perform various logical operations based on the program logic such as decision making

Bit-wise operations like AND, NOT, Exclusive-OR, OR, shift, and rotate are performed.

Example: NOT, AND, ROL,  XOR, OR, SHL, ROR SHR, etc.

Program Control Instructions

Program control instruction specifies a condition that controls the logical execution sequence of the program. Program Control Instructions are the machine instructions that are used by the computer or in assembly language by the programmer to command the processor to alter the program execution.

Different types of program control instructions are used depending upon the program logic. In assembly language, mnemonics are used to specify an opcode that represents a complete and operational machine language instruction. During the program compilation process, this is later translated by the assembler to generate the object code. These instructions include:

Control Instruction

Assembly Language Mnemonic

BRANCH

BR

SKIP

SKP

CALL

CALL

TEST

TST

Join The Best Seller

Computer Science Online Course

This is the most comprehensive  and unique  Computer Science  And Programming Fundamentals course Online which will give you in depth understanding of most important fundamental concepts in computer science And Programming .

Don`t copy text!