Question

Write a program in assembly code (8088/8086) to determine the Average, Highest, Lowest grade in microprocessor...

Write a program in assembly code (8088/8086) to determine the Average, Highest, Lowest grade in microprocessor course (final grade =100) if the class has 30 students. Write the program in the emulator(8086) and show the input data and the results (Average grade- Highest grade- Lowest Grade).
Note: Suppose the grades of the 30 students.
0 1
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

Hello!

AX, BX , CX and DX are 16 bit general purpose registers.

AX is also called as accumulator. any operation like division and ultiplication the result is stored in accumulator(AX)

We can have have 8 bits by refering X with L or H like AH and AL both are 8 bit registers AX = AH + AL , where H represent Higher byte L represents lower byte.

MOV operand 1, operand 2

In this instruction first operand mush be register(AX,AL,AH,BX...) or memory location([DI],[SI]) , second operand can be immediate data or register or memory location.

Ex:

MOV AX, 0015h

MOV [4000h],12h

DB , DW are directives

Directives are used to store inforamtion in the memory

Here i have taken org 100h the program is utilising after first 2 bytes so now our 1st word starts storing at 102h offset address.

var_name db value1,value2,.......value n

Byte(8bits)

In 8086 you can store the data into memory using variables here var_name is a variable so it will allocate the 1 byte memory to the values

var_name dw value1,value2,.......value n

Word(16bits or 2 bytes)

Here var_name is a variable so it will allocate the 2 bytes memory to the all the values

var_name db ?

This creates a variable with no data assigned to it so use ? when dont have clue store which value in varaible.

NOTE: values can be number or charecters or string

VAR_NAME , var_name both are same, 8086 is not case sensitive

ADD operand 1, opearand 2

This instruction add the operand 1 and operand 2 and result stores back to the operand 1.

In this instruction operand 1 must not be immediate value but it can be a register and memory location.

Operand 2 can be any thing register or memory location or register.

Ex:

ADD Cl , 05h

ADD [SI] , 45h

ADD 78h, AX ; first operand must not be immediate value

ADD [DI],Var1 ; both operands must not be addresses

Procedures:

Procedures helps us in code reusability , its similar to functions sometimes same instructions we need to execute for different data in that situation we can use procedures

SYNTAX :

procedure_name PROC

; code

RET

procedure_name ENDP

LOWER ADDRESS BITS GOES TO LEAST SIGNIFICANT BITS.

HIGHER ADDRESS BITS GOES TO MOST SIGNIFICANT BITS.

When var dw 458Bh the data stores at lower loaction lets take DS:0100h is 8Bh and higher loaction that is DS:0101 is 45h

DIV operand

This instruction divides the value accumulator with opearndand result stores back to the Accumulator.

IF 16 bit

AX stores the Quotient

DX stores the Remainder

AX = AX / operand

IF 8 bit

AL stores the Quotient

AH stores the Remainder

AL = AL / operand

Here operand must be Register or Memory location but not immediate data.

EX:

DIV BH ; AH = AH / BH

DIV [5500h]

DIV 0Ah ; should not use immediate value

JNE main ; if zero flag is 0 then goes to main lable

JMP exit ; jumps to the exit of the code

LOGIC:

AVERAGE

  • Goes to each score add to the AX
  • Each score gets stored to BX
  • Adds AX and BX
  • finally divides with cx (number of scores)

MAX or MIn

  • assumes first score is max or min
  • from second element it compares the assumed value
  • if it is max or min then it wil upadate the max or min
  • stores the max or min

CODE:

org 100h   
 
; JUMPS O START OF MAIN PROGRAM 
JMP START

; ALL SCORES STORES IN SCORES ARRAY
SCORES DB 98d,85d,69d,50d,79d,58d,30d,80d,96d,36d,84d,56d,94d,89d,67d
; NUMBER OF SCORES IN THE ARRAY
COUNT DB 15d
; AVERAGE OF SCORES 
AVERAGE DB ?
; MAX OF SCORES
MAX DB ?
; MINIMUM OIF SCORES
MIN DB ?

START:  

; AVERAGE

MOV DI,offset SCORES     ; loads offset address to DI
MOV AX,00h               ; Makes A to 0
MOV CL,[COUNT]           ; Gets the data in count variable
L1:
MOV BX,00                ; Makes BX to 0
MOV BL,[DI]              ; moves data in the loactaion to BL
ADD AX,BX                ; Adds the scores with total scores
INC DI                   ; goes to nest scores location
LOOP L1                  ; loop continues till Cx becomes 0

MOV CL,[COUNT]           ; Gets data to CL
DIV CX                   ; Ax = AX / CX
MOV [AVERAGE],AL         ; moves the average of scores to AVerage variable

; HIGHEST

MOV DI, offset SCORES    ; gets the offset address of scores
MOV AL,[DI]              ; Assumes the first element is the max of scores
MOV CL,[COUNT]           ; gets the count to cx 
DEC CL                   ; Decrements the cl values as we need only 14 comparisons not 15 
HIGH: 
INC DI                   ; goes to next location
CMP AL,[DI]              ; compares the value in AL with next loaction data
JG SKIP                  ; If greater skips the below contidition
MOV AL,[DI]              ; Updates the AL value (max value) of scores
SKIP:                    
LOOP HIGH                ; Loops untill all 14 comparisions are completed
MOV [MAX],AL             ; Moves the maximum value of scores to MAX variable

; LOWEST  

MOV DI, offset SCORES    ; gets the offset address of scores
MOV AL,[DI]              ; Assumes the first element is the min of scores
MOV CL,[COUNT]           ; gets the count to cx 
DEC CL                   ; Decrements the cl values as we need only 14 comparisons not 15 
LOW:
INC DI                   ; goes to next location
CMP AL,[DI]              ; compares the value in AL with next loaction data
JNG SKIP0                ; If not greater skips the below contidition
MOV AL,[DI]              ; Updates the AL value (min value) of scores
SKIP0:                    
LOOP LOW                 ; Loops untill all 14 comparisions are completed

MOV [MIN],AL             ; Moves the minimum value of scores to MIN variable

HLT

    




emu8086 - assembler and microprocessor emulator 4.08 file edit bookmarks assembler emulator math ascii codes help ? E new ope

emu8086 - assembler and microprocessor emulator 4.08 file edit bookmarks assembler emulator math ascii codes help ? help E ab

OUTPUT:

2 3 en AL, MIN HIG em 65 n e variables X ate original source co... X but GHES 52 MOU DI, offset SCORES size: byte elements: 1

Hope this helps and clear.

Please feel free to comment if you have any doubts . If you face any difficulty please let me know i will help you with in few minutes.

I strive to provide the best of my knowledge so please upvote if you like the content.

Thank you!

Add a comment
Know the answer?
Add Answer to:
Write a program in assembly code (8088/8086) to determine the Average, Highest, Lowest grade in microprocessor...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name...

    PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name it MinMaxAvg) to determine the highest grade, lowest grade, and the average of all grades in a 4-by-4 two-dimensional arrays of integer grades (representing 4 students’ grades on 4 tests). The program main method populates the array (name it Grades) with random grades between 0 and 100 and then displays the grades as shown below. The main method then calls method minMaxAvg()that takes a...

  • Write a program that prompts the user for student grades and displays the highest and lowest grades in the class.

    Write a program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values.example Enter as many student grades as you like. Enter a character to stop. The highest grade is: 92.0 The lowest grade is: 10.65# in java

  • Write a JAVA program that prompts the user for student grades and displays the highest and...

    Write a JAVA program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values. Starter code: import java.util.Scanner; public class MaxMinGrades{   public static void main(String[] args){     Scanner input = new Scanner(System.in);     System.out.println("Enter as many student grades as you like. Enter a character to stop.");     double grade = input.nextDouble();     double minGrade = Double.MAX_VALUE;     double maxGrade = Double.MIN_VALUE;     while (Character.isDigit(grade)) {       if (grade == 0)...

  • . Write an 8086 assembly language program to find the prime numbers among 100 bytes of...

    . Write an 8086 assembly language program to find the prime numbers among 100 bytes of data in an array stored from the address 4000H: 1000H in the data segment and store the result from the address 4000H: 3000H. write the code using 8086 assembly language only i do not want any other language If you Do not sure please do not solve it

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Help me write the program in C++ Thanks Program #1: Calculate a student's grade for a...

    Help me write the program in C++ Thanks Program #1: Calculate a student's grade for a class. The class has 4 categories of grades. Each category has different weights. The student's report should include the student's first and last name; course; semester, category listing with weight for each category, grades for each category and the student's final average with a letter grade. Categories with weights: 1. Exams: 30%(3 @ 10% each) 2. Labs: 30% (3 labs @ 10% cach) 3....

  • C++ Write a program to calculate final grade in this class, for the scores given below...

    C++ Write a program to calculate final grade in this class, for the scores given below . Remember to exclude one lowest quiz score out of the 4 while initializing the array. Display final numeric score and letter grade. Use standard include <iostream> Implementation: Use arrays for quizzes, labs, projects and exams. Follow Sample Output for formatting. May use initialization lists for arrays. Weight distribution is as follows: Labs: 15% Projects: 20% Quizzes: 20% Exams: 25% Final Project: 20% Display...

  • Write a program to calculate your final grade in this class. Three(8) assignments have yet to...

    Write a program to calculate your final grade in this class. Three(8) assignments have yet to be graded: Quiz 7, Lab 7 and Final Project. Assume ungraded items receive a grade of 100 points. Remember to drop the lowest two quiz scores. Display final numeric score and letter grade. Implementation: Weight distribution is listed in canvas. Use arrays for quizzes, labs, projects and exams. You are allowed to use initialization lists for arrays. Use at least three (3) programmer defined...

  •   -You are going to write a program to help me determine the final grade and...

      -You are going to write a program to help me determine the final grade and calculate some summary stats. The steps are described below: 1. First, create a dictionary of 10 students with student name as key and score as value. •For simplicity, name students as student 1, student 2, etc. Scores are random integers from 0-100 2. Calculate the average score in the class 3. Determine the letter grade based on the following scheme :•A if score >=...

  • Write a C++ program. Using the while loop or the do – while loop write a...

    Write a C++ program. Using the while loop or the do – while loop write a program that does the following: Calculate the average of a series of homework grades (0 - 100) entered one at a time. In this case the lowest score will be dropped and the average computed with the remaining grades. For example suppose you enter the following grades: 78, 85, 81, 90, 88, 93 and 97.The average will be computed from the 6 grades 85,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT