Beruflich Dokumente
Kultur Dokumente
OBJECTIVE
To learn to write the following application codes:
1. Password protected application, used to sign-in to a computer.
2. Count the capital characters in a defined string.
3. Display the characters in a string in diagonal form.
4. Count the ‘Even’ numbers in an entered string.
1. Code 01: ‘Password protected application’, used to sign-in to a
computer.
Hints:
Initialize a 5-digit password e.g. ‘12345$’ in a db. (.data)
Use function # 8, to hide password input on run time.
Use function # 2, to display ‘*’ or ‘.’ In place of password.
Take a string at input and ‘cmp’ both strings location by location.
Two ways of termination when a wrong password is entered.
i) Any key mismatch (terminate). ii) At the end of string input
Code:
include 'emu8086.inc'
.model small
.stack 100h
.data
password db 'A$'
entered db '?'
.code
main proc
mov ax,@data
mov ds,ax
mov es,ax
1
lea si,password
lea di,entered
mov cl,4 ;limit cx=4 character password only
mov dl,0
input:
mov ah,8 ;Function # 8 hides character input at run time
int 21h
end:
mov dl,'*' ;display '*' as password input
mov ah,2
int 21h
2
login:
mov dl,'*' ;display '*' as password input
mov ah,2
int 21h
finish:
main endp
end main
True
Code:
.model small
.stack 100h
3
.data
msg db 'BDEFg$'
.code
main proc
mov ax,@data
mov ds,ax
lea si,msg
end:
loop inrange
mov ah,2
mov dl,bl
add dl,30h
int 21h
mov ah,4ch
int 21h
main endp
end main
4
3. Code 03: Display the characters in a string in diagonal form.
Flowchart:
Code:
.model small
.stack 100h
.data
msg db 'abcde$'
.code
main proc
mov ax,@data
mov ds,ax
lea si,msg
mov cx,5
label1:
mov ah,2
mov dl,[si]
int 21h
inc si
mov dl,0ah ;new line
int 21h
mov dl,‘ ‘ ;spacebar
int 21h
loop label1
main endp
end main
5
4. Code 04: Count the ‘Even’ numbers in an entered string.
.model small
.stack 100h
.data
.code
main proc
mov cl,0
even:
mov ah,1
int 21h
cmp al,0dh ;enter key
je display
cmp al,30h ;'0'
je counter
cmp al,32h ;'2'
je counter
cmp al,34h ;'4'
je counter
cmp al,36h ;'6'
je counter
cmp al,38h ;'8'
je counter
jne even
counter:
inc cl
jmp even:
display:
mov ah,2
mov dl,0ah ;new line
int 21h
mov dl,0dh
int 21h
mov ah,2
mov dl,cl
add dl,30h
int 21h
main endp end main
6
Lab 06: Logical Operations
OBJECTIVE
To learn the basic ‘logic commands’ and their use.
Command Addressing Description
Format
Logical AND between all bits of two operands.
REG, memory
Result is stored in operand1.
memory, REG
Example:
REG, REG
AND mov al,'a' ;61h=97d =01100001b
memory,
AND al,11011111b ;=223d
immediate mov ah,2
REG, immediate mov dl,al ;ASCII for 'A' is 65d=41h=01000001b
int 21h