summaryrefslogtreecommitdiff
path: root/as/as.doc
blob: 99273ef1c5f03ea3a4832d6e416d05e731d1f3c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
as options
----------

as [-03agjuw] [-b [bin]] [-lm [list]] [-n name] [-o obj] [-s sym] src

The 6809 version does not support -0, -3, -a or -j.

The 'src' file can be '-' for stdin but ONLY on 'big' machines.

defaults (off or none except for these; no output is produced without a flag):
-03		native
list		stdout (beware of clobbering next arg)
name		basename of the source name

-0  start with 16-bit code segment
-3  start with 32-bit code segment
-a  enable partial compatibility with asld
-g  only put global symbols in object or symbol file
-j  force all jumps to be long
-l  produce list file, filename may follow
-m  print macro expansions in listing
-n  name of module follows (goes in object instead of source name)
-o  produce object file, filename follows
-b  produce a raw binary file, filename may follow
-s  produce an ASCII symbol file, filename follows
-u  take undefined symbols as imported-with-unspecified segment
-w  don't print warnings

The -u and -w options are perhaps back to front because they are needed for
cc1 output and Minix's make does the wrong thing with .s files left around.
However, all assembler code not written by compilers should assemble with
them turned off.

The -b flag now produces a 'raw' binary file with no header, if there's no
-s flag the file starts at location 0. The -s generates an ASCII symbol
table, if a binary file doesn't start at location zero the first two items
are the start and end addresses of the binary file.

BCC is classed as a 'small' compiler, with this there is a maximum line
length of 256 characters.

Using GASP
----------

The Gnu assembler preprocessor provides some reasonable implementations
of user biased pseudo operations.

It can be invoked as:
   gasp [-a] ... file.s [file2.s ...] | as86 [...] - [-o obj] [-b bin]

Notes:
Gasp generates an error for '.org' commands if you're not using
'alternate' syntax you can use 'org' instead, otherwise use 'block'.

Export is translated in .global, if you are making a 'bin' file use
'public' or '.define' instead.

The GASP list options have no support in as86.

as source
---------

Conditionals:
   IF, ELSE, ELSEIF, ENDIF	Numeric condition
   IFC, ELSEIFC			String compare (str1,str2)
   FAIL .FAIL			Generate user error.

Segments:
    .TEXT .ROM .DATA .BSS
    .SECT	Follow with one of above
    LOC		Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 15=MAX

Lable type definition:
   Export label defined in this object:		EXPORT PUBLIC .DEFINE
   Force linker to include label in a.out:	ENTRY

   Define label as external or imported:	.GLOBL .GLOBAL
   Import list of externally defined labels:	EXTRN EXTERN IMPORT .EXTERN
   NB: Can't use imports in 'bin' files.

   Mark entry for old binary file (obs)		.ENTER

Data init
  1 byte:   	DB .DATA1 .BYTE  FCB
  2 byte:   	DW .DATA2 .SHORT FDB .WORD
  4 byte:   	DD .DATA4 .LONG
  String:   	.ASCII FCC
  String+Zero: 	.ASCIZ

Data uninit
    byte count:	.BLKB RMB .SPACE
    word count: .BLKW .ZEROW

Data Common
    COMM .COMM LCOMM .LCOMM

Alignment
    .ALIGN .EVEN

Misc
    EQU		Define label
    SET		Define re-definable label
    ORG .ORG	Set assemble location
    BLOCK	Set assemble location and stack old one
    ENDB	Return to stacked assemble location
    GET INCLUDE	Insert new file (no quotes on name)
    USE16	Define default operand size as 16 bit
    USE32	Define default operand size as 32 bit
    END		End of compilation for this file.
    .WARN	Switch warnings
    .LIST	Listings on/off (1,-1)
    .MACLIST	Macro listings on/off (1,-1)

Macros
    MACRO sax
       mov ax,#?1
    MEND
    sax(1)

Unimplemented/unused.
    IDENT	Define object identity string.
    SETDP	Set DP value on 6809
    .MAP	Set binary symbol table map number.

Registers
   BP BX DI SI
   EAX EBP EBX ECX EDI EDX ESI ESP
   AX CX DX SP
   AH AL BH BL CH CL DH DL
   CS DS ES FS GS SS 
   CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7
   TR3 TR4 TR5 TR6 TR7 ST

Operand type specifiers
   BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR


Instructions

AAA AAD AAM AAS ADC ADD AND ARPL BCC BCS BEQ BGE BGT BHI BHIS BLE BLO
BLOS BLT BMI BNE BOUND BPC BPL BPS BR BVC BVS CALL CALLF CALLI CBW CLC
CLD CLI CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CSEG CWD CWDE CDQ DAA DAS
DSEG DEC DIV ENTER ESEG FSEG GSEG HLT IDIV IMUL IN INC INS INSB INSD
INSW INT INTO INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JECXE JECXZ JE
JG JGE JL JLE JMP JMPF JMPI JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE
JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LDS LEA LEAVE LES LOCK LODB
LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ MOV MOVS
MOVSB MOVSD MOVSW MOVW MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW
OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR
ROL ROR REP REPE REPNE REPNZ REPZ RET RETF RETI SAHF SAL SAR SBB SCAB
SCAS SCASB SCASD SCASW SCAW SEG SHL SHR SSEG STC STD STI STOB STOS STOSB
STOSD STOSW STOW SUB TEST WAIT XCHG XLAT XLATB XOR

F2XM1 FABS FADD FADDP 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 FLD FLD1
FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX
FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM
FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT FST
FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP
FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1

BSF BSR BSWAP BT BTC BTR BTS CLTS CMPXCHG INVD INVLPG LAR LFS LGDT LGS
LIDT LLDT LMSW LSL LSS LTR MOVSX MOVZX 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 SIDT SHLD SHRD SLDT SMSW STR VERR VERW WBINVD XADD ADCB ADDB ANDB
CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB
RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB