Professional Documents
Culture Documents
Objectives:: Lab#4: Jump Instructions SSUET/QR/114
Objectives:: Lab#4: Jump Instructions SSUET/QR/114
LAB#4
Objectives:
To introduce control flow instructions
Jump instructions are used to change the flow of a Assembly language program. Jump
instructions are two types:
Unconditional Jump
The JMP instruction, whose syntax is:
JMP target
Transfers unconditionally control to the target location.
Conditional Jump-Instructions
Conditional jumps are of the general form:
JconditionStatementLabel
where (i) condition is one, two, or three letters (ii) the Statement Label must in the current code
segment and within 128 to +127 bytes from the conditional jump instruction.
SUB AX , BX
L2:
JE , JZ ZF = 1 Jump if equal
JC CF = 1 Jump if carry
JO OF = 1 Jump if overflow
JP, JPE PF = 1 Jump if parity even, i.e., if there is an even number of 1 bits in
the result.
JNP, JPO PF = 0 Jump if parity odd, i.e., if there is an odd number of 1 bits in
the result.
.model small
.stack 100h
.code
mainproc
Mov cx , 6
l1: mov ah , 02h
mov dl , ‘a’
int 21h
dec cx
jcxz l2
jmp l1
l2:
mov ah,4ch
int 21h
mainendp
end main
.model small
.stack 100h
.code
mainproc
Mov dl , ‘a’
@1: mov ah , 02h
int 21h
inc dl
cmp dl , ‘g’
jbe @1
mov ah,4ch
int 21h
mainendp
end main
Lab Tasks:
Task#1: Implement all codes given in above example.
SOLUTION
OUTPUT:
SOLUTION
OUTPUT:
Task#2: Display ‘*’ 10 times each in new line (Use NEW_LINE Macro)
SOLUTION:
OUTPUT:
SOLUTION:
OUTPUT:
SOLUTION:
OUTPUT:
SOLUTION:
OUTPUT:
SOLUTION:
OUTPUT:
Task#5: Display ASCII characters from A-Z and z-a each on new line
SOLUTION:
OUTPUT:
SOLUTION:
OUTPUT:
Task#6: Display printable key strokes of a keyboard until user prints Escape “Esc” key
(Hint: ASCII code of Esc is 27)
SOLUTION:
OUTPUT: