SlideShare una empresa de Scribd logo
1 de 31
Name          ID

DULAL CHANDRA BARMAN   00805010

MD.JAHURUL ISLAM       00805034

MD.EMDADUL HUQ         00805038

MD.FARUQ AHMED         00805047

ASHOK KUMAR SARKER     00805049
FLAG REGISTER
FLAGS Register:

   Individual bits control the action or represent the status of the
    processor

Control flags (TF, IF, DF):

   Determine how the processor responds to certain situations

Status flags (CF, PF, AF, ZF, SF, OF):

   Set to represent the result of certain operations

   Used to control conditional jump instructions
FLAG Register Bits:
Status Flags:                        Control Flags:

Bit         Name             Symb
                                ol   Bit   Name             Symb
                                                               ol
0         Carry flag          CF
                                     8     Trap flag        TF
2         Parity flag         PF
4     Auxiliary carry flag    AF     9     Interrupt flag   IF

6          Zero flag          ZF     10    Direction flag   DF
7          Sign flag          SF
11      Overflow flag         OF
Status Flags:

The Carry Flag (CF):
 CF = 1 if there is a carry out from the msb (most
  significant bit) on addition, or there is a borrow into the
  msb on subtraction
 CF = 0 otherwise
 CF is also affected by shift and rotate instructions


The Parity Flag (PF):
 PF = 1 if the low byte of a result has an even number
  of one bits (even parity)
 PF = 0 otherwise (odd parity)
The Auxiliary Carry Flag (AF):
 AF = 1 if there is a carry out from bit 3 on addition, or there is
  a borrow into the bit 3 on subtraction
 AF = 0 otherwise
 AF is used in binary-coded decimal (BCD) operations


The Zero Flag (ZF):
 ZF = 1 for a zero result
 ZF = 0 for a non-zero result


The Sign Flag (SF):
 SF = 1 if the msb of a result is 1; it means the result is
  negative if you are giving a signed interpretation
 SF = 0 if the msb is 0
The Overflow Flag (OF):
   OF = 1 if signed overflow occurred
   OF = 0 otherwise

Example 1. ADD AX,BX , where AX contains FFFFh , BX contains
  FFFFh.
Solution:        FFFFh
               + FFFFh
               1FFFEh
The result stored in AX is FFFEh=1111 1111 1111 1110
SF = 1 because the msb is 1
PF = 0 because there are 7(odd number) of 1 bits in the low byte of
  the result .
ZF = 0 because the result is nonzero.
CF = 1 because there is a carry out of the msb on addition.
OF = 0 because the sign of the stored result is the same as that of
  the numbers being added (as a binary addition, there is a carry
  into the msb and a carry out).
   Example 2. ADD AX, BX, where AX contains 7132h ,
    BX contains 7000h
   Solution:          7132h
                    + 7000h
                      E132h
   The result stored in AX is E132h=1110 0001 0011 0010
   SF = 1 because the msb is 1
   PF = 0 because there are 3(odd number) of 1 bits in the
    low byte of the result .
   ZF = 0 because the result is nonzero.
   CF = 0 because there is no a carry out of the msb on
    addition.
   OF = 1
   Example-3: SUB AX, BX , where AX contains 8000h and BX
    contains 0001h.
   Solution:        8000h
                   -0001h
                    7FFFh
   The result stored in AX is FFFEh=0111 1111 1111 1111
   SF = 0 because the msb is 0
   PF = 1 because there are 8(even number) of 1 bits in the low byte
    of the result .
   ZF = 0 because the result is nonzero.
   CF = 0 because a smaller unsigned number is being subtracted
    from a larger one.

   Now for OF. In a signal sense, we are subtracting a positive number
    from a negative one, which is like adding two negatives. Because
    the result is positive (the wrong sign), OF = 1.
OVERFLOW

 The overflow flag is set when the Most Significant
  Bit (MSB) is set or cleared.
 For example, take the addition of 127 and 127.
  The 8 bit signed binary number of 127 is
  represented as 0111 1111.
 The MSB (the bit to the far left) is 0. When these
  two 8 bit numbers are added the result is 254, or
  1111 1110. Notice now that the MSB is now 1 and
  not 0.
 Therefore, the overflow flag has been set. Here,
  1111 1110 would be interpreted as a negative
  number.
   The addition test shows whether the overflow
    flag has been set.
    If two positive operands generate a negative
    sum. For example, 0101 1100 and 0100 1010 is
    1010 0110, or -90.
   The MSB changed from 0 to 1.
   And the two negative operands generate a
    positive sum.
   For example 1100 0010 and 1000 0100 is
    01101000 or 104.
   The MSB changed from 1 to 0, so the overflow
    flag is being set.
    Overflow never occurs when the sign of two
    addition operands are different.
(Signed) Overflow
   Can only occur when adding numbers of the same sign (subtracting
    with different signs)

   Detected when carry into MSB is not equal to carry out of MSB

   Easily detected because this implies the result has a different sign
    than the sign of the operands

   Programs can ignore the Flags
   Example 4. ADD AX,BX , where AX and BX both contains 7FFFh .

Solution:
                 Hex                    Binary
                7FFFh            0111 1111 1111 1111
                7FFFh            0111 1111 1111 1111
                FFFEh            1111 1111 1111 1110
    The signed and unsigned interpretation of 7FFFh is 32767. Thus for
    both signed and unsigned
    addition,7FFFh+7FFFh=32767+32767=65534.This is out of range
    for signed numbers, the signed interpretation of the stored answer
    FFFEh is -2,so signed overflow occurred .However the unsigned
    interpretation of FFFEh is 65534,which is the right answer, so there
    is no unsigned overflow.
Unsigned overflow:
   On addition, unsigned overflow occurs when there is a carry out of
    the msb.
   On subtraction unsigned overflow occurs when there is a borrow
    into the msb.

  Example 5. ADD AX, BX, where AX contains FF12h, BX contains
   1ACBh.
Solution:
             FF12h
          + 1ACBh
          119DDh
The result is stored in AX is 19DDh=0001 11 111 1101
FF12h=-1 and 1ACBh=1, and FF12h+1ACBh=-1+1=0, so sign overflow
   did
not occur. Here a 1 is carried out of the msb, so unsigned overflow
   occurred.
The importance of flag registers:

Flag register has it's importance by following resion.
1. Sign flag: use to store the sign of any number under processing i.e
when arithmetical logic has negative sign it is in set condition. and
rest in reset.
2. Zero flag: when ALU operation is zero it is in reset condition.
3. Auxiliary carry flag: it hold the carry during internal processing of
addition ,sub , mul and div.
4. Parity flag: hold 1 for even parity,0 for odd parity.
5. Carry flag: hold carry after end of processing of operation.
FLAGS Register & Flow
  control Instruction

           Flags Register
  Individual bits control the action or
represent the status of the processor
Control flags (TF, IF, DF): Determine how
          the processor responds
            to certain situations
    Status flags (CF, PF, AF, ZF, SF, OF):
•     Set to represent the result of certain
                 operations
  •     Used to control conditional jump
                instructions
Flow Control Instructions:

In this assignment we will practice how to
control the flow of an assembly language
program using the compare instruction, the
different jump instructions and the loop
instructions.
Objectives:
1- Jump Instructions.
2- Compare Instruction.
3- Loop Instructions.
Jump Instructions:

The jump instructions are used to transfer
the flow of the program to the indicated
Operator.
Here we discus about various categories.
Conditional Jumps:
There are Three categories of Conditional
Jumps:
 a)Singed Jumps
 b)Unsigned Jumps:
 c) Single-Flag Jumps:
The Unconditional Jump:

  The unconditional jump may be
used to make infinite loops. Though
 the use of such instructions is not
    recommended in high level
languages, due to the availability of
   program control structures, in
assembly however, most of the time
  one must use the unconditional
               jump.
The JMP Instructions

The JMP instruction causes an
   unconditional transfer of
 control(unconditional jump).
        The syntax is
IF-THEN:

• The IF-THEN structure may be expressed
  in pseudocode as follow

IF (condition is true)
   THEN
Execute true-branch statements
END_IF
IF-THEN-ELSE
IF condition is true
     THEN
Execute true-branch statements

ELSE
  Execute false-branch statements

END-IF
Loop
Loops represent the final basic control structure
(sequences, decisions, and loops) which make
up a typical program. Program loops consist of
three components: an optional initialization
component, a loop termination test, and the
body of the loop.
FOR LOOP
 FOR LOOP_COUNT      Initialize
                       count
    times DO
    Statements    Statement

END_FOR
                  Count=count-1


                                  false
                    count=
                    o



                                  true
EXAMPLE
 Write a count-controlled loop to display A to Z 26
 character
The code is
         MOV     CX, 26
         MOV     AH, 2
         MOV     DL, ’A’
     TOP:
          INT    21H
          LOOP   TOP
While Loops
 WHILE condition
Do
   Statements
 END_WHILE
Example
   I = 0;                    mov I, 0
 WHILE (I<100)   WhileLp:   cmp I, 100
   I = I + 1;               jge   WhileDone
                                  inc I
                 jmp   WhileLp
REPEAT LOOP

REAPET             Statement

  Statements
UNTLIE condition


                      count=
                               false
                      o

                               true
Example
    MOV AH,1
LOOP1:
    INT 21H
CMP al, '.'
    JE EndLoop
    JNE LOOP1
EndLoop:
Assignment on alp

Más contenido relacionado

La actualidad más candente

Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Bilal Amjad
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructionswarda aziz
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...warda aziz
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Bilal Amjad
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Bilal Amjad
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086University of Gujrat, Pakistan
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Bilal Amjad
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUEducation
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)Hareem Aslam
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
Assembly language
Assembly language Assembly language
Assembly language Usama ahmad
 
Text Mode Programming in Assembly
Text Mode Programming in AssemblyText Mode Programming in Assembly
Text Mode Programming in AssemblyJaveria Yaqoob
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionBadrul Alam
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086COMSATS Abbottabad
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.NA000000
 
Assembly language (addition and subtraction)
Assembly language (addition and subtraction)Assembly language (addition and subtraction)
Assembly language (addition and subtraction)Muhammad Umar Farooq
 

La actualidad más candente (20)

Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
 
Chapter 6 Flow control Instructions
Chapter 6 Flow control InstructionsChapter 6 Flow control Instructions
Chapter 6 Flow control Instructions
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
 
DAA AND DAS
DAA AND DASDAA AND DAS
DAA AND DAS
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Assembly language
Assembly language Assembly language
Assembly language
 
Text Mode Programming in Assembly
Text Mode Programming in AssemblyText Mode Programming in Assembly
Text Mode Programming in Assembly
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Assembly language (addition and subtraction)
Assembly language (addition and subtraction)Assembly language (addition and subtraction)
Assembly language (addition and subtraction)
 

Destacado

Assembly jmp presentation
Assembly jmp presentationAssembly jmp presentation
Assembly jmp presentationmazb786
 
Microprocessors - 80386DX
Microprocessors - 80386DXMicroprocessors - 80386DX
Microprocessors - 80386DXPriyaDYP
 
Intruduction conditional statement
Intruduction conditional statementIntruduction conditional statement
Intruduction conditional statementKhwaja Agha Karimi
 
Embedded c programming
Embedded c programmingEmbedded c programming
Embedded c programmingPriyaDYP
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Bilal Amjad
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statementselissamiller
 
ALP presentation
ALP presentationALP presentation
ALP presentationcccscoetc
 
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리중선 곽
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systemsjoshparrish13
 

Destacado (11)

Assembly jmp presentation
Assembly jmp presentationAssembly jmp presentation
Assembly jmp presentation
 
Microprocessors - 80386DX
Microprocessors - 80386DXMicroprocessors - 80386DX
Microprocessors - 80386DX
 
Intruduction conditional statement
Intruduction conditional statementIntruduction conditional statement
Intruduction conditional statement
 
8085 intro
8085 intro8085 intro
8085 intro
 
Embedded c programming
Embedded c programmingEmbedded c programming
Embedded c programming
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 1(Microcomputer ...
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
 
ALP presentation
ALP presentationALP presentation
ALP presentation
 
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
프로그래머가 알아야 하는 2진수 기반의 컴퓨터 동작 원리
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systems
 

Similar a Assignment on alp

Flags
FlagsFlags
FlagsCME
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxAssembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxishitasabrincse
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptssuser2b759d
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Anwar Hasan Shuvo
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086John Cutajar
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediateJohn Cutajar
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamDr. Girish GS
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Irfan Anjum
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions setRobert Almazan
 
Lecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxLecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxImranBhatti58
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptxNishatNishu5
 

Similar a Assignment on alp (20)

assembly flag resister
assembly flag resisterassembly flag resister
assembly flag resister
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
 
Flag control
Flag controlFlag control
Flag control
 
Flags
FlagsFlags
Flags
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxAssembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptx
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.ppt
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)
 
Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
 
Hemanth143
Hemanth143 Hemanth143
Hemanth143
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
Lecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxLecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptx
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 

Último

Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789CristineGraceAcuyan
 
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...nirzagarg
 
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Nitya salvi
 
Minimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptxMinimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptxbalqisyamutia
 
Sweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxSweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxbingyichin04
 
Essential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideEssential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideDesign Studio UI UX
 
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best ServiceIndependent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKMarekMitek1
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxNikhil Raut
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证wpkuukw
 
Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...gajnagarg
 
Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...
Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...
Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...HyderabadDolls
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...Amil baba
 
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证ehyxf
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证eqaqen
 
Design-System - FinTech - Isadora Agency
Design-System - FinTech - Isadora AgencyDesign-System - FinTech - Isadora Agency
Design-System - FinTech - Isadora AgencyIsadora Agency
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证eeanqy
 
Gamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad IbrahimGamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad Ibrahimamgadibrahim92
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样yhavx
 
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfJordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfamanda2495
 

Último (20)

Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
 
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
 
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
 
Minimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptxMinimalist Orange Portfolio by Slidesgo.pptx
Minimalist Orange Portfolio by Slidesgo.pptx
 
Sweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxSweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptx
 
Essential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideEssential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive Guide
 
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best ServiceIndependent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
 
Furniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptxFurniture & Joinery Details_Designs.pptx
Furniture & Joinery Details_Designs.pptx
 
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
一比一定(购)卡尔顿大学毕业证(CU毕业证)成绩单学位证
 
Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Meerut [ 7014168258 ] Call Me For Genuine Models We...
 
Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...
Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...
Madhyamgram \ (Genuine) Escort Service Kolkata | Service-oriented sexy call g...
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
 
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
 
Design-System - FinTech - Isadora Agency
Design-System - FinTech - Isadora AgencyDesign-System - FinTech - Isadora Agency
Design-System - FinTech - Isadora Agency
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
 
Gamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad IbrahimGamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad Ibrahim
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
 
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfJordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
 

Assignment on alp

  • 1.
  • 2. Name ID DULAL CHANDRA BARMAN 00805010 MD.JAHURUL ISLAM 00805034 MD.EMDADUL HUQ 00805038 MD.FARUQ AHMED 00805047 ASHOK KUMAR SARKER 00805049
  • 3. FLAG REGISTER FLAGS Register:  Individual bits control the action or represent the status of the processor Control flags (TF, IF, DF):  Determine how the processor responds to certain situations Status flags (CF, PF, AF, ZF, SF, OF):  Set to represent the result of certain operations  Used to control conditional jump instructions
  • 4. FLAG Register Bits: Status Flags: Control Flags: Bit Name Symb ol Bit Name Symb ol 0 Carry flag CF 8 Trap flag TF 2 Parity flag PF 4 Auxiliary carry flag AF 9 Interrupt flag IF 6 Zero flag ZF 10 Direction flag DF 7 Sign flag SF 11 Overflow flag OF
  • 5. Status Flags: The Carry Flag (CF):  CF = 1 if there is a carry out from the msb (most significant bit) on addition, or there is a borrow into the msb on subtraction  CF = 0 otherwise  CF is also affected by shift and rotate instructions The Parity Flag (PF):  PF = 1 if the low byte of a result has an even number of one bits (even parity)  PF = 0 otherwise (odd parity)
  • 6. The Auxiliary Carry Flag (AF):  AF = 1 if there is a carry out from bit 3 on addition, or there is a borrow into the bit 3 on subtraction  AF = 0 otherwise  AF is used in binary-coded decimal (BCD) operations The Zero Flag (ZF):  ZF = 1 for a zero result  ZF = 0 for a non-zero result The Sign Flag (SF):  SF = 1 if the msb of a result is 1; it means the result is negative if you are giving a signed interpretation  SF = 0 if the msb is 0
  • 7. The Overflow Flag (OF):  OF = 1 if signed overflow occurred  OF = 0 otherwise Example 1. ADD AX,BX , where AX contains FFFFh , BX contains FFFFh. Solution: FFFFh + FFFFh 1FFFEh The result stored in AX is FFFEh=1111 1111 1111 1110 SF = 1 because the msb is 1 PF = 0 because there are 7(odd number) of 1 bits in the low byte of the result . ZF = 0 because the result is nonzero. CF = 1 because there is a carry out of the msb on addition. OF = 0 because the sign of the stored result is the same as that of the numbers being added (as a binary addition, there is a carry into the msb and a carry out).
  • 8. Example 2. ADD AX, BX, where AX contains 7132h , BX contains 7000h  Solution: 7132h  + 7000h  E132h  The result stored in AX is E132h=1110 0001 0011 0010  SF = 1 because the msb is 1  PF = 0 because there are 3(odd number) of 1 bits in the low byte of the result .  ZF = 0 because the result is nonzero.  CF = 0 because there is no a carry out of the msb on addition.  OF = 1
  • 9. Example-3: SUB AX, BX , where AX contains 8000h and BX contains 0001h.  Solution: 8000h  -0001h  7FFFh  The result stored in AX is FFFEh=0111 1111 1111 1111  SF = 0 because the msb is 0  PF = 1 because there are 8(even number) of 1 bits in the low byte of the result .  ZF = 0 because the result is nonzero.  CF = 0 because a smaller unsigned number is being subtracted from a larger one.  Now for OF. In a signal sense, we are subtracting a positive number from a negative one, which is like adding two negatives. Because the result is positive (the wrong sign), OF = 1.
  • 10. OVERFLOW  The overflow flag is set when the Most Significant Bit (MSB) is set or cleared.  For example, take the addition of 127 and 127. The 8 bit signed binary number of 127 is represented as 0111 1111.  The MSB (the bit to the far left) is 0. When these two 8 bit numbers are added the result is 254, or 1111 1110. Notice now that the MSB is now 1 and not 0.  Therefore, the overflow flag has been set. Here, 1111 1110 would be interpreted as a negative number.
  • 11. The addition test shows whether the overflow flag has been set.  If two positive operands generate a negative sum. For example, 0101 1100 and 0100 1010 is 1010 0110, or -90.  The MSB changed from 0 to 1.  And the two negative operands generate a positive sum.  For example 1100 0010 and 1000 0100 is 01101000 or 104.  The MSB changed from 1 to 0, so the overflow flag is being set.  Overflow never occurs when the sign of two addition operands are different.
  • 12. (Signed) Overflow  Can only occur when adding numbers of the same sign (subtracting with different signs)  Detected when carry into MSB is not equal to carry out of MSB  Easily detected because this implies the result has a different sign than the sign of the operands  Programs can ignore the Flags
  • 13. Example 4. ADD AX,BX , where AX and BX both contains 7FFFh . Solution: Hex Binary 7FFFh 0111 1111 1111 1111 7FFFh 0111 1111 1111 1111 FFFEh 1111 1111 1111 1110 The signed and unsigned interpretation of 7FFFh is 32767. Thus for both signed and unsigned addition,7FFFh+7FFFh=32767+32767=65534.This is out of range for signed numbers, the signed interpretation of the stored answer FFFEh is -2,so signed overflow occurred .However the unsigned interpretation of FFFEh is 65534,which is the right answer, so there is no unsigned overflow.
  • 14. Unsigned overflow:  On addition, unsigned overflow occurs when there is a carry out of the msb.  On subtraction unsigned overflow occurs when there is a borrow into the msb.  Example 5. ADD AX, BX, where AX contains FF12h, BX contains 1ACBh. Solution: FF12h + 1ACBh 119DDh The result is stored in AX is 19DDh=0001 11 111 1101 FF12h=-1 and 1ACBh=1, and FF12h+1ACBh=-1+1=0, so sign overflow did not occur. Here a 1 is carried out of the msb, so unsigned overflow occurred.
  • 15. The importance of flag registers: Flag register has it's importance by following resion. 1. Sign flag: use to store the sign of any number under processing i.e when arithmetical logic has negative sign it is in set condition. and rest in reset. 2. Zero flag: when ALU operation is zero it is in reset condition. 3. Auxiliary carry flag: it hold the carry during internal processing of addition ,sub , mul and div. 4. Parity flag: hold 1 for even parity,0 for odd parity. 5. Carry flag: hold carry after end of processing of operation.
  • 16. FLAGS Register & Flow control Instruction Flags Register Individual bits control the action or represent the status of the processor
  • 17. Control flags (TF, IF, DF): Determine how the processor responds to certain situations Status flags (CF, PF, AF, ZF, SF, OF): • Set to represent the result of certain operations • Used to control conditional jump instructions
  • 18. Flow Control Instructions: In this assignment we will practice how to control the flow of an assembly language program using the compare instruction, the different jump instructions and the loop instructions. Objectives: 1- Jump Instructions. 2- Compare Instruction. 3- Loop Instructions.
  • 19. Jump Instructions: The jump instructions are used to transfer the flow of the program to the indicated Operator. Here we discus about various categories. Conditional Jumps: There are Three categories of Conditional Jumps: a)Singed Jumps b)Unsigned Jumps: c) Single-Flag Jumps:
  • 20. The Unconditional Jump: The unconditional jump may be used to make infinite loops. Though the use of such instructions is not recommended in high level languages, due to the availability of program control structures, in assembly however, most of the time one must use the unconditional jump.
  • 21. The JMP Instructions The JMP instruction causes an unconditional transfer of control(unconditional jump). The syntax is
  • 22. IF-THEN: • The IF-THEN structure may be expressed in pseudocode as follow IF (condition is true) THEN Execute true-branch statements END_IF
  • 23. IF-THEN-ELSE IF condition is true THEN Execute true-branch statements ELSE Execute false-branch statements END-IF
  • 24. Loop Loops represent the final basic control structure (sequences, decisions, and loops) which make up a typical program. Program loops consist of three components: an optional initialization component, a loop termination test, and the body of the loop.
  • 25. FOR LOOP FOR LOOP_COUNT Initialize count times DO Statements Statement END_FOR Count=count-1 false count= o true
  • 26. EXAMPLE Write a count-controlled loop to display A to Z 26 character The code is MOV CX, 26 MOV AH, 2 MOV DL, ’A’ TOP: INT 21H LOOP TOP
  • 27. While Loops WHILE condition Do Statements END_WHILE
  • 28. Example I = 0; mov I, 0 WHILE (I<100) WhileLp: cmp I, 100 I = I + 1; jge WhileDone inc I jmp WhileLp
  • 29. REPEAT LOOP REAPET Statement Statements UNTLIE condition count= false o true
  • 30. Example MOV AH,1 LOOP1: INT 21H CMP al, '.' JE EndLoop JNE LOOP1 EndLoop: