Lab 5 Practice Test 23blc1259
Lab 5 Practice Test 23blc1259
Submitted By
23BLC1259 – Ithihas Thiruvenkata Durai
Submitted To
Dr. Abraham Sudharson Ponraj
Date: 04/02/2025
3. Store the maximum value in the extra segment at the specified location.
Instructions required:
MOV: To move data between registers and memory.
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
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.
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.
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
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.
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
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.