flat assembler
Message board for the users of flat assembler.

Index > Main > Problem with DUP

Author
Thread Post new topic Reply to topic
Cthulhu



Joined: 12 May 2005
Posts: 29
Cthulhu 13 May 2005, 17:48
How can I declare a variable and initialize it with zeros like DUP in Masm and Tasm?

In Masm I would code it this way:
Code:
.386
.model flat, stdcall
option casemap:none

include d:\masm32\include\windows.inc
include d:\masm32\include\kernel32.inc
includelib d:\masm32\lib\kernel32.lib

.data
        WinDir db MAX_PATH dup(0)
        
.code   
start:
        push MAX_PATH
        push offset WinDir
        call GetWindowsDirectoryA
        
        push 0
        call ExitProcess
end start
    


I can't manage to do the same with Fasm Confused
Post 13 May 2005, 17:48
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 13 May 2005, 18:02
Code:
WinDir  rb  MAX_PATH    


"rb" means "reserve bytes"
Post 13 May 2005, 18:02
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Cthulhu



Joined: 12 May 2005
Posts: 29
Cthulhu 13 May 2005, 18:09
Thanks friend
Post 13 May 2005, 18:09
View user's profile Send private message Reply with quote
YONG



Joined: 16 Mar 2005
Posts: 7997
Location: 22° 15' N | 114° 10' E
YONG 14 May 2005, 07:52
The code
Code:
WinDir  rb  MAX_PATH
    

simply reserves MAX_PATH bytes of space. It does not initialize
those bytes to zero, i.e., those bytes may contain any random values
at program start.

To make sure that those bytes are initialized to zero at program start,
use the following code:
Code:
WinDir: times   MAX_PATH        db      0
    


YONG
Post 14 May 2005, 07:52
View user's profile Send private message Visit poster's website Reply with quote
Cthulhu



Joined: 12 May 2005
Posts: 29
Cthulhu 14 May 2005, 13:16
Thank you YONG!
Post 14 May 2005, 13:16
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 25 Jun 2005, 05:01
Post 25 Jun 2005, 05:01
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.