News:

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

naked function assemble error, help

Started by stbfish, September 12, 2009, 09:28:05 AM

Previous topic - Next topic

stbfish

.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.

ragdog

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

dedndave

Quotetest is a register you can see this
"test" is an instruction

ragdog


hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

cobold

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


donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Slugsnack

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.

donkey

Hi Slugsnack,

Actually thinking about it you're probably right :)
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable