Question: . data ; Declare constants DAYS _ MEASURED equ 1 4 ; Number of days measured TEMPS _ PER _ DAY equ 1 1 ;
data ; Declare constants DAYSMEASURED equ ; Number of days measured TEMPSPERDAY equ ; Number of temperatures per day MINTEMP equ ; Minimum temperature MAXTEMP equ ; Maximum temperature ARRAYSIZE equ DAYSMEASURED TEMPSPERDAY ; Total number of temperatures ; Declare arrays tempArray db ARRAYSIZE dup ; Store all temperature readings highTemps db DAYSMEASURED dup ; Store daily high temperatures lowTemps db DAYSMEASURED dup ; Store daily low temperatures highAvg dw ; Average high temperature lowAvg dw ; Average low temperature ; Declare messages msgIntro db "Temperature Data Program Generated by YourName", msgTemperature db "Temperature Readings for Each Day:", msgHighTemps db "Daily High Temperatures:", msgLowTemps db "Daily Low Temperatures:", msgHighAvg db "Average High Temperature:", msgLowAvg db "Average Low Temperature:", code main: ; Initialize the data segment mov ax @data mov ds ax ; Display intro message lea dx msgIntro mov ahh int h ; Seed the random number generator call Randomize ; Generate the temperature data lea di tempArray mov cx DAYSMEASURED generatedata: push cx mov bx TEMPSPERDAY mov si generatedaydata: call RandomRange mov di al inc di inc si loop generatedaydata pop cx loop generatedata ; Find the high and low temps for each day lea di tempArray lea si highTemps lea bx lowTemps mov cx DAYSMEASURED processdays: push cx mov ax ; Reset high temp for the day mov bx ; Set low temp for the day to the highest possible value mov dx TEMPSPERDAY processtemps: mov aldi cmp al ax jg updatehigh cmp al bx jl updatelow jmp nexttemp updatehigh: mov ax al jmp nexttemp updatelow: mov bx al nexttemp: inc di loop processtemps mov si ax ; Store high temp mov bx bx ; Store low temp inc si inc bx pop cx loop processdays ; Calculate the average high and low temperatures lea si highTemps lea bx lowTemps xor ax ax ; Clear sum for high temps xor dx dx ; Clear sum for low temps mov cx DAYSMEASURED calculateaverages: add axsi ; Add high temp to sum add dxbx ; Add low temp to sum inc si inc bx loop calculateaverages ; Truncate the averages mov bx DAYSMEASURED div bx ; Divide sum of high temps by DAYSMEASURED mov highAvg, ax ; Store average of highs mov lowAvg, dx ; Store average of lows ; Display the temperature data lea dx msgTemperature mov ahh int h lea di tempArray mov cx DAYSMEASURED call displaydaydata ; Display daily high temperatures lea dx msgHighTemps mov ahh int h lea di highTemps call displaydaydata ; Display daily low temperatures lea dx msgLowTemps mov ahh int h lea di lowTemps call displaydaydata ; Display the average high and low temperatures lea dx msgHighAvg mov ahh int h mov ax highAvg call displaynumber lea dx msgLowAvg mov ahh int h mov ax lowAvg call displaynumber ; Exit program mov ahCh int h RandomRange proc ; Generate a random number in the range MINTEMP, MAXTEMP ; The logic for generating the random number can be implemented here using DOS interrupt for randomness ; For simplicity, returning a number between MINTEMP and MAXTEMP inclusive mov al MINTEMP randVal mod MAXTEMP MINTEMP ret RandomRange endp displaydaydata proc push cx mov cx TEMPSPERDAY displaytemploop: mov aldi call displaynumber inc di loop displaytemploop pop cx ret displaydaydata endp displaynumber proc ; Display a number mov ahh add ax int h ret displaynumber endp use only irvineinc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
