SlideShare una empresa de Scribd logo
1 de 49
Types of Instructions
Types of Instructions
• Different assembly language instructions are
  mainly categories into the following main
  types:

3.Data transfer instructions

5.Arithmetic instructions

7.Logical and program control instructions
1)Data trtansfer instruction:
• These instructions are responsible of transfer of
  data among operands.

• i) MOV instruction:
    copy data from one operand to another.

     general Syntax :-
        MOV destination ,source
i)Mov instruction (conti..)
• Data is copies from source to destination in
  such a way that source operand is not
  changed.

• The source operand may be
         immediate data(constant)
         a register
            or
         a memory operand
• The following data transfers are possible:
   register to register
   register to memory
   memory to register

• limitations on types of operands:
iii. CS and IP may never be destination.

v. immediate data and segment registers may
   not be moved to segment registers.
i. The source and destination operand must be
   of same size.

iii. If the source operand is immediate data, it
     must not exceed the destination operand
     size.

   255 (FFh) for a 8-bit destination
         or
   65’535 (FFFFh) for 16-bit destination
• MOV doesn't allow memory to memory
  transfer.
• data must be transfer to a register first.

• e.g to copy var1 to var2, we have to write:
     mov ax, var1
     mov var2, ax
Types of operands:
i) Register operand:
    A mov that involves only registers is the fastest
   type that take only two clock cycles.

clock cycles:-
o CPU’s smallest unit of time measurement
o     It varies from 50 to 210 nano seconds
o     it depends upon type of CPU processor.
• Register should be used when an instruction
  must execute quickly.

• Any register may be used as a source
  operand.

• Any register, except CS and IP may be a
  destination operand.
Examples:
• Mov ax, bx

• Mov dl, al

• Mov bx ,cs
ii) Immediate operands:
• An immediate value i.e. Integer constant may
  be moved to any register
    ( except a segment register or IP).

• And may also be moved to any memory
  operand (variable).
• In immediate value can not be larger then the
  destination operand.

• Examples:
   mov     bl , 01
   mov ax, 1000h
   mov total ,1000h
iii)Memory operand:
• a variable may be coded as one of the
  operands in a mov instruction.

• This causes the contents of memory at the
  variable’s address to be used.
• If an 8-bit variable name “count” contains the
  number ‘1’ ,

• then the following MOV will copy the contents
  of count into AL:

      Mov al, count
In similar way ,BL register’s contents may
be copied into the variable count as:

Mov al, count                   AL

Count
            01                        01
mov count, bl
•   BL                   Count

         01                   01
Some illegal Mov operations are:
1. Moves between two memory operands.

3. Moves of segment registers or immediate
   values to segment registers.

5. Moves to CS and IP.

7. Moves between register of different sizes.

9. Moves to immediate operands (constant).
iii)Loading instructions :-
• specific register instructions.
• used to load bytes or chains of bytes onto a
  register.
• LEA INSTRUCTION (Load Effective Address):

• Purpose: To load the address of the source
  operator.
• Syntax:
   LEA destination, source
LEA instruction (conti..)
• The illustration of one of the facilities we
  have with this command :

      MOV SI, OFFSET VAR1
Is equivalent to:
        LEA SI, VAR1

• MOV......OFFSET instruction is more efficient
  because the offset of operand is calculated by
  MASM at assembly time.
LEA instruction (conti..)
• LEA calculate offset of operand at runtime.
• Slows the program down.

• but LEA instruction may be used effectively
  with more advanced addressing modes such
  as “BASED MODE”.

• It is very probable that for the programmer it
  is much easier to create extensive programs
  by using LEA instruction.
iii)XCHG instruction

• The xchg (exchange) instruction swaps two
  values.

• This instruction is used to exchange the
  contents of two registers or of a register and
  a variable .

• The general form is
   xchg operand1 operand2
EXCHG instruction (conti..)

DIFFERENT FORMS OF REGISTER AND MEMORY
   OPERANDS ARE:-
• Xchg reg , reg
• Xchg reg , mem
• Xchg ax , reg16
• Xchg eax, reg32
 ( Available only on 80386 and later processors)
EXCHG instruction (conti..)
• Provides the most efficient way to exchange
  two 8-bit ,16-bit OR 32-bit operands.

• Because we don’t need a third register or
  variable to hold a temporary value.

• Quit suitable in sorting applications where it
  provides an advantage of speed.
•                EXCHG instruction (conti..)


• One or both operand may be register,
               OR
• a register may be combined with a memory
  operand ,

• But two memory operands may not be used
  together .
EXCHG instruction (conti..)



MOV   AL, VAL1   ; LOAD THE AL REGISTER

XCHG VAL2 ,AL

  ; EXCHANGE THE AL AND VAL2

MOV VAL1 , AL ; STORE AL BACK INTO VAL1
MEMORY
    EXCHG instruction (conti..)

                                  0A        Val1
    AX         00
                                  14
                                            val2

•
                                            val1
                                   0A
    AX         00           14
                                            val2
                                   0A



                                             val1
    AX          00          14         14

                                   0A        val2
EXCHG instruction (conti..)
         Some valid example:
• XCHNG EAX, EBX
     (;exchange two 32-bit registers)

• XCHNG AX, BX
     (;exchange two 16-bit registers)
EXCHG instruction (conti..)

• XCHNG ah , al
    ; exchange two 8-bit registers

• XCHG var , bx
    ; exchange 16-bit memory operand with
  BX
EXCHG instruction (conti..)

• Note that the order of the xchg's operands
  does not matter.

• Both operands must be the same size.

• The xchg instruction does not modify any flags
.MODEL SMALL
.STACK 100H
.DATA
VAL1 DB 0AH
VAL2 DB 14H

.CODE
MAIN PROC
  MOV AX, @DATA ;INITIALIZE DS REGISTER
  MOV DS,AX

 MOV AL, VAL1 ; LOAD THE AL REGISTER
 XCHG VAL2 ,AL ; EXCHANGE THE AL AND VAL2
 MOV VAL1 , AL ; STORE AL BACK INTO VAL1

  MOV AX,4C00H
  INT 21H
MAIN ENDP
END MAIN
2)Arithematic Instructions
• The Intel instruction set has instructions for
    integer arithmetic using 8,16 or 32-bits
    operands.
• The basic arithematic instructions are given
    below:
iii. INC and DEC instructions
iv. ADD instructions
v. SUB instructions
vi. MUL and IMUL instructions
i. INC and DEC instructions
• These INC and DEC are actually unary
  operators and their operands may be either
  8,16, 32-bits register or memory variables.

• INC is used to add 1 to the value of a single
  operand.

• DEC is used to subtract 1 from the value of a
  single operand.
INC and DEC instructions conti..




• These instructions have the following general
  form:
        INC destination
        DEC destination

• These instructions are faster than ADD and
  SUB instructions
ii) ADD instruction:
• This instruction adds 8 ,16 or 32-bits source
  operand to a destination operand of the same
  size.

• The syntax of this instruction is:
        ADD destination, source
ADD instruction conti..
The source operand is unchanged by the
  operation .
• Source operand may be a
       register,
       memory operand
        or immediate operand
• whereas destination may be a
     register or memory operand.
ADD instruction conti..

• A segment register may not be the destination
  and only one memory operand may be used.

• The size of source and destination operand
  must be the same, in this binary instruction,
  Add is a binary operator.
iii)Sub Instruction:
• This instruction subtracts a source operand
  from a destination operand.

• The syntax of this instruction is:
       SUB destination, source
SUB instruction conti..

• The sizes of both operands must match and
  only one may be the memory operand.
• A segment register may not be the
  Destination operand.
• All status flags are affected by this binary
  instructing SUB is a binary operand.
iv)MUL and IMUL instructions:
• These instructions are used to multiply an 8-
  bit or 16-bit operand by AL or AX.

• If an 8-bit source operand is supplied ,if will
  automatically multiplied and the result will be
  stored in AX.
MUL and IMUL instructions conti..


• If a 16-bit operand is source operand is
  supplied it will be automatically multiplied by
  AX and the result will be stored in DX and AX
  so that the higher bits are in DX.
• The syntax of these instructions are:
        MUL source
        IMUL source
• The source operand may be a register or
  memory operand.

 mul reg
 mul mem

• but may not be an immediate data.
• The IMUL (integer multiply) instruction
  multiplies signed binary values.
• Its sign extends the result through highest bit
  of AX or AX:DX ,depending on size of the
  source operand.
• A result of -10h ,for example ,would be
  extended into AH if an 8-bits operation had
  taken place or into DX for accomplishing a 16-
  bit operation.
• DIV INSTRUCTION
    Purpose: Division without sign.
• Syntax:
    DIV source

• The divider can be a byte or a word and it is
  the operator which is given the instruction.

• If the divider is 8 bits, the 16 bits AX register is
  taken as dividend and
• if the divider is 16 bits the even DX:AX
  register will be taken as dividend, taking the
  DX high word and AX as the low.

• If the divider was a byte then the quotient will
  be stored on the AL register and the residue
  on AH, if it was a word then the quotient is
  stored on AX and the residue on DX.
IDIV INSTRUCTION
• Purpose: Division with sign.
• Syntax:
• IDIV source

• It basically consists on the same as the DIV
  instruction,
• the only difference is that this one performs
  the operation with sign.
• For its results it used the same registers as the
  DIV instruction.
2)LOGICAL INSTRUCTIONS:
• generates their result either as true or false.

• Zero ,Carry and Sign flags are particularly associated
  with showing the results of Boolean and comparison
  instructions.

• Boolean instructions are based on boolean algebra
  operations .

• these operations allow modification of individual bits
  in binary numbers.
 AND results into 1 when both the input bit
  are 1.

 OR results into 1 when either input bit is 1.

 XOR results into 1 when the input bits are
  different and is known as exclusive OR.

     NOT results into the reverse of input bit
    i.e. 1 becomes 0 and 0 becomes 1.
ii. The   AND instruction
iii.The   OR instruction
iv.The    XOR instruction
v. The    NOT instruction
vi.The    NEG instruction

Más contenido relacionado

La actualidad más candente

Stack organization
Stack organizationStack organization
Stack organizationchauhankapil
 
Computer architecture addressing modes and formats
Computer architecture addressing modes and formatsComputer architecture addressing modes and formats
Computer architecture addressing modes and formatsMazin Alwaaly
 
Types of Addressing modes- COA
Types of Addressing modes- COATypes of Addressing modes- COA
Types of Addressing modes- COARuchi Maurya
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stackAsif Iqbal
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed controlShashank Singh
 
Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control UnitKamal Acharya
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle pptsheetal singh
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control Anuj Modi
 
Processor organization & register organization
Processor organization & register organizationProcessor organization & register organization
Processor organization & register organizationGhanshyam Patel
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208Ameer Mehmood
 

La actualidad más candente (20)

Stack organization
Stack organizationStack organization
Stack organization
 
Cpu organisation
Cpu organisationCpu organisation
Cpu organisation
 
Computer architecture addressing modes and formats
Computer architecture addressing modes and formatsComputer architecture addressing modes and formats
Computer architecture addressing modes and formats
 
Micro program example
Micro program exampleMicro program example
Micro program example
 
Types of Addressing modes- COA
Types of Addressing modes- COATypes of Addressing modes- COA
Types of Addressing modes- COA
 
Register organization, stack
Register organization, stackRegister organization, stack
Register organization, stack
 
Instruction codes
Instruction codesInstruction codes
Instruction codes
 
Computer registers
Computer registersComputer registers
Computer registers
 
Lecture 3 instruction set
Lecture 3  instruction setLecture 3  instruction set
Lecture 3 instruction set
 
Micro programmed control
Micro programmed  controlMicro programmed  control
Micro programmed control
 
Micro Programmed Control Unit
Micro Programmed Control UnitMicro Programmed Control Unit
Micro Programmed Control Unit
 
instruction cycle ppt
instruction cycle pptinstruction cycle ppt
instruction cycle ppt
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Memory management
Memory managementMemory management
Memory management
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Interrupts and types of interrupts
Interrupts and types of interruptsInterrupts and types of interrupts
Interrupts and types of interrupts
 
Microprogram Control
Microprogram Control Microprogram Control
Microprogram Control
 
Instruction format
Instruction formatInstruction format
Instruction format
 
Processor organization & register organization
Processor organization & register organizationProcessor organization & register organization
Processor organization & register organization
 
Associative memory 14208
Associative memory 14208Associative memory 14208
Associative memory 14208
 

Destacado

Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGFrankie Jones
 
Lecture 2
Lecture 2Lecture 2
Lecture 2GIKI
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed controlRai University
 
MicroProgrammed Explained .
MicroProgrammed Explained .MicroProgrammed Explained .
MicroProgrammed Explained .Muhammad Umar
 
15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COAJay Patel
 
Computer architecture
Computer architectureComputer architecture
Computer architectureneclinux
 
Origin of Microprocessor and Classification of Microprocessor
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor Vijay Kumar
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set ArchitectureDilum Bandara
 

Destacado (9)

Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
Instruction cycle
Instruction cycleInstruction cycle
Instruction cycle
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
basic computer programming and micro programmed control
basic computer programming and micro programmed controlbasic computer programming and micro programmed control
basic computer programming and micro programmed control
 
MicroProgrammed Explained .
MicroProgrammed Explained .MicroProgrammed Explained .
MicroProgrammed Explained .
 
15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA15 control-computer organization and archietecture-CO-COA
15 control-computer organization and archietecture-CO-COA
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Origin of Microprocessor and Classification of Microprocessor
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 

Similar a Types of instructions

Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptxNishatNishu5
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions setRobert Almazan
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructionsRobert Almazan
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction setprakash y
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxAmoghR3
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerchirag patil
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorDaniel Roggen
 
Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9 Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9 Randa Elanwar
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).pptKanikaJindal9
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)Pratheesh Pala
 

Similar a Types of instructions (20)

Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
Uc 2(vii)
Uc 2(vii)Uc 2(vii)
Uc 2(vii)
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
MES_MODULE 2.pptx
MES_MODULE 2.pptxMES_MODULE 2.pptx
MES_MODULE 2.pptx
 
8051d
8051d8051d
8051d
 
8086 Instruction set
8086 Instruction set8086 Instruction set
8086 Instruction set
 
13229286.ppt
13229286.ppt13229286.ppt
13229286.ppt
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
 
instructions set of 8051.pdf
instructions set of 8051.pdfinstructions set of 8051.pdf
instructions set of 8051.pdf
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Chapter3 8086inst logical 2
Chapter3 8086inst logical 2Chapter3 8086inst logical 2
Chapter3 8086inst logical 2
 
Chap3 8086 logical
Chap3 8086 logicalChap3 8086 logical
Chap3 8086 logical
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational Processor
 
Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9 Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt
 
Coal (1)
Coal (1)Coal (1)
Coal (1)
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
 

Último

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptxmary850239
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsPooky Knightsmith
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...
IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...
IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...MerlizValdezGeronimo
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptxJonalynLegaspi2
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 

Último (20)

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx4.11.24 Mass Incarceration and the New Jim Crow.pptx
4.11.24 Mass Incarceration and the New Jim Crow.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Mental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young mindsMental Health Awareness - a toolkit for supporting young minds
Mental Health Awareness - a toolkit for supporting young minds
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...
IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...
IPCRF/RPMS 2024 Classroom Observation tool is your access to the new performa...
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
week 1 cookery 8 fourth - quarter .pptx
week 1 cookery 8  fourth  -  quarter .pptxweek 1 cookery 8  fourth  -  quarter .pptx
week 1 cookery 8 fourth - quarter .pptx
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 

Types of instructions

  • 2. Types of Instructions • Different assembly language instructions are mainly categories into the following main types: 3.Data transfer instructions 5.Arithmetic instructions 7.Logical and program control instructions
  • 3. 1)Data trtansfer instruction: • These instructions are responsible of transfer of data among operands. • i) MOV instruction: copy data from one operand to another. general Syntax :- MOV destination ,source
  • 4. i)Mov instruction (conti..) • Data is copies from source to destination in such a way that source operand is not changed. • The source operand may be  immediate data(constant)  a register or  a memory operand
  • 5. • The following data transfers are possible:  register to register  register to memory  memory to register • limitations on types of operands: iii. CS and IP may never be destination. v. immediate data and segment registers may not be moved to segment registers.
  • 6. i. The source and destination operand must be of same size. iii. If the source operand is immediate data, it must not exceed the destination operand size.  255 (FFh) for a 8-bit destination or  65’535 (FFFFh) for 16-bit destination
  • 7. • MOV doesn't allow memory to memory transfer. • data must be transfer to a register first. • e.g to copy var1 to var2, we have to write: mov ax, var1 mov var2, ax
  • 8. Types of operands: i) Register operand: A mov that involves only registers is the fastest type that take only two clock cycles. clock cycles:- o CPU’s smallest unit of time measurement o It varies from 50 to 210 nano seconds o it depends upon type of CPU processor.
  • 9. • Register should be used when an instruction must execute quickly. • Any register may be used as a source operand. • Any register, except CS and IP may be a destination operand.
  • 10. Examples: • Mov ax, bx • Mov dl, al • Mov bx ,cs
  • 11. ii) Immediate operands: • An immediate value i.e. Integer constant may be moved to any register ( except a segment register or IP). • And may also be moved to any memory operand (variable).
  • 12. • In immediate value can not be larger then the destination operand. • Examples: mov bl , 01 mov ax, 1000h mov total ,1000h
  • 13. iii)Memory operand: • a variable may be coded as one of the operands in a mov instruction. • This causes the contents of memory at the variable’s address to be used.
  • 14. • If an 8-bit variable name “count” contains the number ‘1’ , • then the following MOV will copy the contents of count into AL: Mov al, count
  • 15. In similar way ,BL register’s contents may be copied into the variable count as: Mov al, count AL Count 01 01
  • 16. mov count, bl • BL Count 01 01
  • 17. Some illegal Mov operations are: 1. Moves between two memory operands. 3. Moves of segment registers or immediate values to segment registers. 5. Moves to CS and IP. 7. Moves between register of different sizes. 9. Moves to immediate operands (constant).
  • 18. iii)Loading instructions :- • specific register instructions. • used to load bytes or chains of bytes onto a register. • LEA INSTRUCTION (Load Effective Address): • Purpose: To load the address of the source operator. • Syntax: LEA destination, source
  • 19. LEA instruction (conti..) • The illustration of one of the facilities we have with this command : MOV SI, OFFSET VAR1 Is equivalent to: LEA SI, VAR1 • MOV......OFFSET instruction is more efficient because the offset of operand is calculated by MASM at assembly time.
  • 20. LEA instruction (conti..) • LEA calculate offset of operand at runtime. • Slows the program down. • but LEA instruction may be used effectively with more advanced addressing modes such as “BASED MODE”. • It is very probable that for the programmer it is much easier to create extensive programs by using LEA instruction.
  • 21. iii)XCHG instruction • The xchg (exchange) instruction swaps two values. • This instruction is used to exchange the contents of two registers or of a register and a variable . • The general form is xchg operand1 operand2
  • 22. EXCHG instruction (conti..) DIFFERENT FORMS OF REGISTER AND MEMORY OPERANDS ARE:- • Xchg reg , reg • Xchg reg , mem • Xchg ax , reg16 • Xchg eax, reg32 ( Available only on 80386 and later processors)
  • 23. EXCHG instruction (conti..) • Provides the most efficient way to exchange two 8-bit ,16-bit OR 32-bit operands. • Because we don’t need a third register or variable to hold a temporary value. • Quit suitable in sorting applications where it provides an advantage of speed.
  • 24. EXCHG instruction (conti..) • One or both operand may be register, OR • a register may be combined with a memory operand , • But two memory operands may not be used together .
  • 25. EXCHG instruction (conti..) MOV AL, VAL1 ; LOAD THE AL REGISTER XCHG VAL2 ,AL ; EXCHANGE THE AL AND VAL2 MOV VAL1 , AL ; STORE AL BACK INTO VAL1
  • 26. MEMORY EXCHG instruction (conti..) 0A Val1 AX 00 14 val2 • val1 0A AX 00 14 val2 0A val1 AX 00 14 14 0A val2
  • 27. EXCHG instruction (conti..) Some valid example: • XCHNG EAX, EBX (;exchange two 32-bit registers) • XCHNG AX, BX (;exchange two 16-bit registers)
  • 28. EXCHG instruction (conti..) • XCHNG ah , al ; exchange two 8-bit registers • XCHG var , bx ; exchange 16-bit memory operand with BX
  • 29. EXCHG instruction (conti..) • Note that the order of the xchg's operands does not matter. • Both operands must be the same size. • The xchg instruction does not modify any flags
  • 30. .MODEL SMALL .STACK 100H .DATA VAL1 DB 0AH VAL2 DB 14H .CODE MAIN PROC MOV AX, @DATA ;INITIALIZE DS REGISTER MOV DS,AX MOV AL, VAL1 ; LOAD THE AL REGISTER XCHG VAL2 ,AL ; EXCHANGE THE AL AND VAL2 MOV VAL1 , AL ; STORE AL BACK INTO VAL1 MOV AX,4C00H INT 21H MAIN ENDP END MAIN
  • 31. 2)Arithematic Instructions • The Intel instruction set has instructions for integer arithmetic using 8,16 or 32-bits operands. • The basic arithematic instructions are given below: iii. INC and DEC instructions iv. ADD instructions v. SUB instructions vi. MUL and IMUL instructions
  • 32. i. INC and DEC instructions • These INC and DEC are actually unary operators and their operands may be either 8,16, 32-bits register or memory variables. • INC is used to add 1 to the value of a single operand. • DEC is used to subtract 1 from the value of a single operand.
  • 33. INC and DEC instructions conti.. • These instructions have the following general form: INC destination DEC destination • These instructions are faster than ADD and SUB instructions
  • 34. ii) ADD instruction: • This instruction adds 8 ,16 or 32-bits source operand to a destination operand of the same size. • The syntax of this instruction is: ADD destination, source
  • 35. ADD instruction conti.. The source operand is unchanged by the operation . • Source operand may be a register, memory operand or immediate operand • whereas destination may be a register or memory operand.
  • 36. ADD instruction conti.. • A segment register may not be the destination and only one memory operand may be used. • The size of source and destination operand must be the same, in this binary instruction, Add is a binary operator.
  • 37. iii)Sub Instruction: • This instruction subtracts a source operand from a destination operand. • The syntax of this instruction is: SUB destination, source
  • 38. SUB instruction conti.. • The sizes of both operands must match and only one may be the memory operand. • A segment register may not be the Destination operand. • All status flags are affected by this binary instructing SUB is a binary operand.
  • 39. iv)MUL and IMUL instructions: • These instructions are used to multiply an 8- bit or 16-bit operand by AL or AX. • If an 8-bit source operand is supplied ,if will automatically multiplied and the result will be stored in AX.
  • 40. MUL and IMUL instructions conti.. • If a 16-bit operand is source operand is supplied it will be automatically multiplied by AX and the result will be stored in DX and AX so that the higher bits are in DX.
  • 41. • The syntax of these instructions are: MUL source IMUL source • The source operand may be a register or memory operand.  mul reg  mul mem • but may not be an immediate data.
  • 42. • The IMUL (integer multiply) instruction multiplies signed binary values. • Its sign extends the result through highest bit of AX or AX:DX ,depending on size of the source operand.
  • 43. • A result of -10h ,for example ,would be extended into AH if an 8-bits operation had taken place or into DX for accomplishing a 16- bit operation.
  • 44. • DIV INSTRUCTION Purpose: Division without sign. • Syntax: DIV source • The divider can be a byte or a word and it is the operator which is given the instruction. • If the divider is 8 bits, the 16 bits AX register is taken as dividend and
  • 45. • if the divider is 16 bits the even DX:AX register will be taken as dividend, taking the DX high word and AX as the low. • If the divider was a byte then the quotient will be stored on the AL register and the residue on AH, if it was a word then the quotient is stored on AX and the residue on DX.
  • 46. IDIV INSTRUCTION • Purpose: Division with sign. • Syntax: • IDIV source • It basically consists on the same as the DIV instruction, • the only difference is that this one performs the operation with sign. • For its results it used the same registers as the DIV instruction.
  • 47. 2)LOGICAL INSTRUCTIONS: • generates their result either as true or false. • Zero ,Carry and Sign flags are particularly associated with showing the results of Boolean and comparison instructions. • Boolean instructions are based on boolean algebra operations . • these operations allow modification of individual bits in binary numbers.
  • 48.  AND results into 1 when both the input bit are 1.  OR results into 1 when either input bit is 1.  XOR results into 1 when the input bits are different and is known as exclusive OR.  NOT results into the reverse of input bit i.e. 1 becomes 0 and 0 becomes 1.
  • 49. ii. The AND instruction iii.The OR instruction iv.The XOR instruction v. The NOT instruction vi.The NEG instruction