Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Celeste, Maria Geecel T.

CPE310/ Lab Activity F2

Create an Assembly Language Program that follows the following:

1. By using Compare and Jump commands, have 0-9 be TRUE while any other character
is FALSE.

.model small
.stack
.data
msg1 db "Enter a number (0-9): $"
msg2 db "Correct Input. $"
msg3 db "Wrong input. $"

.code
start:

mov ax, @data


mov ds, ax

input_loop:

mov ah, 9 ; Print msg1


mov dx, offset msg1
int 21h

mov ah, 1
int 21h

cmp al, '0'


jb Wrong_input ; Jump if below '0'

cmp al, '9'


ja Wrong_input ; Jump if above '9'

mov ah, 02
mov dl, 10
int 21h

mov ah, 9 ; Print msg2


mov dx, offset msg2

int 21h

jmp exit
Wrong_input:
mov ah, 02
mov dl, 10
int 21h

mov ah, 9 ; Print msg3


mov dx, offset msg3
int 21h

exit:

mov ah, 4ch


int 21h

end start
2. By Using Compare and Jump commands, have A,B,C,D,E,F,G be TRUE, while any other
character is FALSE.

● Among the TRUE characters, when the user types 'G', the program will close.
● If the character is TRUE, print "The character is correct!", should go back to initial
message.
● Among the FALSE characters, when the user types 'L' the program will close.
● If the character is FALSE, print "The character is wrong!", should go back to initial
message.

.model small
.stack
.data

msg db "Choose your character:$"


success db "Tumpak ganern! $"
fail db "Ligwak ganern! $"
goodbye db "BABOOSH! $"

.code

start:
mov ax, @data
mov ds, ax
mov ah, 02h
mov dl, 10
int 21h
mov ah, 09h
mov dx, offset msg
int 21h
mov ah, 01h
int 21h
cmp al, 'A'
JE tama
cmp al, 'B'
JE tama
cmp al, 'C'
JE tama
cmp al, 'D'
JE tama
cmp al, 'E'
JE tama
cmp al, 'F'
JE tama
cmp al, 'G'
JE tamang_tama
cmp al, 'L'
JE maling_mali

JMP mali

tama:
mov ah, 02h
mov dl, 10
int 21h
mov ah, 09h
mov dx, offset success
int 21h
mov ah, 02h
mov dl, 10
int 21h

jmp start

mali:

mov ah, 02h

mov dl, 10

int 21h
mov ah, 09h

mov dx, offset fail

int 21h

jmp start

maling_mali:

mov ah, 02h

mov dl, 10

int 21h

mov ah, 09h

mov dx, offset goodbye

int 21h

jmp exit

tamang_tama:

mov ah, 02h

mov dl, 10

int 21h

mov ah, 09h

mov dx, offset goodbye

int 21h

jmp exit

exit:

mov ah, 4ch

int 21h

end start
Submit the PDF and ASM file.

You might also like