Write an assembly language program to find the average of 3 numbers
Answers
Answered by
0
the average of three given numbers stored in memory.
Let’s identify variables needed for this program.
First variables will be the one which will hold the values present in the variables to be Added and it will be NUM1, NUM2 and NUM3. Other variables will be holding the Output or Result of the Average and it will be AVG So in all Four variables.
The identified variables are NUM1, NUM2, NUM3 and AVG.
First Line – DATA SEGMENT
DATA SEGMENT is the starting point of the Data Segment in a Program and DATA is the name given to this segment and SEGMENT is the keyword for defining Segments, Where we can declare our variables.
Next Line – NUM1 DB 5
NUM2 DB 9
NUM3 DB 7
AVG DB ?
We are initializing NUM1 to 5 (Blank (or Nothing after number) stands for Decimal ( By Default) ), NUM2 to 9 ((Blank (or Nothing after number) stands for Decimal ( By Default) ), NUM3 to 7 (Blank (or Nothing after number) stands for Decimal ( By Default) ), AVG to ? (?stands for blank value). Detailed explanation is given below.
Next Line – DATA ENDS
DATA ENDS is the End point of the Data Segment in a Program. We can write just ENDS But to differentiate the end of which segment it is of which we have to write the same name given to the Data Segment.
Now, Selection of data type is DB data type the numbers which we are adding will be integers so DB is sufficient.
Let’s identify variables needed for this program.
First variables will be the one which will hold the values present in the variables to be Added and it will be NUM1, NUM2 and NUM3. Other variables will be holding the Output or Result of the Average and it will be AVG So in all Four variables.
The identified variables are NUM1, NUM2, NUM3 and AVG.
First Line – DATA SEGMENT
DATA SEGMENT is the starting point of the Data Segment in a Program and DATA is the name given to this segment and SEGMENT is the keyword for defining Segments, Where we can declare our variables.
Next Line – NUM1 DB 5
NUM2 DB 9
NUM3 DB 7
AVG DB ?
We are initializing NUM1 to 5 (Blank (or Nothing after number) stands for Decimal ( By Default) ), NUM2 to 9 ((Blank (or Nothing after number) stands for Decimal ( By Default) ), NUM3 to 7 (Blank (or Nothing after number) stands for Decimal ( By Default) ), AVG to ? (?stands for blank value). Detailed explanation is given below.
Next Line – DATA ENDS
DATA ENDS is the End point of the Data Segment in a Program. We can write just ENDS But to differentiate the end of which segment it is of which we have to write the same name given to the Data Segment.
Now, Selection of data type is DB data type the numbers which we are adding will be integers so DB is sufficient.
Similar questions