SlideShare a Scribd company logo
Assignment on alp
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
Ad

More Related Content

What's hot (20)

Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
Hareem Aslam
 
Assembly language
Assembly language Assembly language
Assembly language
Usama ahmad
 
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
 
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 Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1
warda aziz
 
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
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computers
warda aziz
 
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
Education
 
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
 
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 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
John Cutajar
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
Mustafa Salah
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
Tech_MX
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with types
Ravinder Rautela
 
Assembly language (addition and subtraction)
Assembly language (addition and subtraction)Assembly language (addition and subtraction)
Assembly language (addition and subtraction)
Muhammad Umar Farooq
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
Ravi Anand
 
DAA AND DAS
DAA AND DASDAA AND DAS
DAA AND DAS
Basavaraj Shetty
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Tirumalesh Nizampatnam
 
8086
8086 8086
8086
ahmad abdelhafeez
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
Hareem Aslam
 
Assembly language
Assembly language Assembly language
Assembly language
Usama ahmad
 
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
 
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 Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1
warda aziz
 
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
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computers
warda aziz
 
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
Education
 
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
 
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 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
John Cutajar
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
Tech_MX
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with types
Ravinder Rautela
 
Assembly language (addition and subtraction)
Assembly language (addition and subtraction)Assembly language (addition and subtraction)
Assembly language (addition and subtraction)
Muhammad Umar Farooq
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
Ravi Anand
 

Viewers also liked (11)

Assembly jmp presentation
Assembly jmp presentationAssembly jmp presentation
Assembly jmp presentation
mazb786
 
Microprocessors - 80386DX
Microprocessors - 80386DXMicroprocessors - 80386DX
Microprocessors - 80386DX
PriyaDYP
 
Intruduction conditional statement
Intruduction conditional statementIntruduction conditional statement
Intruduction conditional statement
Khwaja Agha Karimi
 
8085 intro
8085 intro8085 intro
8085 intro
deval patel
 
Embedded c programming
Embedded c programmingEmbedded c programming
Embedded c programming
PriyaDYP
 
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 statements
Suneel Dogra
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
elissamiller
 
ALP presentation
ALP presentationALP presentation
ALP presentation
cccscoetc
 
프로그래머가 알아야 하는 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
joshparrish13
 
Assembly jmp presentation
Assembly jmp presentationAssembly jmp presentation
Assembly jmp presentation
mazb786
 
Microprocessors - 80386DX
Microprocessors - 80386DXMicroprocessors - 80386DX
Microprocessors - 80386DX
PriyaDYP
 
Intruduction conditional statement
Intruduction conditional statementIntruduction conditional statement
Intruduction conditional statement
Khwaja Agha Karimi
 
Embedded c programming
Embedded c programmingEmbedded c programming
Embedded c programming
PriyaDYP
 
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 statements
Suneel Dogra
 
Conditional Statements
Conditional StatementsConditional Statements
Conditional Statements
elissamiller
 
ALP presentation
ALP presentationALP presentation
ALP presentation
cccscoetc
 
프로그래머가 알아야 하는 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
joshparrish13
 
Ad

Similar to Assignment on alp (20)

assembly flag resister
assembly flag resisterassembly flag resister
assembly flag resister
safayet hossain
 
Exp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Exp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxExp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Exp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
anfaltahir1100
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
BELLALHOSSAIN31
 
Flag control
Flag controlFlag control
Flag control
Robert Almazan
 
Flags
FlagsFlags
Flags
CME
 
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
ishitasabrincse
 
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
ssuser2b759d
 
LEC 15 BOLEAN OPERATORS in comsats university.pptx
LEC 15 BOLEAN OPERATORS in comsats university.pptxLEC 15 BOLEAN OPERATORS in comsats university.pptx
LEC 15 BOLEAN OPERATORS in comsats university.pptx
muhahmad0345
 
LEC 15 BOLEAN OPERATORS in comsats university.pptx
LEC 15 BOLEAN OPERATORS in  comsats university.pptxLEC 15 BOLEAN OPERATORS in  comsats university.pptx
LEC 15 BOLEAN OPERATORS in comsats university.pptx
muhahmad0345
 
lecture4 control flow instruction in assembly.pptx
lecture4 control flow instruction in assembly.pptxlecture4 control flow instruction in assembly.pptx
lecture4 control flow instruction in assembly.pptx
malnaham
 
Flag Registers in Computer Architecture: Functions and Importance
Flag Registers in Computer Architecture: Functions and ImportanceFlag Registers in Computer Architecture: Functions and Importance
Flag Registers in Computer Architecture: Functions and Importance
Marcel David
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
Abdullelah Al-Fahad
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
John Cutajar
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
Nora Youssef
 
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
Dr. Girish GS
 
Hemanth143
Hemanth143 Hemanth143
Hemanth143
vijaydeepakg
 
[ASM]Lab4
[ASM]Lab4[ASM]Lab4
[ASM]Lab4
Nora Youssef
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
Robert Almazan
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
guest2bb25
 
Exp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Exp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxExp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Exp 7.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
anfaltahir1100
 
Flags
FlagsFlags
Flags
CME
 
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
ishitasabrincse
 
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
ssuser2b759d
 
LEC 15 BOLEAN OPERATORS in comsats university.pptx
LEC 15 BOLEAN OPERATORS in comsats university.pptxLEC 15 BOLEAN OPERATORS in comsats university.pptx
LEC 15 BOLEAN OPERATORS in comsats university.pptx
muhahmad0345
 
LEC 15 BOLEAN OPERATORS in comsats university.pptx
LEC 15 BOLEAN OPERATORS in  comsats university.pptxLEC 15 BOLEAN OPERATORS in  comsats university.pptx
LEC 15 BOLEAN OPERATORS in comsats university.pptx
muhahmad0345
 
lecture4 control flow instruction in assembly.pptx
lecture4 control flow instruction in assembly.pptxlecture4 control flow instruction in assembly.pptx
lecture4 control flow instruction in assembly.pptx
malnaham
 
Flag Registers in Computer Architecture: Functions and Importance
Flag Registers in Computer Architecture: Functions and ImportanceFlag Registers in Computer Architecture: Functions and Importance
Flag Registers in Computer Architecture: Functions and Importance
Marcel David
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
John 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 progam
Dr. Girish GS
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
Robert Almazan
 
Ad

Recently uploaded (20)

PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...
PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...
PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...
officialpino35
 
PWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's Work
PWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's WorkPWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's Work
PWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's Work
INKPPT
 
COLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERS
COLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERSCOLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERS
COLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERS
alainyanda99
 
Learn the ABC with Bauhaus by Klara Francisco.pdf
Learn the ABC with Bauhaus by Klara Francisco.pdfLearn the ABC with Bauhaus by Klara Francisco.pdf
Learn the ABC with Bauhaus by Klara Francisco.pdf
KlaraJericaFrancisco
 
Traceability and Uncertainty of measurement
Traceability and Uncertainty of measurementTraceability and Uncertainty of measurement
Traceability and Uncertainty of measurement
artiaghera85
 
White Blue Simple Modern Enhancing Sales Strategy Presentation.pptx
White Blue Simple Modern Enhancing Sales Strategy Presentation.pptxWhite Blue Simple Modern Enhancing Sales Strategy Presentation.pptx
White Blue Simple Modern Enhancing Sales Strategy Presentation.pptx
adamolnar2010
 
FLOOR-PLAN Junior high school architecture planning.docx
FLOOR-PLAN Junior high school architecture planning.docxFLOOR-PLAN Junior high school architecture planning.docx
FLOOR-PLAN Junior high school architecture planning.docx
JamelaTeo
 
McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...
McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...
McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...
INKPPT
 
Mars.pptx we known about the mars using this ppt
Mars.pptx we known about the mars using this pptMars.pptx we known about the mars using this ppt
Mars.pptx we known about the mars using this ppt
shameer200479
 
Unit 5 visual merchandiseing trend analysis. pdf
Unit 5 visual merchandiseing  trend analysis. pdfUnit 5 visual merchandiseing  trend analysis. pdf
Unit 5 visual merchandiseing trend analysis. pdf
NaziaFarheen13
 
iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]
iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]
iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]
Web Designer
 
BHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMN
BHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMNBHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMN
BHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMN
05241146
 
Carte d'indentité1 a model for a nes country
Carte d'indentité1 a model for a nes countryCarte d'indentité1 a model for a nes country
Carte d'indentité1 a model for a nes country
stephaniethomas940921
 
A Sneak Peek into Communication Design by Ayon
A Sneak Peek into Communication Design by AyonA Sneak Peek into Communication Design by Ayon
A Sneak Peek into Communication Design by Ayon
aonbanerjee
 
EHR Usability: Current Challenges and Impacts on Physicians and Patients
EHR Usability: Current Challenges and Impacts on Physicians and PatientsEHR Usability: Current Challenges and Impacts on Physicians and Patients
EHR Usability: Current Challenges and Impacts on Physicians and Patients
Dan Berlin
 
KPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation Trends
KPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation TrendsKPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation Trends
KPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation Trends
INKPPT
 
Accenture Life Trends 2023 – How Brands & Humans Are Evolving Together
Accenture Life Trends 2023 – How Brands & Humans Are Evolving TogetherAccenture Life Trends 2023 – How Brands & Humans Are Evolving Together
Accenture Life Trends 2023 – How Brands & Humans Are Evolving Together
INKPPT
 
ppt nm epanet org irrigation system (1).pptx
ppt nm epanet org irrigation system (1).pptxppt nm epanet org irrigation system (1).pptx
ppt nm epanet org irrigation system (1).pptx
dondeepakff33
 
EY – The Future of Assurance | How Technology is Transforming the Audit
EY – The Future of Assurance | How Technology is Transforming the AuditEY – The Future of Assurance | How Technology is Transforming the Audit
EY – The Future of Assurance | How Technology is Transforming the Audit
INKPPT
 
McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030
McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030
McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030
INKPPT
 
PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...
PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...
PINOQQ SITUS MUDAH MERAIH KEMENANGAN SEGERA DAFTAR DAN RAIH KEMENANGAN NYA HA...
officialpino35
 
PWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's Work
PWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's WorkPWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's Work
PWC – Workforce of the Future 2030 | Four Scenarios Shaping Tomorrow's Work
INKPPT
 
COLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERS
COLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERSCOLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERS
COLOR THEROY IN GRAPHIC DESIGN HANDBOOK FOR BEGINNERS
alainyanda99
 
Learn the ABC with Bauhaus by Klara Francisco.pdf
Learn the ABC with Bauhaus by Klara Francisco.pdfLearn the ABC with Bauhaus by Klara Francisco.pdf
Learn the ABC with Bauhaus by Klara Francisco.pdf
KlaraJericaFrancisco
 
Traceability and Uncertainty of measurement
Traceability and Uncertainty of measurementTraceability and Uncertainty of measurement
Traceability and Uncertainty of measurement
artiaghera85
 
White Blue Simple Modern Enhancing Sales Strategy Presentation.pptx
White Blue Simple Modern Enhancing Sales Strategy Presentation.pptxWhite Blue Simple Modern Enhancing Sales Strategy Presentation.pptx
White Blue Simple Modern Enhancing Sales Strategy Presentation.pptx
adamolnar2010
 
FLOOR-PLAN Junior high school architecture planning.docx
FLOOR-PLAN Junior high school architecture planning.docxFLOOR-PLAN Junior high school architecture planning.docx
FLOOR-PLAN Junior high school architecture planning.docx
JamelaTeo
 
McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...
McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...
McKinsey – Mobility Consumer Pulse 2024 | Global Trends in EVs, Shared Mobili...
INKPPT
 
Mars.pptx we known about the mars using this ppt
Mars.pptx we known about the mars using this pptMars.pptx we known about the mars using this ppt
Mars.pptx we known about the mars using this ppt
shameer200479
 
Unit 5 visual merchandiseing trend analysis. pdf
Unit 5 visual merchandiseing  trend analysis. pdfUnit 5 visual merchandiseing  trend analysis. pdf
Unit 5 visual merchandiseing trend analysis. pdf
NaziaFarheen13
 
iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]
iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]
iTools 4.5.1.8 Crack + License Key Free Download [Latest 2025]
Web Designer
 
BHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMN
BHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMNBHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMN
BHSIWIKJHDCU.pptx MCXDT789OKNBVCDRT678IOLKNBVCXDRTYUIOKMN
05241146
 
Carte d'indentité1 a model for a nes country
Carte d'indentité1 a model for a nes countryCarte d'indentité1 a model for a nes country
Carte d'indentité1 a model for a nes country
stephaniethomas940921
 
A Sneak Peek into Communication Design by Ayon
A Sneak Peek into Communication Design by AyonA Sneak Peek into Communication Design by Ayon
A Sneak Peek into Communication Design by Ayon
aonbanerjee
 
EHR Usability: Current Challenges and Impacts on Physicians and Patients
EHR Usability: Current Challenges and Impacts on Physicians and PatientsEHR Usability: Current Challenges and Impacts on Physicians and Patients
EHR Usability: Current Challenges and Impacts on Physicians and Patients
Dan Berlin
 
KPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation Trends
KPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation TrendsKPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation Trends
KPMG – Global Tech Report 2022 | Web3, Metaverse & Digital Transformation Trends
INKPPT
 
Accenture Life Trends 2023 – How Brands & Humans Are Evolving Together
Accenture Life Trends 2023 – How Brands & Humans Are Evolving TogetherAccenture Life Trends 2023 – How Brands & Humans Are Evolving Together
Accenture Life Trends 2023 – How Brands & Humans Are Evolving Together
INKPPT
 
ppt nm epanet org irrigation system (1).pptx
ppt nm epanet org irrigation system (1).pptxppt nm epanet org irrigation system (1).pptx
ppt nm epanet org irrigation system (1).pptx
dondeepakff33
 
EY – The Future of Assurance | How Technology is Transforming the Audit
EY – The Future of Assurance | How Technology is Transforming the AuditEY – The Future of Assurance | How Technology is Transforming the Audit
EY – The Future of Assurance | How Technology is Transforming the Audit
INKPPT
 
McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030
McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030
McKinsey’s Fashion on Climate Report: A Roadmap to Cut Emissions by 50% by 2030
INKPPT
 

Assignment on alp

  • 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:
  翻译: