News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

strange syntax errors

Started by *DEAD*, December 17, 2007, 10:23:39 AM

Previous topic - Next topic

*DEAD*

This has me absolutely baffled.



IsPrime proc test:DWORD
;
; ;mov ecx, test
; shr ecx, 1
;
; StartLoop:
;
; ; mov eax, test
; xor edx, edx
; div ecx
; cmp edx, 0
; jnz ExitLoop
; sub ecx, 2
;
; ja StartLoop
;
; push 1
; ret
;
; ExitLoop:
; push 0
; ret
IsPrime endp


Apparently, there is a syntax error with the colon. I have no idea whats going on, seeing as I practically copied the DlgProc example, which does work, to make my own.
"C:\masm32\projects\primefinder2\primefinder.asm(32) : error A2008: syntax error : :"
Also, when the middle code isnt commented out, mov ecx, test returns a syntax error
"C:\masm32\projects\primefinder2\primefinder.asm(39) : error A2008: syntax error : test"
but that is more that likely to be a result of the first syntax error. Can anyone tell me whats wrong with my colon. The rest of the code is below.

sinsi

"TEST" is a reserved word (test eax,eax)
Light travels faster than sound, that's why some people seem bright until you hear them.

RuiLoureiro

I didnt understand the way you want exit from IsPrime procedure:

push 1    and   push 0
ret                  ret

Can you explain it ?
Rui

Tedd

It's wrong :P
(The return address is popped off the stack, so it will try to 'return' to address 0 or 1, which will crash.)

The tradition is to put the return value into eax (though there's little to stop you from using a different register, or a memory location.)
No snowflake in an avalanche feels responsible.