fasm empty.asm empty.bininto command line. You should see that file "empty.bin" is created, and it's length is zero.
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".db 'a'
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.directiveNow 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 withdb '1' db '2' db '3'
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 simpledb '1' db '2' db '3'
db
directive followed by more values,
sperated by commas (,):
This will produce file withdb '1','2','3'
123
too.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 usingdb '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'
ordb 'This is my first long string in ','FASM'
etc.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 "quoted string".