flat assembler
Message board for the users of flat assembler.

Index > Main > Proc locals

Author
Thread Post new topic Reply to topic
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie
I want to know if there's any technical differences between these two;

Code:
tst dd 1,1000000,100000,\  
       10000,1000,100,10    


and

Code:
tst dd 1,1000000,100000
    dd 10000,1000,100,10    


In a declaration like this below:

Code:
locals
           frac db 0    ;marker
           both db 0    ;marker
           big db 0     ;marker
           small db 0   ;marker
           large db 0   ;marker
           num dd 0     ;integral part
           num2 dd 0    ;fraction part
           idx dd 0     ;for small
           ndx dd 1     ;For big and large
           exponent dd 0
           mantissa dd 0.0
           copy dd 0.0
           y dd 10.0    ;divisor/multiplier
           tst dd 1,1000000,100000,\  ;<------ here
                  10000,1000,100,10
endl    


thanks Very Happy
Post 03 Sep 2014, 15:30
View user's profile Send private message Visit poster's website Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
No there is no difference.
Could even be:

Code:
tst dd 1
    dd 1000000
    dd 100000
    dd 10000
    dd 1000
    dd 100
    dd 10
    


Last edited by shutdownall on 03 Sep 2014, 21:29; edited 1 time in total
Post 03 Sep 2014, 19:29
View user's profile Send private message Send e-mail Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie
shutdownall

Ok.

But I get different answer in EAX. Is it something about the addressing of proc locals?

Code:
format pe console
include 'win32axp.inc'
;include 'dbg32.inc'

call tester

invoke system,"pause>null"
invoke exit,0

proc tester
     locals
     val dd 31h,32h,33h    ;displays whatever
         dd 34h,35h,36h
     ;val dd 31h,32h,33h,\ ;displays 34h. Correct
     ;       34h,35h,36h
     endl
     mov eax,[val+12]
     ;prtreg@ eax
     ret
endp

data import
     library msvcrt,'msvcrt.dll'
     import msvcrt,\
            system,'system',exit,'exit',\
            putchar,'putchar',getchar,'getchar'
end data    


On the contrary, the first set of "val" works outside locals.
Post 03 Sep 2014, 20:05
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
The locals macro won't initialise the values for unnamed data declarations. Outside of a proc definition the dd functions normally.
Post 03 Sep 2014, 23:00
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Code:
locals 
           frac db 0    ;marker                1 bytes
           both db 0    ;marker               2 bytes
           big db 0     ;marker                3 bytes
           small db 0   ;marker               4 bytes
           large db 0   ;marker                <-------------------- orphaned byte
           num dd 0     ;integral part 
           num2 dd 0    ;fraction part 
           idx dd 0     ;for small 
           ndx dd 1     ;For big and large 
           exponent dd 0 
           mantissa dd 0.0 
           copy dd 0.0 
           y dd 10.0    ;divisor/multiplier 
           tst dd 1,1000000,100000,\  ;<------ here 
                  10000,1000,100,10 
endl
    


You might want to at least WORD align the stack there.
Post 04 Sep 2014, 05:20
View user's profile Send private message Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie
revolution wrote:
The locals macro won't initialise the values for unnamed data declarations. Outside of a proc definition the dd functions normally.
Noted. Thanks
Post 04 Sep 2014, 08:14
View user's profile Send private message Visit poster's website Reply with quote
fasmnewbie



Joined: 01 Mar 2011
Posts: 555
fasmnewbie
typedef wrote:
Code:
locals 
           frac db 0    ;marker                1 bytes
           both db 0    ;marker               2 bytes
           big db 0     ;marker                3 bytes
           small db 0   ;marker               4 bytes
           large db 0   ;marker                <-------------------- orphaned byte
           num dd 0     ;integral part 
           num2 dd 0    ;fraction part 
           idx dd 0     ;for small 
           ndx dd 1     ;For big and large 
           exponent dd 0 
           mantissa dd 0.0 
           copy dd 0.0 
           y dd 10.0    ;divisor/multiplier 
           tst dd 1,1000000,100000,\  ;<------ here 
                  10000,1000,100,10 
endl
    


You might want to at least WORD align the stack there.


That's a great tip. Now my proc behaves as expected when I test it into some big test loop. Thanks guru.
Post 04 Sep 2014, 08:21
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.