flat assembler
Message board for the users of flat assembler.

Index > Main > Requested Feature

Author
Thread Post new topic Reply to topic
doubletoker



Joined: 15 Mar 2005
Posts: 4
doubletoker 16 May 2005, 05:20
Hello, sorry if this post is in the wrong place, just recently switched to fasm, I love it, wish it had 1 extra feature though, if it's not to much, in nasm they have a feature called incbin, which does a raw binary include of a file, like one big db array of the file contents. example:

incbin 'filename.ext'

anyway, if not, I'm sure I could make a program that makes an include file with the dump. Guess I'm being a little lazy as I might be the only one that uses the feature.

fasm rocks & thanks,
double toker
Post 16 May 2005, 05:20
View user's profile Send private message Reply with quote
fly



Joined: 27 Apr 2005
Posts: 11
Location: Salzburg, Austria
fly 16 May 2005, 06:10
in fasm there exist a directive called 'file', i never tried it, but i read about in the fasm programmers manual, page 11
Post 16 May 2005, 06:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 16 May 2005, 06:14
Please, read the fasm's FAQ. Wink
Post 16 May 2005, 06:14
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 17 May 2005, 14:12
Quote:

Please, read the fasm's FAQ. Wink


The very first thing in the FAQ list is "Does flat assembler have some directive like incbin?" and the answer is yes: the directive is called 'file.' See
section 1.2.2 of the manual (Data definitions).

The Manual mentions the 'file' directive, but it isn't very clear on the syntax. I would guess the directive is like this:

file 'filename.ext'[: offset[, length]]

where "filename.ext" is the name of the binary file you wish to read from, "offset" is the offset (in bytes) into the file where you wish to begin reading (if you do not specify this option, the beginning of the file is assumed), and "length" is the number of bytes to read from the file (if not specified, the file is read from offset or beginning of file all the way to the end of the file).

I have never used the directive and unfortunately the manual and FAQ do not tell much about it, but I assume this is how it should be written.

I assume that offset and length are zero-based; however, Privalov, you may wish to mmake this clear in the manual, as I have never actually seen a statement in the manual that says "all numbers are zero-based unless specified otherwise", although when in doubt I assume they are.
Post 17 May 2005, 14:12
View user's profile Send private message AIM Address Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 17 May 2005, 14:16
What do you mean by "zero-based" when you speak about length? As for the offset, all offsets in assembly are zero-based anyway.

And the syntax using your convention should be written this way:

file 'path'[:offset][,length]

you can specify both offset without length and length without offset. I will add some examples to documentation to clear it out.
Post 17 May 2005, 14:16
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 22 May 2005, 21:59
Thanks. I wasn't sure because as I say, it isn't very well documented. This is not assembly, so it's not safe to assume that it is zero-based since all offsets in assembly are zero-based: it's an extra FASM-specific thing. You may wish to add 'incbin' as an alias for 'file', since some people are used to incbin instead of 'file'. You know, it would be nice if it were possible to have aliases for certain directives that are FASM-specific so people could customize FASM.
Post 22 May 2005, 21:59
View user's profile Send private message AIM Address Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 22 May 2005, 22:05
As manuals recommend, you should do any customizations like that with EQU directive (and FIX in case of aliases for preprocessor's constructions). Implementing aliases internally would extend unnecessarily the amount of reserved words and I'd prefer to avoid it.

Quote:
This is not assembly, so it's not safe to assume that it is zero-based since all offsets in assembly are zero-based: it's an extra FASM-specific thing.

Well, it is one of the directives processed by assembler, the ones that control the process of assembling, and they also are a part of an assembly language (even though this language varies between different assemblers). You may even define the instruction mnemonics as a special case of such directives, like: "mov" directive tells assembler to generate and put at current position the opcode of transfer instruction with the specified operands.
And in the assembly languages in general the offset for the first field of any structure - in memory or in file - is zero. That's why you have guessed correctly that in case of "file" directive it's also this way.
Post 22 May 2005, 22:05
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.