Professional Documents
Culture Documents
:
Name: Section:
Date Performed:
Date Submitted:
Instructor:
1. Objective(s):
The activity aims to introduce the control flow statements in assembly language.
The students shall be able to: construct a program with some conditions in assembly language
3. Discussion
Instructions are stored consecutively in memory, but program rarely execute in exact order. But the simplest
programs include jumps and procedure calls that alter the execution path the microprocessor takes. The
control flow can make a transfer from one part of a program to another and it divide into three groups
conditional, unconditional and CMP (CoMPare).
Conditional jump
a jump that is executer only if a specified condition is TRUE.
Format:
Jxx <label>
Opcode Meaning
Opcode Meaning
4. Resources:
1 Desktop Computer
TASM
5. Procedure:
A sample programs that input a single character using JGE, JL and unconditional jump instruction.
.model small
.stack
.data
.code
start:
mov ax, @data
mov ds,ax
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184Fh
int 10h
mov ah, 2
mov bh, 0
mov dh, 10 ; y position
mov dl, 14 ; x position
int 10h
mov ah, 9
mov dx, offset Var1
int 21h
mov ah, 2
mov bh, 0
mov dh, 10 ; y position
mov dl, 54 ; x position
int 10h
back:
cmp al, 61h
jge LOWnum
jmp wrong
UP:
cmp al, 5bh
jle dispUp
jmp back
dispUp:
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 12 ; y position
mov dl, 34 ; x position
int 10h
mov ah, 9
mov dx, offset Var2
int 21h
jmp exit
LOWnum:
cmp al, 7bh
jle dispLow
jmp wrong
dispLow:
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 12 ; y position
mov dl, 34 ; x position
int 10h
mov ah, 9
mov dx, offset Var3
int 21h
jmp exit
wrong:
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 12 ; y position
mov dl, 34 ; x position
int 10h
mov ah, 9
mov dx, offset Var4
int 21h
exit:
mov ah, 4ch
int 21h
end start
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 10 ; y position
mov dl, 14 ; x position
int 10h
mov ah, 9
mov dx, offset Var
int 21h
mov ah, 2
mov bh, 0
mov dh, 10 ; y position
mov dl, 54 ; x position
int 10h
mov ah, 1
int 21h
CORRECT1:
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 12 ; y position
mov dl, 34 ; x position
int 10h
mov ah, 9
mov dx, offset Var1
int 21h
jmp exit
CORRECT2:
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 12 ; y position
mov dl, 34 ; x position
int 10h
mov ah, 9
mov dx, offset Var2
int 21h
jmp exit
wrong:
mov ah, 6
mov bh, 10H
mov cx, 0
mov dx, 184fH
int 10h
mov ah, 2
mov bh, 0
mov dh, 12 ; y position
mov dl, 34 ; x position
int 10h
mov ah, 9
mov dx, offset Var3
int 21h
exit:
mov ah, 4ch
int 21h
end start
Using CMP, Conditional Jump and Unconditional Jump create a program that will allow the user to
input numbers from 0 to 9 only and will convert and display its equivalent number to word.
Create a program that will enter a user’s name and a password. If the username and password is correct, it
display the following:
Your username should be student number and your password should be your first name
7. Conclusion:
Based from the results of the experiment, what general rule can you apply for?
CONDITIONAL JUMP
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________
UNCONDITIONAL JUMP
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________