CHAPTER 1 - Getting started
Here i predict you have some basic information about what are bytes and some
idea what is ASCII code. Maybe i will describe ASCII in later versions of
First try to compile empty source file. Just create empty file "empty.asm"
fasm empty.asm empty.bin
into command line. You should see that
file "empty.bin" is created, and it's length is zero.
Now we will create binary file containing some data. Create text file
and compile it (i hope you already know how). When you look at created file
you should see it is 1 byte long and it contains character "a".
Now let's analyze (?) source:
db is "directive" (directive is command to compiler, remember this!) which
means "define byte". So this directive will put byte into destination file.
Value of byte should follow this directive. For example
db 0 will insert
byte of value 0 to destination file. But if you want to enter some character,
you would have to remember it's ASCII value. In this case, you can enter the
character enclosed in apostrophes (') and compiler will "get" it's value for
you. This is that code works.
Now let's make file with more than one character. It will be:
command to compiler
How this work is clear, i think, it stores three bytes into destination file,
which should now contain simple line with
123. By the way you can't write
because every directive must be on separate line. But if you want to define
more bytes, you can use simple
db '1' db '2' db '3'
db directive followed by more values,
sperated by commas (,):
This will produce file with
But what if you want to define something longer, for example file containing
This is my first long string in FASM? You could write
but it is not very nice. For this reason, if you want define more
consecutive characters using
db 'T','h','i','s' etc...
db , you can use this form:
So you have to enclose whole text in quotes. You can use this too:
db 'This is my first long string in FASM'
db 'This is my first long string in ','FASM'
db 'Thi','s is my first lo','ng string in',' FASM'
string, quoted string
Text enclosed in apostrophes is called "string". In general, "string" is
array of characters. Term used for string inside source code is called