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 -30maxTempLimit SWORD 50coldLimit SWORD 0coolLimit SWORD 15warmLimit SWORD 30numReadings SWORD 7; Strings titleMsg BYTE "Temperature Analysis Program", 0progNameMsg BYTE "Programmed by [Your Name]",0greetMsg BYTE "Hello, ",0enterTempMsg BYTE "Please enter a temperature reading in Celsius (-30to 50): ",0invalidMsg BYTE "Invalid temperature! Please enter a value within the range -30to 50.",0resultsMsg BYTE "Temperature Analysis Results:", 0partingMsg BYTE "Thank you for using the program, ",0; Variables userName BYTE 50DUP(0)totalTemp SDWORD 0validCount SWORD 0coldCount SWORD 0coolCount SWORD 0warmCount SWORD 0hotCount SWORD 0minTemp SWORD 32767maxTemp SWORD -32768.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 7temperature readings mov cx,numReadings mov totalTemp, 0mov validCount, 0input_loop: ; Prompt user to enter temperature mov edx, OFFSET enterTempMsg call WriteString call ReadInt ; Validate input cmp eax, minTempLimit jl invalid_input cmp eax, maxTempLimit jg invalid_input ; Valid input, process temperature add totalTemp, eax ; Accumulate total inc validCount ; Update max and min temperatures cmp eax, maxTemp jle not_new_max mov maxTemp, ax not_new_max: cmp eax, minTemp jge not_new_min mov minTemp, ax not_new_min: ; Categorize temperature cmp eax, coldLimit jl cold_category cmp eax, coolLimit jle cool_category cmp eax, warmLimit jle warm_category jmp hot_category cold_category: inc coldCount jmp next_input cool_category: inc coolCount jmp next_input warm_category: inc warmCount jmp next_input hot_category: inc hotCount jmp next_input invalid_input: mov edx, OFFSET invalidMsg call WriteString call CrLf next_input: loop input_loop ; Calculate average (round to nearest integer)mov eax, totalTemp cdq idiv validCount ; Divide to get the average add edx, edx ; Double remainder to check for rounding cmp edx, validCount jl skip_round inc eax skip_round: 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 irvine32.inc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!