Assembler

This chapter describes the Watcom Assembler. It includes the following sections:

Introduction

This chapter describes the Watcom Assembler. It takes as input an assembler source file (a file with extension .a) and produces, as output, an object file.

The Watcom Assembler command-line syntax is as follows:

wasm [options] asm_file [options] [@env_var]

The square brackets [ ] denote items that are optional.

asm_file
is the filename specification of the assembler source file to be assembled. A default filename extension of .a is assumed when no extension is specified.
options
is a list of valid Watcom Assembler options, each preceded by a dash (-). Options may be specified in any order.

The options supported by the Watcom Assembler are as follows:

{0,1,2,3,4,5}{p}{r,s}
0
same as .8086
1
same as .186
2{p}
same as .286 or .286p
3{p}
same as .386 or .386p (also defines __386__, and changes the default USE attribute of segments from USE16 to USE32)
4{p}
same as .486 or .486p (also defines __386__, and changes the default USE attribute of segments from USE16 to USE32)
5{p}
same as .586 or .586p (also defines __386__, and changes the default USE attribute of segments from USE16 to USE32)
p
protect mode
r
defines __REGISTER__
s
defines __STACK__

For example,

    -2       -3p     -4pr     -5p
      
bt=os
defines __os__, and checks the os_INCLUDE environment variable for include files
c
don't output OMF COMENT records that allow wdisasm to figure out when data bytes have been placed in a code segment
dname[=text]
define text macro
d1
line number debugging support
e
stop reading assembler source file at the END directive. Normally, anything following the END directive causes an error.
enumber
set error limit number
fe=file_name
set error file name
fo=file_name
set object file name
fi=file_name
force file_name to be included
fpc
same as .no87
fpi
inline 80x87 instructions with emulation
fpi87
inline 80x87 instructions
fp0
same as .8087
fp2
same as .287 or .287p
fp3
same as .387 or .387p
fp5
same as .587 or .587p
i=directory
add directory to list of include directories
j or s
force signed types to be used for signed values
m{t,s,m,c,l,h,f}
memory model: (Tiny, Small, Medium, Compact, Large, Huge, Flat)
-mt
Same as .model tiny
-ms
Same as .model small
-mm
Same as .model medium
-mc
Same as .model compact
-ml
Same as .model large
-mh
Same as .model huge
-mf
Same as .model flat

Each of the model directives also defines __model__ (for example, .model small defines __SMALL__). They also affect whether something like foo proc is considered a far or near procedure.

nd=name
set data segment name
nm=name
set module name
nt=name
set name of text segment
o
allow C form of octal constants
zq or q
operate quietly
? or h
print a help message
wnumber
set the warning level number
we
treat all warnings as errors

Assembly directives and opcodes

It isn't the intention of this chapter to describe assembly-language programming in any detail. You should consult a book that deals with this topic. However, we present an alphabetically ordered list of the directives, opcodes and register names that are recognized by the assembler.

The following directives and opcodes are supported by the Watcom Assembler:

.186
.286
.286c
.286p
.287
.386
.386p
.387
.486
.486p
.586
.586p
.8086
.8087

aaa
aad
aam
aas
abs
adc
add
ah
al
alias
align
and
arpl
assume
at
ax

basic
bh
bl
bound
bp
bsf
bsr
bswap
bt
btc
btr
bts
bx
byte

c
call
callf
cbw
cdq
ch
cl
clc
cld
cli
clts
cmc
cmp
cmps
cmpsb
cmpsd
cmpsw
cmpxchg
cmpxchg8b
.code
comm
comment
common
compact
.const
cpuid
cr0
cr2
cr3
cr4
cs
cwd
cwde
cx

daa
das
.data
.data?
db
dd
dec
df
dh
di
div
dl
.dosseg
dp
dq
dr0
dr1
dr2
dr3
dr6
dr7
ds
dt
dup
dw
dword
dx

eax
ebp
ebx
ecx
edi
edx
else
elseif
end
endif
endp
ends
enter
eq
equ
equ2
.err
.errb
.errdef
.errdif
.errdifi
.erre
.erridn
.erridnni
.errnb
.errndef
.errnz
error
es
esi
esp
even
export
extern
externdef

f2xm1
fabs
fadd
faddp
far
.fardata
.fardata2
farstack
fbld
fbstp
fchs
fclex
fcom
fcomp
fcompp
fcos
fdecstp
fdisi
fdiv
fdivp
fdivr
fdivrp
feni
ffree
fiadd
ficom
ficomp
fidiv
fidivr
fild
fimul
fincstp
finit
fist
fistp
fisub
fisubr
flat
fld
fld1
fldcw
fldenv
fldenvd
fldenvw
fldl2e
fldl2t
fldlg2
fldln2
fldpi
fldz
fmul
fmulp
fnclex
fndisi
fneni
fninit
fnop
fnrstor
fnrstord
fnrstorw
fnsave
fnsaved
fnsavew
fnstcw
fnstenv
fnstenvd
fnstenvw
fnstsw
for
forc
fortran
fpatan
fprem
fprem1
fptan
frndint
frstor
frstord
frstorw
fs
fsave
fsaved
fsavew
fscale
fsetpm
fsin
fsincos
fsqrt
fst
fstcw
fstenv
fstenvd
fstenvw
fstp
fstsw
fsub
fsubp
fsubr
fsubrp
ftst
fucom
fucomp
fucompp
fwait
fword
fxam
fxch
fxtract
fyl2x
fyl2xp1

ge
global
group
gs
gt

hlt
huge

idiv
if
if1
if2
ifb
ifdef
ifdif
ifdifi
ife
ifidn
ifidni
ifnb
ifndef
ignore
imul
in
inc
include
includelib
ins
insb
insd
insw
int
into
invd
invlpg
iret
iretd
irp

ja
jae
jb
jbe
jc
jcxz
je
jecxz
jg
jge
jl
jle
jmp
jmpf
jna
jnae
jnb
jnbe
jnc
jne
jng
jnge
jnl
jnle
jno
jnp
jns
jnz
jo
jp
jpe
jpo
js
jz

label
lahf
lar
large
lds
le
lea
leave
length
lengthof
les
lfs
lgdt
lgs
lidt
lldt
lmsw
local
lock
lods
lodsb
lodsd
lodsw
loop
loope
loopne
loopnz
loopz
lsl
lss
lt
ltr

macro
medium
memory
mod
.model
mov
movs
movsb
movsd
movsw
movsx
movzx
mul

name
ne
near
nearstack
neg
no87
nop
not
nothing

offset
or
org
os_dos
os_os2
out
outs
outsb
outsd
outsw

para
pascal
pop
popa
popad
popf
popfd
private
proc
ptr
public
push
pusha
pushad
pushf
pushfd
pword

qword

rcl
rcr
rdmsr
rdtsc
readonly
rep
repe
repne
repnz
repz
ret
retf
retn
rol
ror
rsm

sahf
sal
sar
sbb
sbyte
scas
scasb
scasd
scasw
sdword
seg
segment
seta
setae
setb
setbe
setc
sete
setg
setge
setl
setle
setna
setnae
setnb
setnbe
setnc
setne
setng
setnge
setnl
setnle
setno
setnp
setns
setnz
seto
setp
setpe
setpo
sets
setz
sgdt
shl
shld
short
shr
shrd
si
sidt
size
sizeof
sldt
small
smsw
sp
ss
st
.stack
stc
std
stdcall
sti
stos
stosb
stosd
stosw
str
struc
struct
sub
sword
syscall

tbyte
test
textequ
tiny
tr3
tr4
tr5
tr6
tr7

use16
use32
uses

vararg
verr
verw

wait
watcom_c
wbinvd
word
wrmsr

xadd
xchg
xlat
xlatb
xor

Unsupported directives

Other assemblers support directives that this assembler doesn't. The following is a list of directives that are ignored by the Watcom Assembler (use of these directives results in a warning message):

.alpha
.cref
.lfcond
.list
.listall
.listif
.listmacro
.listmacroall
.nocref
.nolist
page
.sall
.seq
.sfcond
subtitle
subttl
.tfcond
title
.xcref
.xlist

The following is a list of directives that are flagged by the Watcom Assembler (use of these directives results in an error message):

addr
.break
casemap
catstr
.continue
echo
endmacro
.endw
.exit
high
highword
invoke
low
lowword
lroffset
mask
opattr
option
popcontext
proto
purge
pushcontext
.radix
record
.repeat
.startup
this
typedef
union
.until
.while
width