Question: . DATA ; Constants minTempLimit SWORD - 3 0 maxTempLimit SWORD 5 0 coldLimit SWORD 0 coolLimit SWORD 1 5 warmLimit SWORD 3 0 numReadings
DATA ; Constants minTempLimit SWORD maxTempLimit SWORD coldLimit SWORD coolLimit SWORD warmLimit SWORD numReadings SWORD ; Strings titleMsg BYTE "Temperature Analysis Program", progNameMsg BYTE "Programmed by Your NamegreetMsg BYTE "Hello, enterTempMsg BYTE "Please enter a temperature reading in Celsius to : invalidMsg BYTE "Invalid temperature! Please enter a value within the range to resultsMsg BYTE "Temperature Analysis Results:", partingMsg BYTE "Thank you for using the program, ; Variables userName BYTE DUPtotalTemp SDWORD validCount SWORD coldCount SWORD coolCount SWORD warmCount SWORD hotCount SWORD minTemp SWORD maxTemp SWORD CODE main PROC ; Program title and programmer name call Clrscr mov edx, OFFSET titleMsg call WriteString call CrLf mov edx, OFFSET progNameMsg call WriteString call CrLf ; Get user's name mov edx, OFFSET greetMsg call WriteString mov edx, OFFSET userName call ReadString call CrLf ; Display instructions mov edx, OFFSET enterTempMsg call WriteString call CrLf ; Input loop for temperature readings mov cxnumReadings mov totalTemp, mov validCount, inputloop: ; Prompt user to enter temperature mov edx, OFFSET enterTempMsg call WriteString call ReadInt ; Validate input cmp eax, minTempLimit jl invalidinput cmp eax, maxTempLimit jg invalidinput ; Valid input, process temperature add totalTemp, eax ; Accumulate total inc validCount ; Update max and min temperatures cmp eax, maxTemp jle notnewmax mov maxTemp, ax notnewmax: cmp eax, minTemp jge notnewmin mov minTemp, ax notnewmin: ; Categorize temperature cmp eax, coldLimit jl coldcategory cmp eax, coolLimit jle coolcategory cmp eax, warmLimit jle warmcategory jmp hotcategory coldcategory: inc coldCount jmp nextinput coolcategory: inc coolCount jmp nextinput warmcategory: inc warmCount jmp nextinput hotcategory: inc hotCount jmp nextinput invalidinput: mov edx, OFFSET invalidMsg call WriteString call CrLf nextinput: loop inputloop ; Calculate average round to nearest integermov eax, totalTemp cdq idiv validCount ; Divide to get the average add edx, edx ; Double remainder to check for rounding cmp edx, validCount jl skipround inc eax skipround: mov totalTemp, eax ; Store rounded average ; Display results call CrLf mov edx, OFFSET resultsMsg call WriteString call CrLf ; Output maximum, minimum, and average mov edx, OFFSET minTemp call WriteInt call CrLf mov edx, OFFSET maxTemp call WriteInt call CrLf mov edx, OFFSET totalTemp call WriteInt call CrLf ; Output category counts mov edx, OFFSET coldCount call WriteInt call CrLf mov edx, OFFSET coolCount call WriteInt call CrLf mov edx, OFFSET warmCount call WriteInt call CrLf mov edx, OFFSET hotCount call WriteInt call CrLf ; Parting message mov edx, OFFSET partingMsg call WriteString mov edx, OFFSET userName call WriteString call CrLf exit main ENDP END main
This code doesn't work because the instruction operands aren't the same size and the code needs to stay in 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
