File: crasm.1

package info (click to toggle)
crasm 1.4-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 340 kB
  • ctags: 379
  • sloc: ansic: 3,498; makefile: 63
file content (558 lines) | stat: -rw-r--r-- 11,845 bytes parent folder | download | duplicates (2)
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
.\" Copyright (C) 1987- Leon Bottou
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual. Otherwise check the web site
.\" of the Free Software Foundation at http://www.fsf.org.
.\"
.TH CRASM 1 "1/9/1987" "Crasm-1.3" "Crasm-1.3"
.de SS
.SH \\0\\0\\0\\$*
..
.SH NAME
crasm \- Cross assembler for 6800/6801/6803/6502/65C02/Z80

.SH SYNOPSIS
.BI "crasm [-o " "codefile" "] [-slx] " "asmfile"

Assemble the microprocessor program 
.I asmfile 
and produce output file 
.I codefile
in Intel HEX or Motorola S Code format.
A program listing and a symbol table are also produced
on the standard output.
The current version of
.B crasm
can assemble programs for the 
.BR 6800, 
.BR 6801, 
.BR 6803, 
.BR 6502, 
.BR 65C02, 
and
.BR Z80
processors.
The full list is printed when you invoke
.B crasm
without arguments.

.SH OPTIONS
.TP
.BI "-o " codefile
Specify the name of the output file.
No output file is produced without this option.
.TP
.BI "-s"
Disable warnings.
.TP
.BI "-l"
Disable program listing output.
.TP
.BI "-x"
Disable symbol table output.
.PP


.SH SYNTAX

Each line of the assembly program
should follow one of the following templates,
where the brackets delimit optional parts.
.IP ""
.BI "[;" comment "]"
.br
.BI "" label " = " expression " [;" comment "]"
.br
.BI "[" label "] " mnemonic " " operand " [;" comment "]"
.PP
Comments are introduced by a semicolon 
.BR "" "(" ";" ")"
and extend to the end of the line.
Labels are identifiers containing up to 36 alphanumeric 
characters (including period and underscore). Labels
cannot start with a digit.
The format of the mnemonics and operands 
field depends on the selected micro-processor.
A few mnemonics are valid for all processors
and are used to give directives to the assembled.
These are known as "pseudo-mnemonics".

.SS Labels

Labels are identifiers representing
.br
\(em an absolute address,
.br
\(em a relative address (position independent code),
.br
\(em a register,
.br
\(em a list of registers,
.br 
\(em a specific bit at a specific address,
.br
\(em or a mnemonic.
.PP
Most labels are composed of at most 36 alphanumeric characters,
periods
.BR "" "(" "." ")"
or
underscores
.BR "" "(" "_" ")."
Labels cannot start with a digit.  
They are case insensitive.
.PP
Labels starting with a period
.BR "" "(" "." ")"
are local labels whose scope is either limited
to the macro in which they are defined,
or to the code segment delimited by the pseudo-mnemonics
.B CODE
or
.BR DUMMY .
.PP
The predefined "star" label 
.BR "" "(" "*" ")"
represents the current program counter,
that is to say, the address where the next
assembly code instruction will be encoded.
Other predefined labels include all pseudo-mnemonics, 
micro-processor specific mnemonics and 
register names.


.SS Constants

The assembled recognizes numerical constants
expressed in decimal, hexadecimal, octal,
binary, or ascii.
.PP
.TS
center,box;
lfB lfB lfB
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l
l l l
.
Type	Format	Examples
=
decimal	\fIdddd	\fB1234\fR,\fB 675\fR,\fB 12\fR,\fB 1\fR, but not \fB0.12\fR.
=
hexadecimal	\fB$\fIdddd	\fB$fd12\fR,\fB $2AC\fR,\fB $0\fR.
	\fIdddd\fBH\fR	\fB03H\fR,\fB 2da7H\fR,\fB 0FC84H\fR, but not \fBFC84H\fR.
	\fB0X\fIdddd	\fB0x03\fR,\fB 0x2AC\fR,\fB 0Xfc84\fR.
=
octal	\fIdddd\fBQ\fR	\fB377Q\fR,\fB 012412Q\fR.
=
binary	\fB%\fIdddd	\fB%01110110\fR,\fB %1100\fR.
	\fIdddd\fBB\fR	\fB01110110B\fR,\fB 1100B\fR.
	\fB0B\fIdddd	\fB0b1100\fR
=
ascii	\fB'\fIcccc\fB'\fR	\fB'a'\fR,\fB 'AB'\fR,\fB '"'\fR,\fB '\\n'\fR,\fB '\\''\fR.
	\fB"\fIcccc\fB"\fR	\fB"\\t"\fR,\fB "\\""\fR,\fB "a'b"\fR.
.TE
.PP

.SS Expressions

Like labels, expressions can represent an absolute address
.RI ( abs ),
a relative address for position independent code
.RI ( rel ),
a register
.RI ( reg ),
or a list of registers
.RI ( reglist ),
or a reference to a specific bit at a specific address
.RI ( bspec ).

The following operators are recognized on expressions.
.TS
center,box;
lfB lfB lfB
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
l l l 
.
Syntax	Result	Description
=
 \fIabs\fB{\fIabs\fB}\fR	\fIbspec\fR	bit reference, e.g. \fBpia{3}\fR
 \fBADDR(\fIabs\fB)\fR	\fIabs\fR	address from a bit reference
 \fBBIT(\fIabs\fB)\fR	\fIabs\fR	bit number from a bit reference
=
 \fB- \fIabs	\fIabs\fR	two's complement
 \fB~ \fIabs	\fIabs\fR	one's complement
=
 \fIabs\fB << \fIabs\fR	\fIabs\fR	left shift
 \fIabs\fB >> \fIabs\fR	\fIabs\fR	right shift
=
 \fIabs\fB | \fIabs\fR	\fIabs\fR	bitwise or
 \fIabs\fB & \fIabs\fR	\fIabs\fR	bitwise and
 \fIabs\fB ^ \fIabs\fR	\fIabs\fR	bitwise xor
=
 \fIabs\fB * \fIabs\fR	\fIabs\fR	multiplication
 \fIabs\fB * \fIabs\fR	\fIabs\fR	division
=
 \fIabs\fB + \fIabs\fR	\fIabs\fR	addition
 \fIrel\fB + \fIabs\fR	\fIrel\fR	addition
 \fIabs\fB - \fIabs\fR	\fIabs\fR	subtraction
 \fIrel\fB - \fIabs\fR	\fIrel\fR	subtraction
 \fIrel\fB - \fIrel\fR	\fIabs\fR	subtraction
=
 \fIreg\fB - \fIreg\fR	\fIreglist\fR	register range
 \fIreglist\fB \\ \fIreg\fR	\fIreglist\fR	register list
.TE
.PP
The table lists operators in order of decreasing precedence.
Parenthesis can be used to avoid ambiguities.
A warning is generated when an entire expression is surrounded
with parenthesis and can be confused with a micro-processor addressing mode.
.PP
Examples:
.IP ""
\fB (base+$12) >> 8 & 0xff00 \fR
.br
\fB 'A'-80H \fR
.br
\fB (base+0x12) \fR
.PP
The last example causes a warning because the parenthesis
were not necessary and might suggest a micro-processor 
addressing mode.
.PP
All arithmetic expressions are evaluated on 32 bits.
Arithmetic operations overflow silently.
The arithmetic values are then truncated to the
size implied by the micro-processor mnemonic.
This truncation might cause a warning message.

Examples:
all the following instructions
.IP ""
(6502)	\fBlda #$1234\fR
.br
(6800)	\fBldaa $1234,x\fR
.br
(Z80)	\fBld (ix+0C2H),b\fR
.PP
cause a warning
.IP ""
.B >>> WARNING: Operand overflow
.PP
However expression
.IP ""
.B $1123454 * 1298992
.PP
overflows silently.

.SS Pseudo-mnemonics

The following pseudo-mnemonics are always recognized.

.PP
.BI "CPU " cpuname
.in +7n
Indicates the selected micro-processor type.
This must appear before anu micro-processor specific instruction.
The possible values of 
.I cpuname
are listed when you invoke
.B crasm
without arguments.
The current list includes
.BR 6800, 
.BR 6801, 
.BR 6803, 
.BR 6502, 
.BR 65C02, 
and
.BR Z80
.in -7n
.PP
.BI "OUTPUT " binformat
.in +7n
Indicates the format of the output file.
Argument 
.I binformat
can take values
.B SCODE
for producing an output file using Motorola's S code, or
.B HEX
for Intel's Hex format.
The default depends on the selected micro-processor.
.in -7n
.PP
.BI CODE
.in +7n
Delimit the scope of local labels
and introduce a program section.
.TP
.BI DUMMY
Delimit the scope of local labels
and introduce a fake program section
whose sole effect is to define labels
without generating code.
.in -7n
.PP
.BI "" label " EQU " expression 
.br
.BI "" label " = " expression
.in +7n
Define the value of label
.IR label .
Labels defined using these directives
can be redefined later in the program.
.in -7n
.PP
.BI "[" label "] DB " expression "[,...," expression "]"
.in +7n
Insert the specified data bytes (8 bits).
.in -7n
.PP
.BI "[" label "] DW " expression "[,...," expression "]"
.in +7n
Insert the specified data words (16 bits).
The byte ordering depends on the selected micro-processor.
.in -7n
.PP
.BI "[" label "] DL " expression "[,...," expression "]"
.in +7n
Insert the specified data longs (32 bits).
The byte ordering depends on the selected micro-processor.
.in -7n
.PP
.BI "[" label "] DDB " expression "[,...," expression "]"
.in +7n
Insert the specified double bytes (16 bits).
The byte ordering is the opposite of the usual
byte ordering for the selected micro-processor.
.in -7n
.PP
.BI "[" label "] ASC " stringconstant
.in +7n
Insert the ascii representation of the string
.I stringconstant .
The string must be delimited by double quotes.
The C escape sequences \fB\\r\fR, \fB\\n\fR, \fB\\t\fR, 
\fB\\0\fR, \fB\\'\fR, \fB\\"\fR, 
and \fB\\\\\fR are recognized.
.in -7n
.PP
.BI "[" label "] ASC " countexpr ",[" valexpr "]"
.in +7n
Insere
.I countexpr
bytes with value
.IR valexpr .	
The default value is zero.
.in -7n
.PP
.BI "[" label "] ALIGN EVEN"
.br
.BI "[" label "] ALIGN ODD"
.in +7n
Insert a null byte in order to make the program counter even or odd.
.in -7n
.PP
.BI "IF " condexpr
.br
 ...
.br
.BI "ELSE"
.br
 ...
.br
.BI "ENDC"
.in +7n
Conditional assembly:
If expression
.I condexpr
is non zero, 
process the lines located between the
.B IF
and the
.BR ELSE 
pseudo-mnemonics.
Otherwise process the lines located between the
.B ELSE
and the
.BR ENDC
pseudo-mnemonics.
Conditional assembly instructions can be nested. The 
.B ELSE 
part can be omitted.
.in -7n
.PP
.BI "" "label" " MACRO"
.br
        ...
.br
.BI "      ENDM"
.br
.in +7n
Define a new mnemonic 
.I label
equivalent to all the instructions located
between the 
.B MACRO
and
.B ENDM
pseudo-mnemonics.
Invocations of the macro can specify a list of comma 
separated operands.  The character sequences 
\fB\\1\fR, \fB\\2\fR, ... \fB\\\fIN\fR
in the macro definition are replaced by the supplied operands.
The character sequence \fB\\0\fR is replaced by the number
of supplied operands.
.in -7n
.PP
.BI "EXITM"
.in +7n
This pseudo mnemonic can be used inside a macro definition
to exit the macro.  This is useful in conjunction with
the conditional assembly pseudo-mnemonics.
.in -7n
.PP
.BI "INCLUDE " filename
.in +7n
Force the assembler to process file named
.I filename
at the current point.
.in -7n
.PP
.BR "LIST ON"
.br
.BR "LIST OFF"
.in +7n
Enable or disable the production of a listing
(default is on.)
.in -7n
.PP
.BR "CLIST ON"
.br
.BR "CLIST OFF"
.in +7n
Enable or disable the production of a listing
for the non active branches of a conditional assembly
construct (default is on.)
.in -7n
.PP
.BR "ILIST ON"
.br
.BR "ILIST OFF"
.in +7n
Enable or disable the production of a listing
for included files (default is off.)
.in -7n
.PP
.BR "MLIST ON"
.br
.BR "MLIST OFF"
.in +7n
Enable or disable the production of a listing
for the macro expansions (default is off.)
.in -7n
.PP
.BR "NAM " title
.in +7n
Provide name
.I title
for the header of the listing pages.
.in -7n
.PP
.BR "PAGE"
.in +7n
Start a new listing page.
.in -7n
.PP
.BR "PAGE " columns "," rows
.in +7n
Specify the size of a listing page.
.in -7n
.PP
.BR "SKIP " number
.in +7n
Skip
.I number
lines.
.in -7n
.PP
.BR "FAIL " message
.in +7n
Generate an error message
.IR message .
.in -7n
.PP

.SH EXAMPLE

.PP
Here is a small 6502 program:
.IP "" 2
\fB
     cpu 6502
.br
 cout = $fded ; display a character
.br
    * = $300  ; assemble at $300
.br
      code
.br
 pstring  ldy #0
.br
 .1       lda message,y
.br
          beq .2
.br
          jsr cout
.br
          iny          
.br
 .2       bne .1
.br
          rts
.br
 message  asc "This is the message\0"
.br
      code       
\fR
.PP    

.SH CREDITS

Leon Bottou, September 1987.