- May 21, 2013
- 3,656
- 60
- 91
I'm working on a class assignment that involves an array. I need to be able to put values in the array, but I'm getting two errors that I don't understand. It's likely you won't be able to compile because of the io.h, which is part of the software bundled with the textbook.
The io.h that I'm including just includes macros for easier input/output from the user. the output command and wtoa are the only commands that take advantage of it.
Error at line 50:
Error 2 error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\example.obj" /W3 /errorReport
rompt /Fl /Taexample.asm" exited with code 1.
C: \Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\masm.targets
Error at line 55:
Error 1 error A2070: invalid instruction operands C: \Users\Adam\OneDrive\Classes\CS 238\HW-DUE--04062015\windows32\windows32\example.asm
I'm a bit puzzled about what the issues are. Am I not able to move directly into a de-referenced address? And why can't I compare the cl register with candidate from memory?
These are the only two compile errors I have. I'd like to get them sorted to check for logic errors. I'm making this in Visual Studio 2013.
I know the 100th prime is 541, so I'm hoping it's not a size issue.
Code:
; Program Description: Finds the first 100 prime numbers, displays only the 100th
; Date: Apr. 2, 2015
.586
.MODEL FLAT
INCLUDE io.h ; header file for input/output
.STACK 4096
.DATA
prime WORD 2, 3, 98 DUP (?)
primeCount BYTE 2
candidate WORD 5
WindowLbl BYTE "The 100th prime number is:", 0
WindowBody BYTE 6 DUP (?), 0
.CODE
_MainProc PROC
; while (primeCount < 100)
OuterWhileCheck:
cmp primeCount, 100
jz PrintPrime
; {
; outer while loop body
mov cl, 1
lea ebx, prime
; while (index <= primeCount && prime[index] % candidate != 0)
InnerWhileCheck:
cmp cl, primeCount
jnbe ExitInnerWhile
mov edx, 0
mov eax, [ebx]
div candidate
cmp edx, 0
jne ExitInnerWhile
; {
; inner while loop body
inc cl
add ebx, 2
jmp InnerWhileCheck
; end inner while loop body
; }
ExitInnerWhile:
; if (index > primeCount)
; ********ERROR MARKED ON LINE BELOW***********
cmp cl, primeCount
jna EndOfIf
; {
; if body
inc primeCount
; *******ERROR ON LINE BELOW*************
mov [ebx], candidate
; end if body
; }
EndOfIf:
add candidate, 2
jmp OuterWhileCheck
; end outer while loop body
; }
PrintPrime:
wtoa WindowBody, [ebx]
output WindowLbl, WindowBody
mov eax, 0 ; exit with return code 0
ret
_MainProc ENDP
END
The io.h that I'm including just includes macros for easier input/output from the user. the output command and wtoa are the only commands that take advantage of it.
Error at line 50:
Error 2 error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\example.obj" /W3 /errorReport
C: \Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\masm.targets
Error at line 55:
Error 1 error A2070: invalid instruction operands C: \Users\Adam\OneDrive\Classes\CS 238\HW-DUE--04062015\windows32\windows32\example.asm
I'm a bit puzzled about what the issues are. Am I not able to move directly into a de-referenced address? And why can't I compare the cl register with candidate from memory?
These are the only two compile errors I have. I'd like to get them sorted to check for logic errors. I'm making this in Visual Studio 2013.
I know the 100th prime is 541, so I'm hoping it's not a size issue.
