flat assembler
Message board for the users of flat assembler.

Index > Main > Question about declaring variables

Author
Thread Post new topic Reply to topic
inhahe



Joined: 18 Jul 2008
Posts: 2
Location: miami.fl.usa
inhahe 18 Jul 2008, 02:56
How do I declare variables that have a place in memory but don't take up any bytes in the output file? I mean it seems a shame to use up extra bytes in the file for variables that don't need an initial value. (I'm kinda new to assembly.)
Post 18 Jul 2008, 02:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1140
Location: Russian Federation
comrade 18 Jul 2008, 03:20
See http://flatassembler.net/docs.php?article=manual#1.2.2

Basically, use either the "db ?" syntax, or the "rb" syntax.
Post 18 Jul 2008, 03:20
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 18 Jul 2008, 03:23
Just by defining them with the value "?" (for example: aByte db ?).

Note however that the uninitialized variables must be placed AFTER any initialized data or instructions, otherwise the "?"'s will be filled with zeroes (and will take up space).

Example:
Code:
org $100
jmp exit
aByte db ?
exit: int $20    
Makes a 5 bytes file while
Code:
org $100
jmp exit
exit: int $20
aByte db ?    
Makes a 4 bytes file.
Post 18 Jul 2008, 03:23
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.