flat assembler
Message board for the users of flat assembler.

Index > Main > question about instruction times 512-($-$$) db 0

Author
Thread Post new topic Reply to topic
adefeo



Joined: 12 Jan 2004
Posts: 46
Location: Bellmore, Long Island, New York
adefeo 21 Apr 2004, 20:24
I'm slowly moving to FASM from NASM. NASM had a 'times' directive that made the file a certian size by filling the rest with zero-bits. This is extremely useful in bootsectors (they MUST be 512 bytes). For example

...
times 512-($-$$) db 0
...

would make a 512 byte file.
Does FASM support such a directive?
Prompt response would be appreciated

-Anthony DeFeo
Post 21 Apr 2004, 20:24
View user's profile Send private message Visit poster's website AIM Address Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 21 Apr 2004, 20:37
Code:
times 512-$ db 0    

will work with fasm.
Post 21 Apr 2004, 20:37
View user's profile Send private message Visit poster's website Reply with quote
adefeo



Joined: 12 Jan 2004
Posts: 46
Location: Bellmore, Long Island, New York
adefeo 23 Apr 2004, 16:32
Privalov wrote:
Code:
times 512-$ db 0    

will work with fasm.


I tried this and it does not work. It returns an error about an invalid something (i forget ) I am using the latest Linux version of FASM on a Debian Linux 2.1 system with kernel 2.2.12

Why is it not working

Question Smile
Post 23 Apr 2004, 16:32
View user's profile Send private message Visit poster's website AIM Address Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 23 Apr 2004, 16:38
Weird the following work for me (part of my hack and slash bootloader)

Code:
times 512-$-2 db 0
db 55h,0aah ; boot signature
    
Post 23 Apr 2004, 16:38
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8390
Location: Kraków, Poland
Tomasz Grysztar 23 Apr 2004, 17:36
First, this can be used mainly with binary output format only - when you use some relocatable format (like object files, but also PE), you cannot use $ symbol this way, because it doesn't have fixed value.

Second, expression 512-$ will be of course negative when $ is larger than 512 and you will get error in such situation, too.
Post 23 Apr 2004, 17:36
View user's profile Send private message Visit poster's website Reply with quote
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon 23 Apr 2004, 23:14
this is what i always use and it works all the time

Code:
times $-510 db 0
db 0x55h, 0xaa ; boot signature
    

_________________
It is better to be on the right side of the devil than in his path.
Post 23 Apr 2004, 23:14
View user's profile Send private message Visit poster's website Reply with quote
Daemon



Joined: 08 Jul 2003
Posts: 15
Daemon 24 Apr 2004, 05:59
Why not to use a 'rb' directive ?

btw question to Privalov: is this directive always leaves zeros or not?
I mean is it possible that in

rb 1024

can be not only zeros but some random data ??
Post 24 Apr 2004, 05:59
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Apr 2004, 07:01
manual says you should always treat value as --undefined--, and that is. If "rb" is used at end of file, it will just reserve space in file header, and thus when you run program memory will contain data remained from previous owner of this part of memory
Post 24 Apr 2004, 07:01
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
adefeo



Joined: 12 Jan 2004
Posts: 46
Location: Bellmore, Long Island, New York
adefeo 26 Apr 2004, 19:48
Thanks! I'll try it when I get home from school.
Post 26 Apr 2004, 19:48
View user's profile Send private message Visit poster's website AIM Address Reply with quote
adefeo



Joined: 12 Jan 2004
Posts: 46
Location: Bellmore, Long Island, New York
adefeo 27 Apr 2004, 19:22
NEITHER of the methods work... I'm Confuzzled...What's wrong:?:
Post 27 Apr 2004, 19:22
View user's profile Send private message Visit poster's website AIM Address 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.