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

Name: _____Luigie C.

Legaspi_________

Objective:

1. Familiarity on the ASM Code


2. Familiarity on the different registers
3. Generate solution using fundamental ASM code

Instruction:

“01” if loaded to the accumulator will trigger an Input event and the user input will then be passed
automatically to the lower accumulator.

MOV AH,01H ; LOADS AN INPUT SEQUENCE ( 1 INPUT ONLY )


INT 21H ; EXECUTES THE SEQUENCE ➔ AL WILL HOLD THE USER INPUT

This is just to obtain an input from the user. But we need to see what is the input of the user. So, we
followed the code with an output.

MOV AH,01H ; OBTAIN AN INPUT COMMAND


INT 21H

MOV AH,02H ; DISPLAY A CHARACTER COMMAND


MOV DL, AL ; LOADS THE INPUT (USER INPUT) FROM AL TO DL
INT 21H ; SHOW THE INPUT

The next is “08” which is also an input command without echo, means it will not show what the user
pressed from the keyboard.

MOV AH,08 ; AN INPUT WITHOUT ECHO


INT 21H ; INPUT WILL BE OBTAIN BY AL AUTOMATICALLY

For output of string here is the template.


.model small
.stack
.data
message db "Hello World!!!", "$"

.code

main proc
mov ax,seg message
mov ds,ax
mov ah,09h ; load string
lea dx, message ; obtain string using dx(DH,DL) from .data
int 21h ; execute and display

mov ax,4c00h ; End of code


int 21h

main endp ;Terminal Process


end main

PROBLEM: PERFORM A PIN NUMBER [ 4 INPUTS ONLY] VERIFICATION USING ASSEMBLY LANGUAGE.
3 ERRORS WILL DISPLAY “UNAUTHORIZE”, A CORRECT PIN WILL DISPLAY “ACCESS GRANTED”.

e.g

[ 3 ERROR]
Enter Pin : * * * *
“Error”
Enter Pin : * * *
“Error”
Enter Pin : * * * *
Enter Pin : * * *
“Error”

“UNAUTHORIZE”

[ ACCESS GRANTED ]
Enter Pin : * * * *

ACCESS GRANTED
Code:

;PIN: 1434

.model small

.stack

.data

mes db "Error.$'"

mes2 db "Access Granted. $"

mes3 db "Enter PIN: $"

mes4 db "Maximum tries reached. Please try again later.$"

.code

main proc

mov ax,@data

mov ds,ax

mov cl,03h

jmp here

error:

mov ah,02h

mov dl,0Ah

int 21h
mov ah,09h

lea dx,mes

int 21h

mov ah,02h

mov dl,0Ah

int 21h

dec cl

cmp cl,00h

je max

here:

mov ah,09h

lea dx, mes3

int 21h

mov ah,08

int 21h
mov bl,al

mov ah,02h

mov dl,2Ah

int 21h

cmp bl,31h

jne error

mov ah,08

int 21h

mov bl,al

mov ah,02h

mov dl,2Ah

int 21h

cmp bl,34h

jne error
mov ah,08

int 21h

mov bl,al

mov ah,02h

mov dl,2Ah

int 21h

cmp bl,33h

jne error

mov ah,08

int 21h

mov bl,al

mov ah,02h

mov dl,2Ah

int 21h
cmp bl,34h

jne error

je correct

max:

mov ah,09h

lea dx, mes4

int 21h

jmp exit

correct:

mov ah,02h

mov dl,0Ah

int 21h

mov ah,09h

lea dx, mes2

int 21h
exit:

mov ax,4c00h

int 21h

main endp

end main

You might also like