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

16 May 2005, 05:20

fly

Joined: 27 Apr 2005
Posts: 11
Location: Salzburg, Austria

fly

in fasm there exist a directive called 'file', i never tried it, but i read about in the fasm programmers manual, page 11

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.

17 May 2005, 14:12

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

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.

17 May 2005, 14:16

THEWizardGenius

Joined: 14 Jan 2005
Posts: 382
Location: California, USA

THEWizardGenius

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.

22 May 2005, 21:59

Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland

Tomasz Grysztar

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.

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum