The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: stbfish on September 12, 2009, 09:28:05 AM

Title: naked function assemble error, help
Post by: stbfish on September 12, 2009, 09:28:05 AM
.386
.model flat, stdcall
option casemap:none

test proto

.DATA
.DATA?
.CONST

.CODE
start:
invoke test

test proc
    pushad
    pushfd
    ;
    popfd
    popad
test endp

end start

A2008: syntax error : proto
A2008: syntax error : test
syntax error : in instruction
syntax error : endp

help me.. :(

;assemble error reason
test is an instruction in asm, so can't use it for function name.
thanks for help.
Title: Re: naked function assemble error, help
Post by: ragdog on September 12, 2009, 09:38:50 AM
Hi

test is a register you can see this
test eax,eax

change your proc in _test or what ever


.386
.model flat, stdcall
option casemap:none

_test proto

.DATA
.DATA?
.CONST

.CODE
start:
invoke _test

_test proc
    pushad
    pushfd
    ;
    popfd
    popad
_test endp

end start
Title: Re: naked function assemble error, help
Post by: dedndave on September 12, 2009, 10:09:51 AM
Quotetest is a register you can see this
"test" is an instruction
Title: Re: naked function assemble error, help
Post by: ragdog on September 12, 2009, 11:04:27 AM
sorry yes i mean this :bg

greest
Title: Re: naked function assemble error, help
Post by: hutch-- on September 13, 2009, 01:33:59 AM
The term is "RESERVE WORD" and it applies to the entire intel instruction set as well as MASM specific operators. Its for a very obvious reason, the assembler has no way of distinguishing between a variable/label/operator of the same name so it says unhappy things to you in the form of error messages.

A characteristic of MASM (not a necessarily good one) is that after the FIRST error, often the rest is nonsense.
Title: Re: naked function assemble error, help
Post by: cobold on September 14, 2009, 07:01:50 PM
Quote from: ragdog on September 12, 2009, 09:38:50 AM
...

change your proc in _test or what ever


.386
.model flat, stdcall
option casemap:none

_test proto

.DATA
.DATA?
.CONST

.CODE
start:
invoke _test

_test proc
    pushad
    pushfd
    ;
    popfd
    popad
RET ; would be nice to have - usually we want to return don't we?
_test endp

end start

Title: Re: naked function assemble error, help
Post by: donkey on September 15, 2009, 05:03:05 AM
Well, if we're correcting code here, after the call to _test returns the program will proceed through it one more time because he doesn't terminate. This will result in a stack misalignment and likely a GP when the RET is executed (since no meaningful return address is likely to be on the stack). There should be an ExitProcess in there....

.CODE
start:
invoke _test
invoke ExitProcess, 0

_test proc
    pushad
    pushfd
    ;
    popfd
    popad
RET ; would be nice to have - usually we want to return don't we?
_test endp

end start


And by the way, the proper term is test is an assembly mnemonic
Title: Re: naked function assemble error, help
Post by: Slugsnack on September 15, 2009, 11:30:22 AM
Quote from: donkey on September 15, 2009, 05:03:05 AM
Well, if we're correcting code here, after the call to _test returns the program will proceed through it one more time because he doesn't terminate. This will result in a stack misalignment and likely a GP when the RET is executed (since no meaningful return address is likely to be on the stack). There should be an ExitProcess in there....

Haha actually, if I'm not wrong, every thread's starting ESP is a pointer to code for :
push eax
call RtlExitUserThread

Hence what the return value for applications is for. This is why you can use ret as a quick way of finish threads.
Title: Re: naked function assemble error, help
Post by: donkey on September 15, 2009, 11:59:25 AM
Hi Slugsnack,

Actually thinking about it you're probably right :)