Mic 11
Mic 11
(Year: 2023-2024)
Micro Project
Course: MICROPROCESSOR
______________________________________________
Mahavir Polytechnic
1
Vision
We strive to educate students to become industry ready engineers having professional attitude and
groomed personality.
Mission
· To provide well defined system to ensure quality education by strengthening teaching learning
processes through innovative practices
· To provide a platform where students are exposed to the industry, up bridged with the industry
standards and requirements.
Vision
Computer Engineering Department strives to educate students to become Industry ready Engineers
having Professional attitude and groomed personality.
Mission
. To provides well defined system to ensure quality education by strengthening teaching learning
processes through innovative practices.
. To provides a platform where students are exposed to the industry, up bridged with the industry
standards and requirements.
2
PART A
In this Microproject we are going to accept occurrence of user character. This will help to find
occurrences of user character from the given string.
1.To get the knowledge about microprocessor and assembly language.
2.To Understand the concept of given problem statement.
3.To develop a program to find the number of occurrences of a letter in the given string.
4 Develop assembly language program using macro and modular programming approach.
Name Of
Sr. No Specifications Quantity Remarks
Resource/Material
1
SOFTWARE I5 11gen -
2
SOURCE OF INFORMATION Google, Chat GPT -
For this assembly language application, literature evaluations would examine effective
character search algorithms and optimization strategies. They would draw attention to the value of
For this assembly language application, literature evaluations would examine effective
character search algorithms and optimization strategies. They would draw attention to the value of
The methodology of the provided assembly language code involves prompting the user to
input a string and a character to search for. It then iterates through the input string character by
character, comparing each character with the target character. As each match is found, a counter is
incremented to keep track of the number of occurrences. Finally, the program displays the total count
of occurrences of the target character in the input string. This methodology demonstrates
5
fundamental string manipulation and control flow techniques in assembly language programming.
Name Of
Sr. No Specifications Quantity Remarks
Resource/Material
1
SOFTWARE I5 11gen 8gb Ram 1
2
SOURCE OF INFORMATION Google, Chat GPT 1
6
Understanding System Calls: Utilizing system calls to interact with the operating system for
input/output operations demonstrates practical understanding of system-level programming
concepts.
Project Management: Managing a micro-project involves planning, coding, testing, and refining the
solution. It provides experience in project management within a small scope, fostering organizational
skills and time management.
Communication of Technical Concepts: Explaining the functionality and design choices of the micro-
project to others promotes the ability to articulate technical concepts clearly and concisely, an
essential skill in any technical field.
7
Character Occurrence Counter in Assembly Language
DATA SEGMENT
The DATA SEGMENT section defines the data segment of the program.
MSG1, MSG2, MSG3, MSG4, and MSG5 are strings used for displaying messages to the user.
CHAR is a single-byte variable used to store the character entered by the user.
COUNT is a single-byte variable used to store the count of occurrences of the specified
character in the string.
P1, M1, L1, and P11 are various labels and variables used within the program.
DISPLAY OUTPUT:
8
DISPLAY is a macro used to display messages to the user. It takes the message as a parameter and
displays it using DOS interrupt INT 21H.
CODE SEGMENT:
The CODE SEGMENT section defines the code segment of the program.
ASSUME CS: CODE, DS:DATA directive is used to specify assumptions about the segment
registers.
START is the entry point of the program. It initializes the data segment.
DISPLAY MESSAGE:
9
INT 21H, AH=0AH is used to read a string from the user and store it at the specified address
(P1).
The user-entered character is read using INT 21H, AH=1 and stored in the CHAR variable.
CHECKING CONDITIONS:
The program then iterates through the entered string using a loop.
Each character of the string is compared with the entered character (CHAR).
If a match is found, the COUNT variable is incremented.
After processing the entire string, the program checks if any occurrences were found.
10
If occurrences are found, it displays a message with the count (MSG5), else it displays a
message indicating no occurrences were found (MSG4).
Finally, the program exits.
Main Code:
DATA SEGMENT
CHAR DB?
COUNT DB 0
P1 LABEL BYTE
M1 DB 0FFH
L1 DB?
DATA ENDS
MOV AH,9
INT 21H
ENDM
CODE SEGMENT
MOV DS, AX
DISPLAY MSG1
LEA DX, P1
MOV AH,0AH
INT 21H
DISPLAY MSG2
MOV AH,1
INT 21H
MOV CHAR, AL
DISPLAY MSG3
MOV CL, L1
MOV CH,0
CHECK:
JE END_CHECK
JNE NOT_FOUND
12
INC COUNT
NOT_FOUND:
INC SI
LOOP CHECK
END_CHECK:
CMP COUNT,0
JNE CHAR_FOUND
DISPLAY MSG4
JMP EXIT
CHAR_FOUND:
DISPLAY MSG5
ADD DL,30H
MOV AH,2
INT 21H
EXIT:
MOV AH,4CH
INT 21H
CODE ENDS
END START
13
**Introduction**
The given assembly code is designed to work on the Intel 8086 microprocessor architecture and is intended
to be executed in the MS-DOS environment. The program's primary objective is to count the occurrences of
a specific character within a user-provided string. It accomplishes this task by prompting the user to input a
string and a character, then searching the string for the specified character and displaying the count of
occurrences.
**Code Structure**
The code is divided into two main segments: the data segment and the code segment.
**Data Segment**
The data segment is responsible for defining and storing various variables, strings, and constants used
throughout the program. Here's a breakdown of the data segment:
1. `MSG1` to `MSG5`: These are predefined strings used for displaying prompts and messages to the user.
2. `CHAR`: A byte variable used to store the character entered by the user.
3. `COUNT`: A byte variable used to keep track of the number of occurrences of the specified character in
the user-provided string.
4. `P1`: A label representing the memory location where the user-entered string will be stored.
5. `M1`: A constant value of `0FFH` (255 in decimal), which is typically used as a sentinel value or a
placeholder.
6. `L1`: A byte variable used to store the length of the user-entered string.
7. `P11`: A buffer (an array of bytes) used to store the user-entered string, terminated by the '$' character.
**Code Segment**
14
The code segment contains the actual assembly instructions that perform the desired operations. Here's a
breakdown of the code segment:
1. The program starts by initializing the data segment register (`DS`) with the appropriate segment address.
2. The `DISPLAY` macro is defined, which encapsulates the code for displaying a string to the console using
the DOS interrupt `21H` with the function code `09H` (display string).
3. The program prompts the user to enter a string using the `MSG1` string and reads the user input into the
`P1` memory location using the DOS interrupt `21H` with the function code `0AH` (buffered input).
4. The program prompts the user to enter a character using the `MSG2` string and reads the character into
the `CHAR` variable using the DOS interrupt `21H` with the function code `01H` (character input).
5. The program initializes the `SI` register with the address of `P11` (the buffer containing the user-entered
string) and loads the length of the string into the `CL` register.
6. The `CHECK` loop begins, which iterates over each character in the user-entered string:
- The current character is loaded into the `AL` register.
- If the character is the '$' (end of string marker), the loop jumps to the `END_CHECK` label.
- If the character matches the user-entered character stored in `CHAR`, the `COUNT` variable is
incremented.
- The `SI` register is incremented to move to the next character in the string.
- The loop counter (`CL`) is decreased, and the loop continues if `CL` is not zero.
7. After the loop ends, the program checks the value of `COUNT`:
- If `COUNT` is zero, it means the specified character was not found in the string, so the program displays
the `MSG4` string ("NO CHARACTER FOUND IN THE GIVEN STRING").
- If `COUNT` is non-zero, it means the character was found in the string, so the program displays the
`MSG5` string ("CHARACTER(S) FOUND IN THE GIVEN STRING") and the count of occurrences by converting
the value of `COUNT` to its ASCII representation and displaying it.
8. Finally, the program exits by invoking the DOS interrupt `21H` with the function code `4CH` (terminate
program).
**Program Flow**
**Input/Output Operations**
The program utilizes various DOS interrupt services to perform input/output operations:
- `INT 21H` with function code `09H` is used to display strings to the console.
- `INT 21H` with function code `0AH` is used to read a string from the user input.
- `INT 21H` with function code `01H` is used to read a single character from the user input.
- `INT 21H` with function code `4CH` is used to terminate the program.
These interrupt services were part of the MS-DOS operating system and provided a standardized way for
assembly language programs to interact with the console and perform input/output operations.
**String Manipulation**
16
- Utilizing loop constructs (`LOOP` instruction) to iterate over the characters in the string.
These techniques are fundamental in assembly language programming for string manipulation and
processing.
**Character Comparison**
The program performs character comparison to determine if the current character in the string matches the
user-entered character. This is achieved using the `CMP` instruction, which compares the values in the `AL`
register (containing the current character from the string) and the `CHAR` variable (containing the user-
entered character). Based on the result of this comparison, the program either increments the `COUNT`
variable or moves to the next character in the string.
**Counting Occurrences**
The `COUNT` variable is used to keep track of the number of occurrences of the specified character in the
user-entered string. Whenever a match is found between the current character and the user-entered
character, the `COUNT` variable is incremented using the `INC` instruction. After the loop completes, the
final value of `COUNT` represents the total count of occurrences.
**Output Display**
The program uses predefined strings (`MSG4` and `MSG5`) to display messages to the user, indicating
whether the specified character was found in the string or not. If the character was found, the program
displays the count of occurrences by converting the value of `COUNT` to its ASCII representation using the
`ADD` instruction (`DL` register + `30H`) and displaying it using the DOS interrupt `21H` with the function
code `02H` (display character).
17