Question: Why is my MASM code only outputting the first procedure? ; Description: 'This program generates a series of temperature readings ( TEMPS _ PER _
Why is my MASM code only outputting the first procedure?
; Description: 'This program generates a series of temperature readings TEMPSPERDAY readings
; per day for DAYSMEASURED days in the range of MINTEMP MAXTEMP into one array. Once
; this array is generated, the program calculates the highest and lowest temperature reading for each day,
; then calculates the average of each of these daily high and low temperatures. Everything is displayed
; wth descriptive titles.
INCLUDE Irvineinc
; insert macro definitions here
; insert constant definitions here
DAYSMEASURED ;Rows
TEMPSPERDAY ;Columns
MINTEMP EQU
MAXTEMP EQU
ARRAYSIZE EQU DAYSMEASURED TEMPSPERDAY ;Total elements days measuredtemps per day
data
; insert variable definitions here
intro BYTE "Welcome to Chaotic Temperature Statistics Programmed by Nicole",
intro BYTE "This program generates a series of temperature readings, X per day for Y days,",
intro BYTE "depending on constants, and performs some basic statistics on them: daily high and low",
intro BYTE "and average high and low temps. It then prints these results, with descriptive titles.",
dispArray BYTE "The temperature readings are as follows one row is one day:
dispHigh BYTE "The highest temperature of each day was:
dispLow BYTE "The lowest temperature of each day was:
avgHigh BYTE "The truncated average high temperature was:
avgLow BYTE "The truncated average low temperature was:
;signOff optional
tempArray DWORD ARRAYSIZE DUP ;Create a MAXSIZEelement DWORD array, leave values uninitialized
highArray DWORD DAYSMEASURED DUP ;Create a element DWORD array of the highest temperature for each day, leave values uninitialized
lowArray DWORD DAYSMEASURED DUP ;Create a element DWORD array of the lowest temperature for each day, leave values uninitialized
highAvg DWORD ;High average value, initialized to decimal
lowAvg DWORD ;Low average value, initialized to decimal
code
main PROC
CALL Randomize ;Random int access
;greeting and explanation
PUSH OFFSET intro
PUSH OFFSET intro
PUSH OFFSET intro
PUSH OFFSET intro
CALL printGreeting
;setup temp array
PUSH OFFSET tempArray
CALL generateTemperatures
;find daily highs
PUSH OFFSET tempArray
PUSH DAYSMEASURED
PUSH TEMPSPERDAY
PUSH OFFSET highArray
CALL findDailyHighs
;find daily lows
PUSH OFFSET tempArray
PUSH DAYSMEASURED
PUSH TEMPSPERDAY
PUSH OFFSET lowArray
CALL findDailyLows
;calculate high and low averages
PUSH OFFSET highArray
PUSH OFFSET lowArray
CALL calcAverageLowHighTemps
;display temps from daysrows and temps per daycolumns
PUSH OFFSET dispArray
PUSH OFFSET tempArray
PUSH DAYSMEASURED
PUSH TEMPSPERDAY
CALL displayTempArray
;display daily highs
PUSH OFFSET dispHigh
PUSH OFFSET highArray
PUSH DAYSMEASURED
PUSH
CALL displayTempArray
;display daily lows
PUSH OFFSET dispLow
PUSH OFFSET lowArray
PUSH DAYSMEASURED
PUSH
CALL displayTempArray
;display temp avgs
PUSH OFFSET avgHigh
PUSH highAvg
CALL displayTempWithString
PUSH OFFSET avgLow
PUSH lowAvg
CALL displayTempWithString
RET
Invoke ExitProcess,
main ENDP
;
;Name: printGreeting
;parameters: introreference input introreference input
;Procedure to introduce the program & programmer
;preconditions: intros are described
;postconditions: EDX changed
;receives:
;returns:
;
printGreeting PROC ;introduce programmer
PUSH EBP
MOV EBP, ESP
; EBP address of OFFSET intro
; EBP address of OFFSET intro
; EBP address of OFFSET intro
; EBP address of OFFSET intro
; EBP return address
; EBP old ebp
MOV EDX, EBP
CALL WriteString
MOV EDX, EBP
CALL WriteString
MOV EDX, EBP
CALL WriteString
MOV EDX, EBP
CALL WriteString
POP EBP
RET
printGreeting ENDP
;
;Name: generateTemperatures
;parameters: tempArray reference output
;MINTEMP, MAXTEMP, DAYSMEASURED, TEMPSPERDAY will be used as globals within this procedure.
;Randomly generate temperatures within the range and stores them in tempArray
;preconditions:
;postconditions:
;receives:
;returns: tempArray
;
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
