0% found this document useful (0 votes)
14 views

Lab 5 Practice Test 23blc1259

The document outlines lab tasks for a Microprocessors and Microcontrollers course, detailing three specific lab exercises. Each task includes an aim, procedure, required instructions, a program in assembly language, input and output specifications, and the inference and result of the task. The tasks involve finding the maximum goals scored by players, calculating quiz scores and averages, and checking if a number is prime.
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)
14 views

Lab 5 Practice Test 23blc1259

The document outlines lab tasks for a Microprocessors and Microcontrollers course, detailing three specific lab exercises. Each task includes an aim, procedure, required instructions, a program in assembly language, input and output specifications, and the inference and result of the task. The tasks involve finding the maximum goals scored by players, calculating quiz scores and averages, and checking if a number is prime.
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/ 8

School of Electronics Engineering (SENSE)

BECE204P – MICROPROCESSORS AND


MICROCONTROLLERS
LAB RECORD
(L21+L22)

Submitted By
23BLC1259 – Ithihas Thiruvenkata Durai

Submitted To
Dr. Abraham Sudharson Ponraj
Date: 04/02/2025

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 1


LAB – 05: Practice test

LABTASK-1: Maximum Goals Scored by Top Goal Scorers


AIM:
To find the maximum number of goals scored by the top goal scorers in a team of
15 players and store the result in the extra segment at a specified location.
Procedure:
1. Initialize the data segment with the number of goals scored by each player.

2. Iterate through the list of goals to find the maximum value.

3. Store the maximum value in the extra segment at the specified location.

Instructions required:
 MOV: To move data between registers and memory.

 CMP: To compare values.

 JBE: To jump if the value is below or equal.

 INC: To increment a value.

 LOOP: To repeat a block of instructions.

 DIV: To perform division (not used in this task).

Program:
.MODEL SMALL
.STACK 100H
.DATA
goals DB 22, 15, 10, 18, 20, 12, 14, 16, 19, 21, 13, 17, 11, 9, 8 ; Example data
max_goals DB 0
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV CX, 15 ; Number of players
LEA SI, goals ; Load address of goals array
MOV AL, [SI] ; Load first player's goals
MOV max_goals, AL ; Assume first player has max goals
INC SI ; Move to next player
DEC CX ; Decrement counter
FIND_MAX:
MOV AL, [SI] ; Load next player's goals

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 2


CMP AL, max_goals ; Compare with current max
JBE NEXT ; If not greater, skip
MOV max_goals, AL ; Update max_goals
NEXT:
INC SI ; Move to next player
LOOP FIND_MAX ; Repeat for all players
MOV AX, @EXTRA ; Load extra segment
MOV ES, AX
MOV DI, 15H ; Store result at 15%RH
MOV AL, max_goals
MOV ES:[DI], AL ; Store max_goals in extra segment
MOV AH, 4CH ; Exit program
INT 21H
MAIN ENDP
END MAIN
Input & Output:

INPUT:
 An array of 15 bytes representing the number of goals scored by each player,
stored in the data segment starting at location 1100H.

[22, 15, 10, 18, 20, 12, 14, 16, 19, 21, 13, 17, 11, 9, 8 ]

OUTPUT:
 The maximum number of goals scored, stored in the extra segment at location
15%RH.

22
INFERENCE:
 The program successfully identifies the player with the highest number of
goals by comparing each player's goals and updating the maximum value.

RESULT:
 The maximum number of goals scored by a player is stored in the extra
segment at the specified location.

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 3


LABTASK-2: Digital Quiz with Negative Marking
AIM:
To calculate the number of students with positive marks and the class average for a
quiz conducted for 30 students, where marks are stored in the data segment.
Procedure:
1. Initialize the data segment with the marks of 30 students.

2. Iterate through the marks to count the number of positive marks and calculate
the total sum of marks.

3. Compute the class average by dividing the total sum by the number of
students.

Instructions required:
 MOV: To move data between registers and memory.

 CMP: To compare values.

 JLE: To jump if the value is less than or equal.

 ADD: To add values.

 DIV: To perform division.

 INC: To increment a value.

Program:
.MODEL SMALL
.STACK 100H
.DATA
marks DW 30 DUP(?) ; Example marks for 30 students
positive_count DW 0
total_marks DW 0
average DW 0
.CODE
MAIN PROC

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 4


MOV AX, @DATA
MOV DS, AX
MOV CX, 30 ; Number of students
LEA SI, marks ; Load address of marks array
MOV positive_count, 0
MOV total_marks, 0
PROCESS_MARKS:
MOV AX, [SI] ; Load student's mark
CMP AX, 0 ; Check if mark is positive
JLE NEXT_STUDENT ; If not, skip
INC positive_count ; Increment positive_count
ADD total_marks, AX ; Add to total_marks
NEXT_STUDENT:
ADD SI, 2 ; Move to next student's mark
LOOP PROCESS_MARKS ; Repeat for all students
MOV AX, total_marks
MOV BX, 30 ; Number of students
DIV BX ; Calculate average
MOV average, AX ; Store average
MOV AH, 4CH ; Exit program
INT 21H
MAIN ENDP
END MAIN
Input & Output:

INPUT:
 An array of 30 words (16-bit) representing the marks of each student, stored in
the data segment starting at location 2000H.

OUTPUT:
 The number of students with positive marks.
 The class average of the quiz marks.

INFERENCE:
 The program processes the marks of all students, identifies positive marks,
and calculates the class average.

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 5


RESULT:
 The number of students with positive marks and the class average are
computed and stored.

LABTASK-3: Check if a Given Number is Prime


AIM:
To determine whether a given number is a prime number or not.
Procedure:
1. Initialize the number to be checked.
2. Check divisibility of the number by all integers from 2 to the number itself.
3. If the number is divisible by any integer other than 1 and itself, it is not a
prime number.
4. If no divisors are found, the number is prime. .

Instructions required:
 MOV: To move data between registers and memory.
 CMP: To compare values.
 JE: To jump if equal.
 JAE: To jump if above or equal.
 DIV: To perform division.
 INC: To increment a value.

Program:
.MODEL SMALL
.STACK 100H
.DATA
number DW 29 ; Example number to check
is_prime DB 1 ; Assume number is prime initially
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
MOV CX, 2 ; Start divisor from 2
MOV AX, number ; Load number

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 6


CHECK_PRIME:
CMP CX, AX ; Compare divisor with number
JAE PRIME ; If divisor >= number, it's prime
MOV DX, 0 ; Clear DX for division
DIV CX ; Divide number by CX
CMP DX, 0 ; Check remainder
JE NOT_PRIME ; If remainder is 0, not prime
INC CX ; Increment divisor
MOV AX, number ; Reload number
JMP CHECK_PRIME ; Repeat
NOT_PRIME:
MOV is_prime, 0 ; Set is_prime to 0
PRIME:
MOV AH, 4CH ; Exit program
INT 21H
MAIN ENDP
END MAIN
Input & Output:

INPUT:
 A 16-bit number stored in the data segment.

OUTPUT:
 A flag (is_prime) indicating whether the number is prime (1) or not (0).

INFERENCE:
 The program checks the divisibility of the number and determines if it is
prime.

RESULT:
 The program sets the is_prime flag to 1 if the number is prime, otherwise sets it
to 0.

[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 7


[21BEC1001] BECE204P- Microprocessors and Microcontrollers Lab Page No: 8

You might also like