0% found this document useful (0 votes)
24 views17 pages

Course Code - CSE-3102

Uploaded by

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

Course Code - CSE-3102

Uploaded by

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

Course Code : CSE-3102

Course Title: Microprocessor and Microcontroller Lab


Section: 03
Semester: Fall 2024

Submitted To:
Shakib Mahmud Dipto
Lecturer
Department of Computer Science and Engineering (CSE)

Submitted By:
Saiful Islam (223014193)
Problem 1: The problem is to take a character input from the user input and generate a
lowercase of the character.

CODE:
.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH
LF EQU 0AH
MSG1 DB 'Enter a character: $'
MSG2 DB 0DH, 0AH, 'The lowercase character is: $'
CHAR DB ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV AH, 9
LEA DX, MSG1
INT 21H
MOV AH, 1
INT 21H
MOV CHAR, AL
CMP CHAR, 'A'
JB not_uppercase
CMP CHAR, 'Z'
JA not_uppercase
ADD CHAR, 32
not_uppercase:
MOV AH, 9
LEA DX, MSG2
INT 21H
MOV AH, 2
MOV DL, CHAR
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN

OUTPUT:
DISCUSSION:
This program, reads upper case letter input from user and then converts upper class to lower case
letter. Initially, it shows a message to the user prompting "Enter a character." The program
compares the input character with ASCII values of A and Z to check whether it is an uppercase
letter or not. If the character falls within the range of an uppercase, it adds 32 to the ASCII value
to make it its lowercase equivalent. Here the user enters A, then the program adds 32 to its
ASCII value so it gets a, and then it prints the lowercase character is: and enters the character. If
the character is a lowercase, or not an uppercase letter, then nothing will be converted of that so
it is displayed as is. This simple program shows a very basic example of how input and output is
handled in assembly language and it also shows how we can check for a condition and then use
arithmetical operations to increment the character values.

Problem 2: Write a program to take a letter in lower case and show it in upper case.
CODE:

.MODEL SMALL
.STACK 100H
.DATA
CR EQU 0DH
LF EQU 0AH
MSG1 DB 'ENTER A LOWER CASE LETTER $'
MSG2 DB 0DH,0AH, 'IN UPPER CASE ITS IS: '
CHAR DB ?,'$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL, 20H
MOV CHAR, AL
LEA DX,MSG2
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN

OUTPUT:
DISCUSSION:
This program, reads upper case letter input from user and then converts upper class to
lower case letter. Initially, it shows a message to the user prompting "Enter a character."
The program compares the input character with ASCII values of a and z to check whether
it is an lowercase letter or not. If the character falls within the range of an lowercase, it
subtracts 32 to the ASCII value to make it its uppercase equivalent. Here the user enters
v, then the program subtracts 32 to its ASCII value so it gets V, and then it prints the
uppercase character is: and enters the character. If the character is a uppercase, or not an
lowercase letter, then nothing will be converted of that so it is displayed as is. This simple
program shows a very basic example of how input and output is handled in assembly
language and it also shows how we can check for a condition and then use arithmetical
operations to increment the character values.

Problem 3: Write a program to print the first letter of your first name.
CODE:

.model small
.stack 100h
.data
buffer db 50h dup('$') ; buffer to store user input
msg db 'Enter your name: $'
nameMsg db ' Your name is: $'
firstLetterMsg db 'The first letter of your name is: $'
.code
main proc
mov ax, @data
mov ds, ax
lea dx, msg
mov ah, 9
int 21h
lea dx, buffer
mov ah, 0Ah
int 21h
lea dx, nameMsg
mov ah, 9
int 21h
lea dx, buffer + 2
mov ah, 9
int 21h
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
mov ah, 2
int 21h
lea dx, firstLetterMsg
mov ah, 9
int 21h
mov dl, buffer + 2
mov ah, 2
int 21h
mov ah, 4Ch
int 21h
main endp
end main

OUTPUT:
DISCUSSION:
This Assembly code asks the user for their name, displays the full name and then only the first
letter of the name. It uses the. MODEL SMALL starts a small memory model and defines a stack
of 100h bytes. The DATA section outlines critical program features such as customs messages to
prompt and display information, as well as a buffer to eventually store the user name.

First, the program has to configure the data segment, so all references to data will be correct.
Using INT 21H with an AH=9, it prints the prompt "Enter your name:" on screen. Then the
program sleeps until the user enters their name after showing this prompt. It works with INT
21H, AH=0Ah, that reads a string in the buffer Note that in this arrangement, the length of the
string is stored in the first byte of buffer and the actual name characters will proceeds in the third
byte (buffer + 2), which is significant while accessing the input.

After storing the name inside the buffer, the program prints out the text Your name is: and prints
out the name stored by calling the name from the buffer from the third byte on (buffer + 2). In
order to display only the first letter, the program reads the first character of the name directly
from buffer + 2. Then it will print The first letter of your name is: and print that single character
using INT 21H, AH=2 (the character is in DL).

The following program demonstrates basic user interaction in Assembly, allowing you to read
input and write output. It shows how to use interrupts to print text and get user input, so it is
another good example of how to work with strings and characters in Assembly. Some people do
this kind of programming for its own sake, in order to learn low-level text processing; this skill is
useful for other programming endeavors as it reveals how the accessories are interfacing between
a very primitive computer input and either display or storage.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy