flat assembler
Message board for the users of flat assembler.

Index > Feedback > FASM short reference info text / manpage

Author
Thread Post new topic Reply to topic
franka



Joined: 10 Dec 2005
Posts: 12
franka
I tried to put together a short reference.

the aim is to have a brief text summing up grammar of an .asm source
it's supposed to be complete as to mention all directives, reserved words,
speelings and so forth and requires understanding of FASM. but it then allows to look up individual issues with no need to search through multi-KB tutorials and stuff. actual 386 assembly ops are outside of it's scope.

please correct omissions or errors (maybe number formats?)

----- cut here ------ Arrow

FASM short reference

;syntax hilite: green num ; blue symbolic[({ch ; red 'string' ; grey coment ; black asm_opcodes asf. ;

;symbol char +-/*=<>()[]{}:,|&~#` and space ' ' and maybe " // they need no space
;symbol a..Z_ seq. with no space in between e.g. NOP
;line break: all complete ops in one line, then $ is current IP
\ concats two phys. lines
in al , \
$ ; stupid but $ is the same as if the 2 lines were one "in al,$"

;reserved words
include section extrn public readable writeable executable entry 666
export import resource fixups use16 use32 use64 heap stack 255
near far byte word dword ; usage see jump
used defined
display file dup format ELF ELF64 COFF MS COFF
virtual at $

display d ; assemble-time screen info preprocessed variable d
format PE GUI 4.0 DLL at 7000000h on 'stub.exe' ; one whole format directive
rva ; is specific to PE output format and performs the conversion of an address into the RVA

section '.reloc' data discardable fixups
section '.rsrc' data readable resource from 'my.res'

incl fix include ; fix has priority over equ
b equ 2 ; constant definition = 0 bytes assembler! used in "mov al,b" subsequently
offset equ ; empty constant symbolic value for use in mov ax, offset char ; with char being a label ?

num expr
'quoted string' "this to"
'to print can''t' as can't

ptr ; kinda [] replacement
mov byte [7],3 ; can also be written as mov byte ptr 7,3 move value 3 into byte at addr.7
jmp byte 0 ; short jump

[] usage [CX+4] indirect [mem addr]
{} usage macro tst {test al,0xFF} ; {multi line poss.} ; match params, list { foo params }
() usage db 3 dup (1,2) yields 1,2, 1,2, 1,2

org 100 ; where to place following code line offset-wise; differs for various OS'es
$ current IP offset
$$ current base addr (segm)
%t current time stamp ; note %t% meaning ENVIR VARI t in DOS ; SET T=IneedTlater
% current repeat counter in looping directive (see below)

, mov al,3 ; separates arguments

numbers and . usage
1.0 1E0 1f ; float number 1.0000 in three styles ; but 1 meaning an integer
255 '552' $FF 0xFF FFh 11111111b 377o 255.0 255e0 255e0f ; these are all equal values //really? '522'
good: FFh 1f ; recomended uppercase usage: ABCDEF always a hex value, lowercase f float or char or sth.
bad : ffH 1F ; but possible

- + * / mod rva ; arithm evaluated by assembler, used in address expressions too
& | ~ meaning AND OR NOT

Priority Operators // evaluation depth unknown, probably 3 or 4
0 + -
1 * /
2 mod
3 and or xor
4 shl shr
5 not
6 rva




;4 condition texts:
if
else
else if
end if
;usage in terms
= equal ; = also used as assignment: constant = value e.g. my_length = 32
< less
> greater
<= less or equal
>= greater or equal
<> not equal


#
; comment ignored by assembler

db 3 ; single byte data definition db '3'
du 'string'
dq ? ; place holder value undef'd
dp hi lo words
dd h lo words in pointer
df 1,2
dt 3.14 FPU double precis.
rb ru ;and so forth

as in these size operators:
byte 8 1
word 16 2
dword 32 4
fword 48 6
pword 48 6
qword 64 8
tbyte 80 10
tword 80 10
dqword 128 16

: ; the colon usage varies
label: nop ; e.g. loop_end: nop ; jump here when finished
label without : ; e.g. img_blk db 42 ; img_blk holds offset from data definition
label wchar word at mychar ; this line can be anywhere in the asm source, possibly grouped

@@ name means anonymous label ; if you think any label name would be rather confusing
@b or @r means nearest preceding anonymous label (backwd)
@f means nearest following anonymous label (fwd)

.my_local_label ; is completed to either my_scope_A.my_local_lbl or my_scope_B.my_local_lbl,
; depending on preceding global label
my_scope_B.my_local_lbl ; explicit gobal.local label, eases cut n paste of source text parts
..my_global_label ; not altering local label prefix

seg:offs as in
jmp 0FFFFh:0 ; direct far jump
jmp 100h ; direct near jump
LABEL ; usage example: NOP1forINT01 NOP ; patch in 0cch = int03 if needed
alpha db 0 ; no need for : as in alpha: db 0 ; some languages use this style

virtual at 0 ; usage of : virtual code or data block , later text may ref. a label from there
file 'a.txt':10h,1 ; unreferenced virtuals do not appear in target
load mychar from 0
end virtual


h hex, use 0fh leading zero if using ABCDE , see above

include 'c:\source_in_other_file.inc':2:3 // offset, count
include '/etc/my_include.inc'
include %incdir%'winapi.inc' ; %environment_vari% such as %PATH% DOS searchpath

% such as %PATH% DOS searchpath


repeat
count

rept 3 counter
{ byte#counter db counter }
will generate lines:
byte1 db 1
byte2 db 2
byte3 db 3
Post 11 Dec 2005, 02:51
View user's profile Send private message Reply with quote
quasar



Joined: 09 Oct 2005
Posts: 16
quasar
very short one I always wanted docs to be as long as this one Very Happy
Post 11 Dec 2005, 14:16
View user's profile Send private message Reply with quote
franka



Joined: 10 Dec 2005
Posts: 12
franka
quasar wrote:
very short Very Happy


well it looks much better in colour (syntax hilite) and proper typefaces ...

I'll upload that too
Post 12 Dec 2005, 01:58
View user's profile Send private message 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.