flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Duplicate symbols on proc not checked

Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 15 Nov 2008, 18:07
Code:
include 'win32axp.inc'

proc start arg, arg
local a:DWORD, b:BYTE, a:DWORD
locals
  c db ?
  c dd ?
  arg dw ?
endl
  mov     [a], eax
  mov     eax, [c]
  int3
endp

.end start    


I suppose this problem could be fixed by attaching "start." to every argument and local instead of using "local" preprocessor directive and I think it could be beneficial for the new debugging feature. I'm unsure of the side effects of doing it this way though, at least there could be some collisions like this:
Code:
proc a.b
endp
proc a
local b:DWORD
endp    

This wouldn't be compilable anymore but is it really a too much high price for verbose label names?
Post 15 Nov 2008, 18:07
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 15 Nov 2008, 23:34
Yeah, this is a good idea. Those collisions are not really a serious issue.
Post 15 Nov 2008, 23:34
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 18 Jun 2010, 15:55
I almost report this twice Razz

There are two things I noticed today, one is that a local using the same name than one of the params triggers no errors and the parameter takes priority over the local unless it was defined in a "locals" block. The second, is that if it happens that the same symbol is used somewhere else in source and the proc either defines the same parameter twice, or use the same symbol in the parameters list and in a locals block, it will interfere with the global variable and even make the code uncompilable. Example:
Code:
format PE GUI 4.0
entry start
include 'win32wx.inc'

proc start alpha
locals
alpha dd ?
endl

mov eax, [alpha]
int3
endp

alpha: ; "Error: Symbol already defined." ; Instruction: "..arg?QE:"    


Contrary to my first report, I don't feel so confident about my proposal to fix this. Can duplicates be checked with match instead or something?
Post 18 Jun 2010, 15:55
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 18 Jun 2010, 19:48
Code:
format pe gui 4.0
include 'win32wx.inc'


entry $
        hlt
        call    p1
        call    p2
        call    p3
        ret


/*
push    ebp
mov     ebp,esp
sub     esp,4
push    [word ss:ebp-3] ;a dw ?
leave
retn
*/
proc p1
  locals
    a db ?
    a dw ?
  endl
        push    [a]
        ret
endp


/*
push    ebp
mov     ebp,esp
sub     esp,4
leave
retn
*/
proc p2
  locals
    a dw ?
    a db ?
  endl
;        push    [a] ; a db ?
        ret
endp


/*
push    ebp
mov     ebp,esp
sub     esp,4
push    [dword ss:ebp-4] ; a dd ?
leave
retn    4
*/
proc p3 a
  locals
    a dd ?
  endl
        push    [a]
        ret
endp
    
Post 18 Jun 2010, 19:48
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 18 Jun 2010, 22:51
Code:
/* <------------ Smile
push    ebp
mov     ebp,esp
sub     esp,4
push    [word ss:ebp-3] ;a dw ?
leave
retn
*/ <------------ Smile    

Wink Razz

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 18 Jun 2010, 22:51
View user's profile Send private message Send e-mail Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 19 Jun 2010, 04:27
that is real necessity(not TG humbling), we use assemblers(or compilers Confused) instead of hex editors...
Post 19 Jun 2010, 04:27
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.