0% found this document useful (0 votes)
84 views3 pages

Dire Dawa Institute of Technology: Department of Electrical and Computer Engineering

The document contains 3 programs: 1. A program that prints a binary number on the console. It uses ADD, MOV, TEST, and LOOP instructions to print each bit. 2. A program that adds a profit factor to each element in a cost array and stores the results in a prices array. It uses MOV, ADD, DAA, and LOOP instructions to iterate through the arrays. 3. A login validation program that reads a 4-character password from keyboard, compares it to a stored password using CMPSB, and prints "access granted" or "access denied" based on the comparison. It uses MOV, INT, CLD, REPE, and

Uploaded by

YITBAREK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views3 pages

Dire Dawa Institute of Technology: Department of Electrical and Computer Engineering

The document contains 3 programs: 1. A program that prints a binary number on the console. It uses ADD, MOV, TEST, and LOOP instructions to print each bit. 2. A program that adds a profit factor to each element in a cost array and stores the results in a prices array. It uses MOV, ADD, DAA, and LOOP instructions to iterate through the arrays. 3. A login validation program that reads a 4-character password from keyboard, compares it to a stored password using CMPSB, and prints "access granted" or "access denied" based on the comparison. It uses MOV, INT, CLD, REPE, and

Uploaded by

YITBAREK
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Dire Dawa Institute of Technology

Department of Electrical and Computer Engineering


ECEg4161: Microcomputer and interfacing
Lab Experiment No – 5: Programs
1. Print a number in binary on the console window

MOV AL, 5

MOV BL, 10

ADD BL, AL

MOV CX, 8

PRINT: MOV AH, 2

MOV DL, ‘0’

TEST BL, 10000000B

JZ zero

MOV DL, ‘1’

zero: INT 21H

SHL BL, 1

LOOP PRINT

MOV DL, ‘B’

INT 21H

RET

2. A program that adds a profit factor to each element in a cost array and puts the result in
an prices array

PROFIT EQU 15H

ARRAYS SEGMENT

1
COST DB 20H, 28H, 15H, 26H, 19H, 27H, 16H, 29H

PRICES DB 8 DUP (0)

ARRAYS ENDS

CODE SEGMENT

ASSUME CS:CODE, DS:ARRAYS

START: MOV AX, ARRAYS

MOV DS, AX

MOV CX, 8H

MOV BX, 0

DO_ET: MOV AL, COST[BX]

ADD AL, PROFIT

DAA

MOV PRICES[BX], AL

INC BX

DEC CX

JNZ DO_ET

CODE ENDS

END

3. Consider a Login system. Suppose you have a 4 – character password stored in DS in


memory. Write a program that reads a 4 – character password string from keyboard port;
compare the string with the password in memory; prints “access granted” if correct or
“access denied” otherwise.
Use INT 21H/ AH = 1, For Input Character
Use INT21H/ AH = 9, To Display String
Use CMPSB to compare strings

Answer

pass1 DB ?,?,?,?
pass2 DB ‘1’,’2’,’3’,’4’

2
LEA BX, pass1 ;Points the address of the input password
MOV SI, BX ; keep the address of input password
MOV CX, 4
MOV AH, 1
INP:
INT 21H ;Gets the input from the keyboard
MOV [BX], AL
INC BX
LOOP INP
CLD
LEA SI, pass1 ;keep the address of input password
LEA DI, pass2 ;keep the address of saved password
MOV CX, 4
REPE CMPSB ;Compare the strings
JNZ Not_equal
MOV DX, OFFSET GRANTED
MOV AH, 9 ;Output of a string at DS: DX
INT 21H
JMP Exit_here

Not_equal:

MOV DX, OFFSET DENIED

MOV AH, 9 ;Output of a string at DS: DX

INT 21H

Exit_here: ;Final

RET

GRANTED DB 0AH, 0DH, “ACCESS GRANTED!!! $”

DENIED DB 0AH, 0DH, “ACCESS DENIED!!! $”

You might also like