flat assembler
Message board for the users of flat assembler.

Index > Windows > newb problem:what's wrong with this code?

Author
Thread Post new topic Reply to topic
hitertan



Joined: 12 Mar 2004
Posts: 15
Location: China
hitertan 17 Mar 2004, 13:26
I'm a newbie in assemble language.Today when i programming i am held by one curious mistake.I have written some simple codes to stand out the mistake:
Code:
include '%fasminc%/win32ax.inc'
 
 .code
    start:
       call testProc
       invoke ExitProcess,0
proc testProc
       .testLocal dd ?
     enter
       push eax
testGoto1:      
    mov eax,3
   mov [.testLocal],eax
        pop eax
     return
      
    .end start
    

the fasm compile output the compile error below:
Quote:

mov [.testLocal],eax
error: undefined symbol

But when I comment the label testGoto1:,the codes can be compiled ok.
the correct codes is below
Code:
 include '%fasminc%/win32ax.inc'
 
 .code
    start:
            call testProc
       invoke ExitProcess,0
proc testProc
       .testLocal dd ?
     enter
       push eax
;testGoto1:     
    mov eax,3
   mov [.testLocal],eax
        pop eax
     return
      
    .end start
    

What's the wrong i'am making?

_________________
i like assembly language and i study it in my pleasure time
tanshunquan@hotmail.com
Post 17 Mar 2004, 13:26
View user's profile Send private message MSN Messenger Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro 17 Mar 2004, 13:46
proc defines global testProc label and dot before testLocal makes it child label of testProc, so it comes testProc.testLocal. Now when you define global label(no dot before it) testGoto1 it changes prefix to testGoto1 so after that when you try to access .testLocal it's same as writing testGoto1.testLocal.

Solution: use local labels(labels starting with dot) inside proc's. If you need global label inside of proc you need to use label beginning with 2 dots, it's global but doesn't change current prefix for the local labels.

You should read more about labels from fasm.txt
Post 17 Mar 2004, 13:46
View user's profile Send private message Reply with quote
Iehbr



Joined: 17 Mar 2004
Posts: 1
Iehbr 17 Mar 2004, 13:56
hitertan wrote:
I'm a newbie in assemble language.Today when i programming i am held by one curious mistake.I have written some simple codes to stand out the mistake:
Code:
include '%fasminc%/win32ax.inc'
 
 .code
    start:
        call testProc
       invoke ExitProcess,0
proc testProc
       .testLocal dd ?
     enter
       push eax
testGoto1:      
    mov eax,3
   mov [.testLocal],eax
        pop eax
     return
      
    .end start
    

the fasm compile output the compile error below:
Quote:

mov [.testLocal],eax
error: undefined symbol

But when I comment the label testGoto1:,the codes can be compiled ok.
the correct codes is below
What's the wrong i'am making?


Use 'stdcall testProc'
Post 17 Mar 2004, 13:56
View user's profile Send private message Reply with quote
hitertan



Joined: 12 Mar 2004
Posts: 15
Location: China
hitertan 17 Mar 2004, 14:26
aaro wrote:
proc defines global testProc label and dot before testLocal makes it child label of testProc, so it comes testProc.testLocal. Now when you define global label(no dot before it) testGoto1 it changes prefix to testGoto1 so after that when you try to access .testLocal it's same as writing testGoto1.testLocal.

Solution: use local labels(labels starting with dot) inside proc's. If you need global label inside of proc you need to use label beginning with 2 dots, it's global but doesn't change current prefix for the local labels.

You should read more about labels from fasm.txt

I see!Thank you very much! Very Happy

_________________
i like assembly language and i study it in my pleasure time
tanshunquan@hotmail.com
Post 17 Mar 2004, 14:26
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.