24
COA PRESENTATION

Assembly jmp presentation

  • Upload
    mazb786

  • View
    79

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Assembly jmp presentation

COAPRESENTATION

Page 2: Assembly jmp presentation

Muhammad Umer Ahsan

Mateen Arshad

Muhammad Zeshan

Awais Zia Butt

Ali Zain

COMSATS Institute Of Information and

Technology, Sahiwal PAKISTAN

GROUP MEMBERS

Page 3: Assembly jmp presentation

Unconditional instruction

Control unit jumps to some arbitrary address as the next

instruction to be executed.

Example:

Mov al,01

Add al,01

Mov bl,05

Cmp al,bl

Je 010c

Jmp 0102

Int 20

JUMP(JMP)

JMP instruction will continue adding 1 in al until al=05

Page 4: Assembly jmp presentation

Conditional instructions (depend on CMP instruction)

Both JA and JG are use to check whether the 1st operand is greater then the 2nd one or not.

Example:

Mov al,02

Mov bl,01

Cmp al,bl

JA 0110

Mov dl,53

Mov ah,02

Int 21

Int20

Mov dl,47

Mov ah,02

Int 21

JUMP IF ABOVE (JA)JUMP IF GREATER (JG)

Here the result will be “G” because 2 is greater then 1.

&

Page 5: Assembly jmp presentation

Conditional instructions

Both JB and JL check whether the 1 st operand is less than the 2nd one or not.

Example:Mov al,01

Mov bl,02

Cmp al,bl

Jl 0110

Mov dl,47

Mov ah,02

Int 21

Int 20

Mov dl,53

Mov ah,02

Int 21

Int 20

JUMP IF BELOW (JB)JUMP IF LESS (JL)

“S” displays because 01<02

&

Page 6: Assembly jmp presentation

Conditional instructions

JNG & JNA executes when 1 st operand is not greater than the 2 nd one.

Example:

Mov ah,01

Int 21

Sub al ,30

Mov bl ,02

Cmp al ,bl

Jng 0114

Mov dl ,47

Mov ah,02

Int 21

Int20

Mov dl ,53

Mov ah,02

Int 21

int20

JUMP IF NOT ABOVE(JNA)JUMP IF NOT GREATER(JNG)

&

When input!>02 then “S” displays.

Page 7: Assembly jmp presentation

Conditional instructions

Both JNB & JNL executes when 1st operand is not less than the 2nd one.

Example:

Mov ah,01

Int 21

Sub al ,30

Mov bl ,02

Cmp al ,bl

Jnb 0114

Mov dl ,53

Mov ah,02

Int 21

Int 20

Mov dl ,47

Mov ah,02

Int 21

Int 20

JUMP IF NOT BELOW(JNB)JUMP IF NOT LESS(JNL)

JNB can easily be replaced by JNL. Both perform the same function.

Page 8: Assembly jmp presentation

Conditional instruction

Both JAE and JGE are use to check whether the 1st operand is greater than or equal to the second one or not.

Example:Mov ah,01

Int 21

Sub al ,30

Mov bl ,05

Cmp al ,bl

Jae 0114

Mov dl ,4e

Mov ah,02

Int 21

Int 20

Mov dl ,59

Mov ah,02

Int 21

Int 20

JUMP IF ABOVE OR EQUAL (JAE)JUMP IF GREATER OR EQUAL (JGE)

JAE will check that the input>=5 or not. JAE can easily be

replaced by JGE without changing the other code.

&

Page 9: Assembly jmp presentation

Conditional instruction

JBE and JLE instructions are use to check whether the 1st operand is less than or equal to the 2nd one or not.

Example:Mov ah,01

Int 21

Sub al ,30

Mov bl ,05

Cmp al ,b l

Jbe 0114

Mov dl ,59

Mov ah,02

Int 21

Int 20

Mov dl ,4e

Mov ah,02

Int 21

Int 20

JUMP IF BELOW OR EQUAL(JBE)JUMP IF LESS OR EQUAL(JLE)

&

JBE will check that the input<=5 or not. If yes than “N” will

display otherwise “Y” will display.

Page 10: Assembly jmp presentation

Condit ional instructions

JNAE & JNGE executes when 1st operand is not greater than nor equal to the 2nd one.

Example:

Mov ah,01

Int 21

Sub al ,30

Mov bl ,05

Cmp al ,bl

Jnge 0114

Mov dl ,59

Mov ah,02

Int 21

Int 20

Mov dl , 4e

Mov ah,02

Int 21

Int 20

JUMP IF NOT ABOVE NOR EQUAL(JNAE)JUMP IF N0T GREATER NOR EQUAL(JNGE)

&

“N” displays when input <=5

“Y” displays when input >=5

Page 11: Assembly jmp presentation

Condit ional instructions

These instructions executes when 1st operand is not less than nor equal to the 2nd one.

Example:

Mov ah,01

Int 21

Sub al ,30

Mov bl ,05

Cmp al ,bl

Jnle 0114

Mov dl ,59

Mov ah,02

Int 21

Int 20

Mov dl ,4e

Mov ah,02

Int 21

Int 20

JUMP IF NOT BELOW NOR EQUAL(JNBE)JUMP IF NOT LESS NOR EQUAL(JNLE)&

“N” displays when input !<=5.

Page 12: Assembly jmp presentation

Conditional instruction

JC executes if the carry flag is on i.e CF=1

Example :

Mov ah,01

Int 21

Sub al ,30

Mov bl ,09

Mul bl

Jc 0114

Mov dl ,4e

Mov ah,02

Int 21

Int 20

Mov dl ,59

Mov ah,02

Int 21

Int 20

JUMP IF CARRY(JC)

ASCII of “f” is 66 and of “F” is 46.

Page 13: Assembly jmp presentation

Condit ional instruction

JNC executes when carry flag is of f i .e CF= 0

Example:

Mov ah,01

Int 21

Sub al ,30

Mov bl ,09

Mul bl

Jnc 0114

Mov dl ,59

Mov ah,02

Int 21

Int 20

Mov dl ,4e

Mov ah,02

Int 21

Int 20

JUMP IF NOT CARRY(JNC)

ASCII of “f” is 66.

Page 14: Assembly jmp presentation

Conditional instruction

JE executes when 1st operand is equal to the 2nd one.

Example:Mov ah,01

Int 21

Sub al ,30

Mov bl ,al

Int 21

Sub al ,30

Cmp al ,bl

Je 0118

Mov dl ,4e

Mov ah,02

Int 21

Int 20

Mov dl ,59

Mov ah,02

Int 21

Int 20

JUMP IF EQUAL(JE)

JE will check that both inputs are same or not.

Page 15: Assembly jmp presentation

Condit ional instruction

JNE executes when 1st operand is not equal to the 2nd one.

Example:

Mov ah,01

Int 21

Sub al ,30

Mov bl ,al

Int 21

Sub al ,30

Cmp al ,bl

Jne 0118

Mov dl ,59

Mov ah,02

Int 21

Int 20

Mov dl ,4e

Mov ah,02

Int 21

Int 20

JUMP IF NOT EQUAL(JNE)

N will display when both inputs are not same.

Page 16: Assembly jmp presentation

Conditional instructions

Both JP & JPE executes when Parity flag is on i .e PF= 1

Example:

Mov ah,01

Int 21

Sub al,30

Jpe 0110

Mov dl,4e

Mov ah,02

Int 21

Int 20

Mov dl,59

Mov ah,02

Int 21

Int 20

JUMP IF PARITY(JP)JUMP IF PARITY EVEN(JPE)

&

Parity of 3 is even so Y displays

Page 17: Assembly jmp presentation

Conditional instruction

Both JNP & JPO executes when parity flag is zero.

Example:Mov ah,01

Int 21

Sub al,30

Jnp 0110

Mov dl,4e

Mov ah,02

Int 21

Int 20

Mov dl,59

Mov ah,02

Int 21

Int 20

JUMP IF NO PARITY(JNP)JUMP IF PARITY ODD(JPO)

&

In machine language 3=0011, which has even parity so PF=1

And 4=0100, which is odd so PF =0 and Y displays.

Page 18: Assembly jmp presentation

Conditional instruction

JZ executes when Zero flag is on i.e ZF=1

Example :

Mov ah,01

Int 21

Sub al,30

Mov bl,05

Sub al,bl

Jz 0114

Mov dl,4E

Mov ah,02

Int 21

Int20

Mov dl,5A

Mov ah,02

Int 21

int20

JUMP IF ZERO(JZ)

When input=5 then ZF will be on and Z will be displayed.

Page 19: Assembly jmp presentation

Conditional instruction

JNZ executes when Zero flag is of f i .e ZF=0

Example :

Mov ah,01

Int 21

Sub al ,30

Mov bl ,05

Sub al ,bl

Jnz 0114

Mov dl ,5a

Mov ah,02

Int 21

Int20

Mov dl ,4e

Mov ah,02

Int 21

int20

JUMP IF NOT ZERO(JNZ)

ZF=1 when input=5 otherwise it will be zero and N displays

Page 20: Assembly jmp presentation

Conditional instruction

JS executes when Sign flag is On i.e SF=1 and SF On when result is negative.

Example:Mov ah,01

Int 21

Sub al ,30

Mov bl ,f f

cmp bl ,al

Js 0114

Mov dl ,4e

Mov ah,02

Int 21

Int 20

Mov dl ,59

Mov ah,02

Int 21

Int 20

JUMP IF SIGNED(JS)

Cmp inst subtract al from bl and change the SF to 1.

Page 21: Assembly jmp presentation

Conditional instruction

JNS executes when Sign flag is Off i .e SF=0 and SF Off when result is +ve.

Example:Mov ah,01

Int 21

Sub al ,30

Mov bl ,f

cmp bl ,al

Jns 0114

Mov dl ,4e

Mov ah,02

Int 21

Int 20

Mov dl ,59

Mov ah,02

Int 21

Int 20

JUMP IF NOT SIGNED(JNS)

Jns executes until the result will be +ve i.e SF=0

Page 22: Assembly jmp presentation

Conditional instruction

JO executes when overflow flag is On i.e OF=1

Example:

Mov al, -5

Sub al,7e

Jo 010e

Mov dl,4e

Mov ah,02

Int 21

Int 20

Mov dl,59

Mov ah,02

Int 21

Int 20

JUMP IF OVERFLOW(JO)

-5-127=-132 which is not in range (-128….127) so JO

executes and “Y” displays

Page 23: Assembly jmp presentation

Conditional instruction

JNO executes when overflow flag is off i .e OF!= 1

Example:

Mov al, -5

Sub al,7e

Jno 010e

Mov dl,59

Mov ah,02

Int 21

Int 20

Mov dl,4e

Mov ah,02

Int 21

Int 20

JUMP IF NOT OVERFLOW(JNO)

JNO not executes because -5-127=-132 which is not in the

range (-128…127) so there is an overflow

Page 24: Assembly jmp presentation

Conditional instruction

JCXZ executes when counter register is zero i .e CX= 0

Example:Mov ah,01

Int 21

Sub al ,30

Add cl ,al

JCXZ 0116

Mov bl ,05

Cmp cl ,bl

J le 0100

Sub cl ,cl

Jmp 0108

Int 20

Mov dl ,5A

Mov ah,02

Int 21

Int 20

JUMP IF CX IS ZERO(JCXZ)

Whenever the sum of inputs exceeds 5, CX becomes zero

and “Z” displays.