Question
Assembly language 32 program CS271 I am getting the errors... I am not sure how to fix these errors. The code I have is posted
Assembly language 32 program CS271
I am getting the errors...
I am not sure how to fix these errors. The code I have is posted below. And here are the requirements
INCLUDE Irvine32.inc
; declare the constant values
; for max, min, and colunm limits.
MAX_LIMIT EQU 300
MIN_LIMIT EQU 1
COL_LIMIT EQU 10
.data;
;declare the variables of byte type
EclidIntro BYTE "Composite Numbers "
BYTE "Programmed by Euclid", 0
Prompt1 BYTE "Enter the number of composite numbers you would like "
BYTE "to see.", 10, 13
BYTE "I will accept orders for up to 300 composites.", 0
promptNum BYTE "Enter the number of composites to display "
BYTE "[1 ... 300]: ", 0
errorMsg BYTE "Out of range. Try again.", 0
spaces BYTE " ", 9, 0
endMsg BYTE "Results certified by Euclid. Goodbye.", 0
;declare the variables of dword type
userInput DWORD ?
count DWORD ?
presentValue DWORD ?
tempFactor DWORD ?
maxFactor DWORD ?
.code
;main procedure
main PROC
call introduction ;call the procedure introduction
call getUserData ;call the procedure getUserData
call showComposites ;call the procedure showComposites
call farewell ;call the procedure farewell
exit
main ENDP
;-----------------------------------------------------------
; Procedure introduction displays the program introdcution.
; and return.
;-----------------------------------------------------------
introduction PROC
; display the value of variable EclidIntro
mov edx, OFFSET EclidIntro
call WriteString
call Crlf
call Crlf
; display the value of variable Prompt1
mov edx, OFFSET Prompt1
call WriteString
call Crlf
call Crlf
ret
introduction ENDP
;-----------------------------------------------------------
; Procedure getUserData prompts and read the input from
; the user and calls the sub procedure validate and return.
;-----------------------------------------------------------
getUserData PROC
; prompt and read the input from the user
mov edx, OFFSET promptNum
call WriteString
call ReadInt
; store the value in userInput
mov userInput, eax
;call the procedure validate
;to validate the input
call validate
ret
getUserData ENDP
;------------------------------------------------------
; Procedure validate validates the user input.
; Checks whether is in between the max and min limits.
; If not, its an error message and return.
;------------------------------------------------------
validate PROC
mov eax, userInput ;move the value into eax
cmp eax, MIN_LIMIT ; compare the value with MIN_LIMIT
jl printErrorMsg ; if value
cmp eax, MAX_LIMIT ; compare the value with MAX_LIMIT
jg printErrorMsg ; if value>MAX_LIMIT, call printErrorMsg
jmp inputValid ; if value >= 1 &
; this print the error message string
; and call the procedure getUserData
printErrorMsg:
mov edx, OFFSET errorMsg
call WriteString
call Crlf
call getUserData
;This return when input is valid
inputValid:
ret
validate ENDP
;--------------------------------------------------------
; Procedure showComposites calculates composite numbers.
; Calls isComposite to calculates composite numbers.
; Displays 10 composite numbers per row.
;--------------------------------------------------------
showComposites PROC
mov ecx, userInput ;move the value into eax
mov presentValue, 4 ;assign 4 for presentValue
mov count, 1 ;assign 1 for count
; iterate a loop
whileLoop:
call isComposite ; call the procedure isComposite
;prints the decimval value with spaces
printNum:
mov eax, presentValue
call WriteDec
mov edx, OFFSET spaces
call WriteString
inc presentValue
cmp count, COL_LIMIT ;if count>COL_LIMIT jump to nextRow
jge nextRow
inc count ;increment the count value
jmp continueLoop
; set the count to 1
nextRow:
call Crlf
mov count, 1
; call the whileLoop
continueLoop:
loop whileLoop
ret
showComposites ENDP
;------------------------------------------------------------------------
; Procedure isComposite calculates the next composite number.
; divides the number x by 2, 3, ..., x - 1 until remainder of 0 is found.
;------------------------------------------------------------------------
isComposite PROC
factorReset:
mov eax, presentValue;move the value into eax
dec eax ;decrement the value of eax
mov tempFactor, 2 ;move value 2 into tempFactor
mov maxFactor, eax ;move value maxFactor into eax
division:
mov eax, presentValue
cdq
div tempFactor ; perform division operation
cmp edx, 0 ;if remainder is 0, then a composite is found
je compositeFound
inc tempFactor ;else increment the value of tempFactor
mov eax, tempFactor
cmp eax, maxFactor
jle division ;if no factors are found then increment presentValue
inc presentValue
jmp factorReset ; jump to factorReset
compositeFound:
ret
isComposite ENDP
;-------------------------------------------------------------
; Procedure farewell displayes the end of the program message.
;-------------------------------------------------------------
farewell PROC
; display farewell
call Crlf
call Crlf
mov edx, OFFSET endMsg
call WriteString
call Crlf
ret
farewell ENDP
END main
Severity Code Description Project File Line Suppression State Error A2006 undefined symbol : presentValue Project C: \Project32_VS2019\template.asm 135 Error A2024 invalid operand size for instruction Project C: \Project32_VS2019\template.asm 47 Error MSB3721 The command "ml.exe /c ologo /Sg /Zi/ Fo"Debug\template.obj" /Fl"Project.Ist" || "C:\Irvine" /W3 /errorReport:prompt | Tatemplate.asm" exited with code 1. Project C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft| VC\v160\BuildCustomizations\masm.target 70 S Objectives 1. Designing and implementing procedures 2. Designing and implementing loops 3. Writing nested loops 4. Understanding data validation Problem Definition Write a program to calculate composite numbers. First, the user is instructed to enter the number of composites to be displayed, and is prompted to enter an integer in the range (1.300). The user enters a number, n, and the program verifies that 1 ss 300. If n is out of range, the user is re-prompted until they enter a value in the specified range. The program then calculates and displays all of the composite numbers up to and including the nth composite. The results should be displayed 10 composites per line with at least 3 spaces between the numbers. Requirements 1. The programmer's name must appear in the output. 2. The counting loop (1 to n) must be implemented using the MASM loop instruction. 3. The main procedure must consist (mostly) of procedure calls. It should be a readable "list" of what the program will do. 4. Each procedure will implement a section of the program logic, i.e., each procedure will specify how the logic of its section is implemented. The program must be modularized into at least the following procedures and sub- procedures: o introduction o getUserData validate showComposites isComposite o goodbye 5. The upper limit should be defined and used as a constant. 6. Data validation is required. If the user enters a number outside the range (1.300) an error message should be displayed and the user should be prompted to re-enter the number of composites. 7. Each procedure must have a procedure header that follows the format discussed during lecture. 8. The usual requirements regarding documentation, readability, user-friendliness, etc., apply. Notes 1. For this program, you may use global variables instead of passing parameters. This is a one-time relaxation of the standards so that you can get accustomed to using procedures. In future homework, global variables will not be allowed. 2. A number k is composite if it can be factored into a product of smaller integers. Every integer greater than one is either prime or composite. Note that this implies that o 1 is not composite. o The number must be positive. 3. If you choose to use the LOCAL directive while working on this program be sure to read section 8.2.9 in the Irvine textbook. LOCAL variables will affect the contents of the system stack! Example Program Operation Welcome to the Composite Number Spreadsheet Programmed by Author Name This program is capable of generating a list of composite numbers. Simply let me know how many you would like to see. I'll accept orders for up to 300 composites. How many composites do you want to view? [1 .. 300]: 400 Out of range. Please try again. How many composites do you want to view? [1 .. 300]: 0 Out of range. Please try again. How many composites do you want to view? [1 .. 300]: 23 4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30 32 33 34 35 Thanks for using my program! Severity Code Description Project File Line Suppression State Error A2006 undefined symbol : presentValue Project C: \Project32_VS2019\template.asm 135 Error A2024 invalid operand size for instruction Project C: \Project32_VS2019\template.asm 47 Error MSB3721 The command "ml.exe /c ologo /Sg /Zi/ Fo"Debug\template.obj" /Fl"Project.Ist" || "C:\Irvine" /W3 /errorReport:prompt | Tatemplate.asm" exited with code 1. Project C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft| VC\v160\BuildCustomizations\masm.target 70 S Objectives 1. Designing and implementing procedures 2. Designing and implementing loops 3. Writing nested loops 4. Understanding data validation Problem Definition Write a program to calculate composite numbers. First, the user is instructed to enter the number of composites to be displayed, and is prompted to enter an integer in the range (1.300). The user enters a number, n, and the program verifies that 1 ss 300. If n is out of range, the user is re-prompted until they enter a value in the specified range. The program then calculates and displays all of the composite numbers up to and including the nth composite. The results should be displayed 10 composites per line with at least 3 spaces between the numbers. Requirements 1. The programmer's name must appear in the output. 2. The counting loop (1 to n) must be implemented using the MASM loop instruction. 3. The main procedure must consist (mostly) of procedure calls. It should be a readable "list" of what the program will do. 4. Each procedure will implement a section of the program logic, i.e., each procedure will specify how the logic of its section is implemented. The program must be modularized into at least the following procedures and sub- procedures: o introduction o getUserData validate showComposites isComposite o goodbye 5. The upper limit should be defined and used as a constant. 6. Data validation is required. If the user enters a number outside the range (1.300) an error message should be displayed and the user should be prompted to re-enter the number of composites. 7. Each procedure must have a procedure header that follows the format discussed during lecture. 8. The usual requirements regarding documentation, readability, user-friendliness, etc., apply. Notes 1. For this program, you may use global variables instead of passing parameters. This is a one-time relaxation of the standards so that you can get accustomed to using procedures. In future homework, global variables will not be allowed. 2. A number k is composite if it can be factored into a product of smaller integers. Every integer greater than one is either prime or composite. Note that this implies that o 1 is not composite. o The number must be positive. 3. If you choose to use the LOCAL directive while working on this program be sure to read section 8.2.9 in the Irvine textbook. LOCAL variables will affect the contents of the system stack! Example Program Operation Welcome to the Composite Number Spreadsheet Programmed by Author Name This program is capable of generating a list of composite numbers. Simply let me know how many you would like to see. I'll accept orders for up to 300 composites. How many composites do you want to view? [1 .. 300]: 400 Out of range. Please try again. How many composites do you want to view? [1 .. 300]: 0 Out of range. Please try again. How many composites do you want to view? [1 .. 300]: 23 4 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 28 30 32 33 34 35 Thanks for using my program
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started