-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmacxx.html
More file actions
3368 lines (3350 loc) · 167 KB
/
Copy pathmacxx.html
File metadata and controls
3368 lines (3350 loc) · 167 KB
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
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- <link rel="stylesheet" href="style.css"> -->
<title>MACXX</title>
<style>
table {
border-collapse: collapse;
width: 50%;
}
th, td {
text-align: left;
padding: 2px;
}
tr:nth-child(even) {
background-color: #D6EEEE;
}
.TblCntr table
{
margin: 10px;
border:1px solid #000;
border-collapse: collapse;
width: 50%;
align: left;
}
.TblCntr tr
{
border: 2px solid white;
}
.TblCntr th
{
border: 2px solid white;
text-align: center;
padding: 2px;
}
.TblCntr td
{
border: 2px solid white;
text-align: center;
padding: 2px;
}
.TblCntr tr:nth-child(even)
{
background-color: #D6EEEE;
}
</style>
</head>
<body>
<div style="width: 25%;text-align:center;">
<h1>MACXX</h1>
MACxx Macro Assembler<br>
Version 10.28<br>
First created probably late 1977<br>
Revisions through Nov 1989 on the PDP11 assembly version<br>
Revisions through Aug 2022 on the C version<br>
</div>
<p></p>
<div style="border: 2px solid black;margin:4px;padding: 4px">
<em>Note from Dave Shepperd, 8/2022
<p>
There never were any release notes kept on this application so there is no record of what got changed when. It just is what it is.
I wrote the PDP11/RT11 version in the late 1970's and the current C version in the early to mid 1980's. It continued to get development until the late 1990's
and continues to get bug fixes and new features to this day.
</p>
<p>
Recently I got involved in rebuilding some of old Atari coin-op game code (some of which recently
was released on github) and wanted to use this tool to make ROM/EPROM images and to test them with MAME. This prompted me to port the documentation,
what little there is, of the three main applications used to build game images to HTML. Those tools are the assembler
(<a href="https://github.com/DaveShepperd/macxx.git" target="_blank">MACXX</a>),
linker (<a href="https://github.com/DaveShepperd/llf.git" target="_blank">LLF</a>) and rom image maker
(<a href="https://github.com/DaveShepperd/mixit.git" target="_blank">MIXIT</a>).
Although I wrote the original documentation for this assembler (macxx.doc which was the basis for this document), I am neither a technical
writer nor am I any good at HTML5. As might be evidenced
with the original documentation, I quickly lose interest in writing technical documents and don't check things too closely. So good luck
making sense of anything written here. Feel free to hack this document into something more readable. If you do, please send me a copy.
</p>
<p>If one cares, I wrote a little history about how this assembler and the other two tools came to be. It can be found
<a href="#history">HERE</a>.
</p>
</em>
</div>
<p>
MACxx is an assembler first written in PDP11 assembly language for a computer running RT11 (RT11 version 2 or 3, I don't recall which).
Later it was rewritten in the C language and has been ported to various operating systems. The RT11 version was implemented as a 2 pass
assembler. The current C version is a 1.5 pass assembler meaning it makes one pass through the source code producing both a listing and
an intermediate internally maintained binary object "file". Once all the souce has been parsed, it makes another pass through its internally
maintained object "file" resolving all expressions it is able to and producing the actual binary or ASCII object file. As of version 11.??
a new command line option of <a href="#CMD_2_PASS">2_PASS</a> can be used to force the assembler to run in a full 2 pass mode. But that option is only available for mac65,
mac68 and mac69.
</p>
<p> The macxx sources produce a unique macro assembler for the following processors:
</p>
<pre>
<b>macpp</b> - A macro pre-processor; no CPU; it works similar to the C language's CPP.
<b>mac65</b> - For the MOS Technology 6502 <!--and 65C02 CPU's-->CPU
<b>mac68</b> - For the Motorola 6800 CPU
<b>mac69</b> - For the Motorola 6809 CPU
<b>mac68k</b> - For the Motorola 68000 and 68010 CPU
<b>mac8080</b> - For the Intel 8080 CPU
<b>macz80</b> - For the Zilog Z80 CPU
<b>mac11</b> - For the PDP11 CPU (specifically the T11 used by Atari)
<b>macas</b> - For the custom Atari Simplified Architecure Processor (ASAP) CPU
<b>mactj</b> - For the Atari custom Tom and Jerry DSP's
</pre>
<p>
<b>Macxx</b> consists of a core group of pseudo-ops
common among all versions of the assembler and a common statement syntax. The output of these assemblers
(except <b>MACPP</b>) is expected to be further processed by <b>LLF</b> into a load image. <b>LLF</b> is
yet another tool I wrote that is a link+locate+format editor. <b>LLF</b> may be found <a href="https://github.com/DaveShepperd/llf.git" target="_blank">HERE</a>.
</p>
<p><em>NOTE: There may be some obscure bug in these sources somewhere where if you build it as a 64 bit application, it
makes some obscure mistake. I'm not sure about this, I've only heard about it from someone who complained. I haven't
looked into it further. It was just too easy to build with -m32 and forget about it. User beware.
</em>
</p>
<h2>Table of contents</h2>
<table style="width: 50%">
<tr><th>Directive</th><th>Description</th></tr>
<tr><td><a href="#gen_syntax">Statement syntax</a></td><td>General statement syntax</td></tr>
<tr><td><a href="#gen_label">Labels</a></td><td>Labels versus symbols</td></tr>
<tr><td><a href="#Direct_assignments">Symbols</a></td><td>Symbols versus labels</td></tr>
<tr><td> </td><td> </td></tr>
<tr><td><a href="#dir_dc">DB</a></td><td>Put constants in memory (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_ascix">DC</a></td><td>Put constants in memory (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_dc">DC.x</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_dcb">DCB.x</a></td><td>Fill memory witn constants</td>
<tr><td><a href="#dir_blkx">DS.x</a></td><td>Allocation storage</td>
<tr><td><a href="#Direct_assignments">EQU</a></td><td>Define symbol (mac8080 and macz80 only; same as = )</td>
<tr><td><a href="#Direct_assignments">DEFL</a></td><td>Define symbol (mac8080 and macz80 only; same as := )</td>
<tr><td><a href="#dir_blkx">DEFS</a></td><td>Define storage (mac8080 and macz80 only; see .blkb)</td>
<tr><td><a href="#dir_dcb">DEFB</a></td><td>Put constant bytes in memory (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_byte">DEFW</a></td><td>Put constant words in memory (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_if">IFEQ, IFNEQ, IFDEF, IDNDEF, ELSE, ENDIF</a></td><td>Conditional assembly (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_globl">XDEF, XREF</a></td><td>Assign symbol(s) as being global in scope</td>
<tr><td><a href="#dir_byte">.ADDRESS</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_align">.ALIGN</a></td><td>Align location counter</td>
<tr><td><a href="#dir_ascix">.ASCII, .ASCIN, .ASCIZ</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_psect">.ASECT, .BSECT, .CSECT</a></td><td>Set program section</td>
<tr><td><a href="#dir_blkx">.BLKx</a></td><td>Allocation of storage</td>
<tr><td><a href="#dir_byte">.BYTE, .WORD, .LONG</a></td><td>Put constants in memory</td>
<!-- <tr><td><a href="#dir_cpu">.CPU</a></td><td>65816 specific instruction</td> -->
<tr><td><a href="#dir_define">.DEFINE, .UNDEFINE</a></td><td>Define/Undefine some replacement text</td>
<tr><td><a href="#dir_defstack">.DEFSTACK</a></td><td>Define a user stack</td>
<!-- <tr><td><a href="#dir_dpage">.DPAGE</a></td><td>65816 specific instruction</td> -->
<tr><td><a href="#dir_enabl">.ENABL, .DSABL</a></td><td>Enable/Disable assembler functions</td>
<tr><td><a href="#dir_end">END</a></td><td>End of assembly (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_end">.END</a></td><td>End of assembly</td>
<tr><td><a href="#dir_endm">.ENDM</a></td><td>End of macro</td>
<tr><td><a href="#dir_endm">.ENDR</a></td><td>End of indefinite repeat blocks</td>
<tr><td><a href="#dir_if">.ENDC</a></td><td>End of conditional assembly block</td>
<tr><td><a href="#dir_if">ENDIF</a></td><td>End of conditional assembly block (mac8080 and macz80 only)</td>
<tr><td><a href="#dir_error">.ERROR</a></td><td>Signal an assembly error</td>
<tr><td><a href="#dir_escape">.ESCAPE</a></td><td>Set various escape characters</td>
<tr><td><a href="#dir_even">.EVEN</a></td><td>Align location counter</td>
<tr><td><a href="#dir_float">.FLOAT</a></td><td>Tom&Jerry specific instruction</td>
<tr><td><a href="#dir_getpointer">.GETPOINTER</a></td><td>Get a user's stack pointer</td>
<tr><td><a href="#dir_globl">.GLOBx</a></td><td>Assign symbol(s) as being global in scope</td>
<tr><td><a href="#dir_if">.IF, .IFx, .IFF, .IFT, .IFTF, .ENDC, .IIF</a></td><td>Conditional assembly</td>
<tr><td><a href="#dir_include">.INCLUDE</a></td><td>Include another file during assembly starting with this line</td>
<tr><td><a href="#dir_irp">.IRP, .IRPC</a></td><td>Indefinite repeat blocks</td>
<tr><td><a href="#dir_ldlit">.LDLIT</a></td><td>ASAP specific instruction</td>
<tr><td><a href="#dir_length">.LENGTH</a></td><td>Set length of symbol, opcode or MAU</td>
<tr><td><a href="#dir_list">.LIST, .NLIST</a></td><td>Enable/Disable listing controls</td>
<tr><td><a href="#dir_byte">.LONG</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_macro">.MACRO</a></td><td>Macro definition</td>
<tr><td><a href="#dir_byte">.MAU, .2MAU, .4MAU</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_mexit">.MEXIT</a></td><td>Macro exit</td>
<tr><td><a href="#dir_narg">.NARG</a></td><td>Get number of macro arguments</td>
<tr><td><a href="#dir_nchr">.NCHR</a></td><td>Get number of characters in string</td>
<tr><td><a href="#dir_list">.NLIST</a></td><td>Disable listing controls</td>
<tr><td><a href="#dir_even">.ODD</a></td><td>Align location counter</td>
<tr><td><a href="#dir_outfile">.OUTFILE</a></td><td>Change output file (MACPP only)</td>
<tr><td><a href="#dir_page">.PAGE</a></td><td>Put form feed in listing</td>
<tr><td><a href="#dir_pop">.POP</a></td><td>Pop a value from a user stack</td>
<tr><td><a href="#dir_print">.PRINT</a></td><td>Print text on line printer output</td>
<tr><td><a href="#dir_psect">.PSECT</a></td><td>Set program section</td>
<tr><td><a href="#dir_push">.PUSH</a></td><td>Push an expression onto a user stack</td>
<tr><td><a href="#dir_radix">.RADIX</a></td><td>Set number interpreter radix</td>
<tr><td><a href="#dir_restore">.RESTORE</a></td><td>Restore location counter from a previous .SAVE</td>
<tr><td><a href="#dir_rept">.REPT</a></td><td>Repeat block</td>
<tr><td><a href="#dir_mexit">.REXIT</a></td><td>Repeat block exit</td>
<tr><td><a href="#dir_save">.SAVE</a></td><td>Save the current location counter</td>
<tr><td><a href="#dir_sbttl">.SBTTL</a></td><td>Set a subtitle</td>
<tr><td><a href="#dir_setpointer">.SETPOINTER</a></td><td>Set the user stack's pointer</td>
<tr><td><a href="#dir_sqoff">.SQOFF</a></td><td>Turn squeak off (used for macxx internal debugging)</td>
<tr><td><a href="#dir_sqon">.SQON</a></td><td>Turn squeak on (used for macxx internal debugging)</td>
<tr><td><a href="#dir_stabx">.STABx</a></td><td>Pass stab debug directives through to object file</td>
<tr><td><a href="#dir_ascix">.STRING</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_globl">.STATIC</a></td><td>Assign symbol(s) as being static in scope</td>
<tr><td><a href="#dir_sbttl">.SUBTITLE</a></td><td>Set a subtitle (same as .SBTTL)</td>
<tr><td><a href="#dir_test">.TEST</a></td><td>Perform a test on an expression</td>
<tr><td><a href="#dir_title">.TITLE</a></td><td>Set the title for the pages in the listings</td>
<tr><td><a href="#dir_triplet">.TRIPLET</a></td><td>MAC65 only; Put 24 bit variables in memory</td>
<tr><td><a href="#dir_undefine">.UNDEFINE</a></td><td>Undefine some replacement text</td>
<tr><td><a href="#dir_vctrs">.VCTRS</a></td><td>Place 15 bit vectors in the object file</td>
<tr><td><a href="#dir_warn">.WARN</a></td><td>Signal an assembly warning</td>
<tr><td><a href="#dir_byte">.WORD</a></td><td>Put constants in memory</td>
<tr><td><a href="#dir_globl">xref, xref.s</a></td><td>Assign symbol(s) as being global in scope</td>
<tr><td> </td><td> </td></tr>
<tr><td><a href="#gen_macros">Macros</a></td><td>How to use macros</td>
<tr><td> </td><td> </td></tr>
<tr><td><a href="#gen_operating">Operating MACXX</a></td><td>How to run MACXX</td>
<tr><td> </td><td> </td></tr>
<tr><td><a href="#Appendix">Appendix</a></td><td></td>
<tr><td> </td><td> </td></tr>
<tr><td><a href="#macxx_specials">MACXX specials</a></td><td>Some specifics to several macxx assemblers</td>
<tr><td><a href="#mac65_specials">MAC65 specials</a></td><td>Unique features to mac65</td>
<tr><td><a href="#macpp_specials">MACPP specials</a></td><td>Unique features to macpp</td>
<tr><td><a href="#mac68k_specials">MAC68K specials</a></td><td>Unique features to mac68k</td>
<tr><td><a href="#macas_specials">MACAS specials</a></td><td>Unique features to macas</td>
<tr><td><a href="#mac11_specials">MAC11 specials</a></td><td>Unique features to mac11</td>
<tr><td><a href="#mactj_specials">MACTJ specials</a></td><td>Unique features to mactj</td>
<tr><td><a href="#mac8080_specials">MAC8080 specials</a></td><td>Unique features to mac8080</td>
<tr><td><a href="#macz80_specials">MACZ80 specials</a></td><td>Unique features to macz80</td>
<tr><td> </td><td> </td></tr>
<tr><td><a href="#history">History</a></td><td>A bit of history</td>
</table>
<h2 id="gen_syntax">Statement syntax</h2>
<p>
A source program is composed of a sequence of source lines; each
source line contains a single assembly language statement followed by a
terminator (line feed or form feed). Input lines are limited to 255
characters.
</p>
<p>
A statement can contain up to four fields which are identified by order
of appearance and by specified terminating characters. The general
format of a MACxx assembly statement is:
</p>
<pre>
[label:] [opcode [operand(s)]] [;comments]
</pre>
<p>
Items shown surrounded with []'s are optional.
The label is delimited by one or two
colon characters (:) and the semicolon (;) delimits the comments. White space
may be required to delimit the opcode from the operand and multiple
operands may need either a comma (,) or white space to delimit them from
one another but otherwise, white space is optional.
</p>
<h3 id="gen_label">Label field</h3>
<p>
A label is a user defined symbol that is unique to the first n characters
(various assemblers have various defaults for 'n' but the value for 'n'
may be changed to any number up to 32 with a command line option or asssembler
directive) and is
assigned to the value of the current location counter and entered into
the user symbol table (as opposed to the 'permanent' symbol table). The
value may be either absolute (fixed at a specific location in memory at
assembly time) or relocatable (fixed at a specific location at link or
load time). This depends on whether the current section is absolute or
relocatable. A label is a symbolic method of referring to a specific place
in memory. If present, a label must be first in the statement and
terminated with a colon. For example:
</p>
<pre>
FRED: LDA FOOBAR
</pre>
<p>
defines FRED to point to the location in memory of the LDA instruction.
More than one label can appear on a single statement, however, each
will be given the same value. For example:
</p>
<pre>
ONE: TWO: THREE: LDA FOOBAR
</pre>
<p>
defines ONE, TWO and THREE to point to the location in memory of the LDA
instruction. A symbol used as a label may not be redefined and any
attempt to do so will result in an error message. If two colon
characters are used to delimit the label, then the label is defined
as a global. Global labels are inserted into the object file so that
LLF and, subsequently, other modules will be able to reference them
by name. For example:
</p>
<pre>
FRED:: LDA FOOBAR ;fred is defined and also made global
</pre>
<p>
Internal symbols may belong to the current program section or to other
program sections. Expressions containing symbols belonging to different
program sections may not be completely resolved by the assembler.
Depending on the type of operation that is required in the expression,
it may not be possible for the assembler to resolve an expression
regardless of which section a symbol belongs. In these cases, the
expression will be passed to the separate <b>LLF</b> (custom Link+Locate+Format)
program to be resolved after all the sections
have been relocated and labels defined to their ultimate values.
</p>
<h3 id="gen_opcode">Opcode field</h3>
<p>
The opcode field contains an opcode, macro name or assembler directive
(pseudo-op). Is is legally terminated by white space or any
non-alphanumeric character. For example:
</p>
<pre>
LDA #FRED ;the white space delimits the opcode
LDA#FRED ;the # delimits the opcode
</pre>
<h3 id="gen_operands">Operand field</h3>
<p>
The operand field contains zero, one or more items that may be separated
by commas or white space depending on the requirements of the opcode,
macro or pseudo-op. The operand field is terminated by the semicolon of
an optional comment or an end-of-line. For example:
</p>
<pre>
CLC ;no operands are required
LDA FRED ;FRED is the operand
LDA FRED,X ;FRED and X are operands to the LDA opcode
</pre>
<h3 id="gen_comments">Comment field</h3>
<p>
The comment field is optional and may contain any printing ASCII
character as well as tab and space. All other non-printing ASCII
characters except new-line will be converted to white space. The
comment begins with a semicolon (;) which may appear anywhere on the
line and continues to end-of-line. The contents of comments are
ignored by the assembler.
</p>
<h3 id="gen_formatting">Formatting</h3>
<p>
Spaces, tabs and form feeds may be used at will to control the text
formatting in the source file. A form feed character is interpreted as
a new line. Except in certain contexts (such as ASCII constants and
parameter delimiting) white space is ignored by the assembler.
</p>
<h4>Symbols</h4>
<p>
Assembler symbols, labels and macro names can be comprised of any of the
letters A through Z (upper and/or lower case), digits 0 through 9,
period (.), dollar sign ($) and underscore (_). The first character of a
symbol or label must not be a digit except in the special case of local symbols
described HERE. The case of the letters in a symbol
is not significant unless the .ENABL LOWER option has been selected. For
example:
</p>
<table class="TblCntr" style="width: 20%">
<tr><th>Valid symbols</th><th>Invalid symbols</th></tr>
<tr><td>ABC</td><td>0123</td></tr>
<tr><td>abc</td><td>2abc</td></tr>
<tr><td>$._AB_C.$$</td><td>9$AB_.</td></tr>
</table>
<p>
The symbol length is, by default, significant to the first 'n' characters
only. The default value for 'n' varies from assmbler to assembler however
it may be changed via a command line option or an assembler directive.
In either case the significant length cannot be
reduced to less than 6 nor made greater then 32. Symbols output in the
object file will be uppercased (unless the .ENABL LOWER option has been
selected; its default varies from assembler to assembler) and truncated
to the significant length. Symbols are delimited
by any character that is not included in the list of valid symbol
characters. Be advised that not all load file formats accept symbol names
as long as 32 characters. Extended TEKhex, for example, will only pass
the first 16 characters of a symbol name. This will only be a
significant factor if one intends on passing global symbols with long
names to a symbolic debugger via a restricting load file format.
</p>
<h4>Permanent symbols</h4>
<p>
Permanent symbols are those pre-defined in the assembler and consist
entirely of opcodes and pseudo-ops. The assembler allocates memory from
the operating system and "seeds" this area with the permanent symbols
stored internal to the assembler. Macro names that are defined by the
user are placed into the permanent symbol table perhaps replacing an
existing entry.
</p>
<h4>User defined symbols</h4>
<p>
User symbols both ordinary and local are stored in a user symbol table.
This symbol table is the only one searched during expression evaluation.
The permanent symbol table is the only one searched for opcodes.
Consequently, macro and opcode names may be the same as symbol and label
names and each represents different values.
</p>
<p>
User defined symbols are either internal or external (global). All user
defined symbols are internal unless explicitly declared otherwise.
</p>
<p>
Look <a href="#Direct_assignments">HERE</a> for details and examples
on how to assign symbol values.
</p>
<p>
<a href="#mac11_specials">MAC11</a>,
<a href="#mac68k_specials">MAC68K</a>,
<a href="#mac8080_specials">MAC8080</a>
<a href="#macz80_specials">MACZ80</a>
and <a href="#macas_specials">MACAS</a>
have predefined user symbols representing the standard
register names found in those processors. See the links appendix for specifics.
</p>
<h4 id="gen_localSymbols">Local symbols</h4>
<p>
There's a special type of symbol known as a local symbol. This symbol
is a string of decimal digits terminated with a dollar sign. Its
presence is known only within what is known as a local symbol block (LSB).
The LSB is delimited, unless otherwise indicated, with
changes in program sections or by the definition of a new label.
Local symbols can be used anywhere ordinary symbols can be used and are
defined the same as ordinary symbols. They cannot, however, be declared
global. Local symbols must consist only of the digits 0-9 and a
trailing dollar sign, but otherwise they are treated as ordinary strings
and are limited in length to the maximum input size of 255 characters.
Some examples:
</p>
<pre>
lsb_1: ;Any label starts a new local symbol block
10$: ;defines local symbol 10$
20$ = fred ;direct assignments work too,...
LABEL = fred ; ...however, direct assignments do NOT open a new LSB
30$: ;another local label
lsb_2: ;Opens a new LSB
10$: ;these local symbols are not the same as
20$: ; the other ones because they are in a
30$: ; different LSB.
.PSECT ;this opens a new local symbol block too
</pre>
<p>
There may be instances where one needs to reference local symbols
across ordinary labels or through program section changes. This can be
accomplished with a pseudo-op:
</p>
<pre>
.ENABL LSB ;opens a LSB and turns OFF
; the normal lsb delimiter sensing.
10$: ;defines a local symbol
LABEL: ;in this case, does NOT open a new lsb
.WORD 10$ ;refers to the 10$ above LABEL
.DSABL LSB ;closes the LSB and turns back ON
; then normal lsb delimiter sensing.
</pre>
<h4>Location counter symbol</h4>
<p>
There's a special pre-defined symbol, period (.), that refers to
the current location counter. The special symbol '$' can be made
a duplicate of a '.' with '.ENABL DOLLAR_PC'.
The value of this symbol is always defined
and may be relocatable or absolute depending on the attribute of the
current section. The period may not be used as a label. It may only be
used in expressions and as the target of a direct assignment statement.
For example:
</p>
<pre>
saved_place = . ;saves current location
. = some_new_place ;set the current location to new place
offset = <.+3>/4 ;compute displacement
</pre>
<p>
Care must be used when making direct assignments to the location counter
or there will certainly be unexpected results. For example, there are
times when one wants to position the location counter to a fixed
location from the beginning of a RELOCATABLE program section. This
CANNOT be done by simply assigning the location counter to the offset.
Suppose one wants to set the location counter to an offset of 1000 from
the start of section DATA. First a symbol would have to be defined at
the beginning of the DATA section:
</p>
<pre>
.PSECT DATA ;declare section DATA
START_OF_DATA: ;define first location of section DATA
</pre>
<p>
Then the location counter can be set:
</p>
<pre>
. = START_OF_DATA+1000 ;move PC to DATA+1000.
</pre>
<p>
The more direct approach of .=1000 is only allowed when the current
location is an absolute (non-relocatable) section. Direct assignments
that would result in having the current section change are not allowed
and will result in an error message. For example:
</p>
<pre>
.PSECT TEXT
FRED:
.PSECT DATA
. = FRED ;will result in an error since FRED
; is not in the DATA psect
</pre>
</p>
<!-- Does not work so just don't tell anybody about it
<h4>Symbol blocks</h4>
<p>
Another form of local symbol block exists which allows for all forms of
symbols to appear "local to the block". That is, symbols and labels
defined within a symbol block can only be referenced by code and data
appearing within that block or a fully enclosed block. These blocks can
be nested to a depth of 7. Nested levels beyond 7 are folded into
level 7 and a warning message stating that the scoping is too deep is
displayed. Inner blocks may reference symbols and labels defined in an
outer block, but outer blocks may not reference symbols and labels
defined in inner blocks. The outer most level is 0 and is the level
used by normal symbols and labels. There are a maximum of 8192 blocks
available in a single assembly module. This block is delimited between
the pseudo ops .PROC and .ENDP. For example:
</p>
<pre>
.PROC ;This opens a local symbol block
FRED: ;This defines a local version of FRED
FOOBAR = 123 ;It works for both labels and symbols
.WORD FRED ;The symbol can be used in the block
.ENDP
.WORD FRED ;This will produce an error since FRED is unknown
.WORD FOOBAR ;This will error out too
</pre>
<p>
WHEN USING SYMBOL BLOCKS, FORWARD REFERENCES TO SYMBOLS OR LABELS ARE
NOT ALLOWED. All symbols and labels referenced in the current block must
be predefined or predeclared. There is a .LOCAL directive to declare a
symbol and/or label in a block if it is referenced before it is defined.
</p>
-->
<h4>Radix</h4>
<p>
The programmer can specify the radix with which a number is to be
interpreted on each number appearing in the source or globally for all
numbers appearing in the source. The radix values can be one of 2,8,10
or 16. Using the .RADIX pseudo-op specifies which radix to use for all
numbers appearing between that directive and the next .RADIX or end of
file. The unary operators ^B, ^O, ^D (or trailing period), ^X or ^H
can be used on individual numbers to indicate the radices 2, 8, 10, 16
or 16 respectively.
</p>
<h4>Numbers</h4>
<p>
Number constants are strings consisting of the digits 0-9 and the
letters A-F. The first character of the number must be a digit 0-9
regardless of the current radix. Any character not of that character set
delimits the number. If the number contains digits that are greater than
the current radix allows, the assembler will attempt to evaluate the
number at the appropriate higher radix and displays an error message. A
temporary decimal radix can be set by appending a period to the number
or any other temporary radix can be set via a one of the unary operators
(^B, ^D, ^O, ^X or ^H for binary, decimal, octal, hex or hex respectively).
In addition, hexadecimal numbers may be expressed by
prefixing a "0x" or "0X" to them. If the H_HEX option is <a href="#dir_enabl">.ENABL</a>'d, then
an 'h' or 'H' suffix will denote the number as hex. If the O_OCTAL or Q_OCTAL
is <a href="#dir_enabl">.ENABL</a>'d, then a 'o' or 'O' or 'q' 'Q' respective suffix will
denote the number as octal. If the DOLLAR_HEX is <a href="#dir_enabl">.ENABL</a>'d,
then a prefixed '$" will denote the number as hex.
<br>
For example:
</p>
<pre>
0110 ;valid binary, octal, decimal or hex number
1234 ;valid octal, decimal or hexadecimal number
7890 ;valid decimal or hexadecimal number
0FFF ;valid hex number
A000 ;not a valid number (valid symbol, though)
1000. ;decimal 1000
0x1234 ;hexadecimal number
^X1234 ;hexadecimal number
<a href="#dir_enabl">.ENABL</a> H_HEX
0AAAH ;hexadecimal number (Note: Still have to prefix a 0-9)
<a href="#dir_enabl">.ENABL</a> DOLLAR_HEX
$AAA ;hexadecimal number (Note: No leading 0-9 required)
<a href="#dir_enabl">.ENABL</a> O_OCTAL
1234o ;octal number
</pre>
<h3 id="gen_expressions">Expressions</h3>
<p>
An expression is a collection of one or more terms separated by
arithmetic operators. There are both unary operators (apply only to a
single term) and binary operators (apply to two terms). Unlike most
other languages, and except for mac8080 and macz80 (see below), all operators have equal precedence and are evaluated
from left to right. The order of evaluation can be changed by the use of
the parenthesis. (In MAC65, MAC68, MAC69 and MAC11, the parenthesis must be substituted with the
expression brackets "<" and ">"). All terms in an expression and the
result of the expression itself are 32 bits (signed). The relational
operators (not available in MAC65, MAC68, MAC69 and MAC11) return either a 0 for false or 1 for
true.
</p>
<table style="width: 30%">
<tr><th>Binary operators</th><th>Examples</th><th>Meaning</th></tr>
<tr><td> +</td><td>A+B</td><td>A added with B (can also be +A which means 0+A)</td></tr>
<tr><td> -</td><td>A-B</td><td>A subtracted with B (can also be -A which means 0-A)</td></tr>
<tr><td> *</td><td>A*B</td><td>A multiplied by B (32 bit product)</td></tr>
<tr><td> /</td><td>A/B</td><td>A divided by B (returns a 32 bit quotient)</td></tr>
<tr><td> &</td><td>A&B</td><td>A logically anded with B</td></tr>
<tr><td> |</td><td>A|B</td><td>A logically or'ed with B</td></tr>
</table>
<p>
The following are <u><b>NOT</b></u> available in MAC65, MAC68, MAC69 and MAC11 but are available in the others:
</p>
<table style="width: 30%">
<tr><th>Binary operators</th><th>Examples</th><th>Meaning</th></tr>
<tr><td> ^</td><td>A^B</td><td>A exclusive or'ed with B</td></tr>
<tr><td> <<</td><td>A<<B</td><td>A shifted B bits left</td></tr>
<tr><td> >></td><td>A>>B</td><td>A shifted B bits right</td></tr>
<tr><td> ==</td><td>A==B</td><td>returns 1 if A equals B</td></tr>
<tr><td> !=</td><td>A!=B</td><td>returns 1 if A not equal B</td></tr>
<tr><td> ></td><td>A>B</td><td>returns 1 if A greater than B</td></tr>
<tr><td> <</td><td>A<B</td><td>returns 1 if A less than B</td></tr>
<tr><td> >=</td><td>A>=B</td><td>returns 1 if A greater than or equal to B</td></tr>
<tr><td> <=</td><td>A<=B</td><td>returns 1 if A less than or equal to B</td></tr>
</table>
<p>
The following are available <u><b>ONLY</b></u> in MAC65, MAC68, MAC69 and MAC11 (this was chosen to keep compatible with the syntax of the very old RT11 version of MACxx):
</p>
<table style="width: 30%">
<tr><th>Binary operators</th><th>Examples</th><th>Meaning</th></tr>
<tr><td> !</td><td>A!B</td><td>A logically or'ed with B (same as |)</td></tr>
<tr><td> ?</td><td>A?B</td><td>A exclusive or'ed with B (same as ^ in other assemblers)</td></tr>
<tr><td> {</td><td>A{B</td><td>A is shifted B bits left (same as << in other assemblers)</td></tr>
<tr><td> }</td><td>A}B</td><td>A is shifted B bits right (same as >> in other assemblers)</td></tr>
</table>
<p>
Unary operators are escaped with a circumflex (^) which means the character
following the circumflex is the operator. In order for this to be noticed and not confused with the exclusive or
binary operator, the circumlex must appear as the first character of a term. But one would be wise to watch
for any potential confusion in this regard. I.E. A^^^B looks confusing, but it means exclusive or A with the high
byte of B.
</p>
<table style="width: 30%">
<tr><th>Unary operators</th><th>Examples</th><th>Meaning</th></tr>
<tr><td> ^C</td><td>^C A</td><td>returns 1's compliment of A</td></tr>
<tr><td> ^B</td><td>^B 100</td><td>change radix of term to 2 (binary; number is 0x004)</td></tr>
<tr><td> ^D</td><td>^D 100</td><td>change radix of term to 10 (decimal; number is 0x064)</td></tr>
<tr><td> ^H</td><td>^H 100</td><td>change radix of term to 16 (hexadecimal; number is 0x100)</td></tr>
<tr><td> ^O</td><td>^O 100</td><td>change radix of term to 8 (octal; number is 0x40)</td></tr>
<tr><td> ^X</td><td>^X 100</td><td>change radix of term to 16 (hexadecimal; number is 0x100)</td></tr>
<tr><td> ^V</td><td>^V A</td><td>returns low byte: bits 7-0 of A</td></tr>
<tr><td> ^^</td><td>^^ A</td><td>returns high byte: bits 15-8 of A</td></tr>
<tr><td> ^~</td><td>^~ A</td><td>returns bits 15:8 swapped with bits 7:0 and bits 23-16 with bits 31-24 of A</td></tr>
</table>
<p>
MAC8080 and MACZ80 is different in that the expression operators do have precedence. However, the precedence can be made
the same as the others with a '.DSABL PRECEDENCE'. The operator precedences are listed below. Higher numbers
indicate higher precedence. Terms with equal precedence are processed left to right.
</p>
<table style="width: 30%">
<tr><th>Operator</th><th>Precedence</th><th>Description</th></tr>
<tr><td>Symbol</td><td>20</td><td>Symbol name</td></tr>
<tr><td>Integer</td><td>20</td><td>Number</td></tr>
<tr><td>-</td><td>18</td><td>Negative term (as opposed to a subtract)</td></tr>
<tr><td>+</td><td>18</td><td>Positive term (as opposed to an add)</td></tr>
<tr><td>~</td><td>18</td><td>1's compliment</td></tr>
<tr><td>!</td><td>18</td><td>Not (relational)</td></tr>
<tr><td>^?</td><td>16</td><td>All unaries defined by leading circumflex</td></tr>
<tr><td>*</td><td>14</td><td>Multiply</td></tr>
<tr><td>/</td><td>14</td><td>Divide</td></tr>
<tr><td>%</td><td>14</td><td>Modulo</td></tr>
<tr><td>+</td><td>12</td><td>Add</td></tr>
<tr><td>-</td><td>12</td><td>Subtract</td></tr>
<tr><td>>></td><td>10</td><td>Shift left</td></tr>
<tr><td><<</td><td>10</td><td>Shift right</td></tr>
<tr><td>></td><td>8</td><td>Greater than</td></tr>
<tr><td>>=</td><td>8</td><td>Greater or equal</td></tr>
<tr><td><</td><td>8</td><td>Less than</td></tr>
<tr><td><=</td><td>8</td><td>Less or equal</td></tr>
<tr><td>=</td><td>8</td><td>Equal</td></tr>
<tr><td>!=</td><td>8</td><td>Not equal</td></tr>
<tr><td>&</td><td>6</td><td>And</td></tr>
<tr><td>^</td><td>5</td><td>Xor</td></tr>
<tr><td>|</td><td>4</td><td>Or</td></tr>
<tr><td>&&</td><td>3</td><td>Logical and</td></tr>
<tr><td>||</td><td>2</td><td>Logical or</td></tr>
</table>
<p>
Any term of an expression may be enclosed in a pair of expression
brackets ('<' and '>' in MAC65, MAC68, MAC69 and MAC11 or '(' and ')' in the other assemblers)
and itself be a collection of one or more terms. For example:
</p>
<pre>
A+<<B*C/D+6>*100>/4?^V<FRED*10>+^H<0FFF+ABC+1234> ;MAC6x and MAC11
A+((B*C/D+6)*100)/4^^V(FRED*10)+^H(0FFF+ABC+1234) ;others
</pre>
<p>
would evaluate in the following order (left to right, all operators having
equal precedence):
</p>
<pre>
B*C/D+6*100+A/4 exclusive OR'd with the low byte of FRED*10
and the whole result added to ABC+0x2233
</pre>
<h4 id="Direct_assignments">Direct assignment</h4>
<p>
A direct assignment statement associates a symbol with a value (or an
expression). When a direct assignment statement is used for the first
time that symbol is entered into the user defined symbol table and the
specified value is attached to it. If the expression does not resolve
to an absolute value, then the expression is attached to the symbol. A
symbol may be re-defined by assigning a new value to it. The latest
assigned value replaces any previous value assigned to the symbol.
The general format is:
</p>
<pre>
symbol = expression ;comments
symbol == expression ;make the symbol global too
symbol := expression ;set the symbol as unchangeable in later assembly
symbol :== expression ;set unchangeable and also global
</pre>
<p>
Symbols take on the relocatable or absolute attributes of their defining
expression. If the expression does not resolve to a single term then the
resultant expression is attached to the symbol and the value of the
symbol becomes a multiple term expression which will be substituted in
whatever other expressions the symbol is used and, in fact, may be
passed on to LLF if it cannot be resolved during object file creation. A
double equal sign will declare the symbol global as well as defining it,
however, for purposes of linking, only the last assignment made to a
symbol is passed to LLF (i.e. the value at the end of pass one of the
assembler is what gets passed to LLF). One may prefix a colon to the
equals or double equals to indicate that the symbol is to be defined
only once (i.e. generate an error if the symbol is redefined elsewhere).
For example:
</p>
<pre>
A = 1 ;A has absolute value of 1
B: ;defines B as a relocatable
C = B ;C is equivalent to B
D = E+F+G ;If E, F or G is undefined or relocatable then
; D becomes defined as E+F+G (expression)
H == 12 ;H is global 12
. = .+100 ;move the location counter up 100 bytes
J := 10 ;make J an absolute 10 and not eligible for
; redefinition
</pre>
<p>
<b>DO NOT MAKE CIRCULAR ASSIGNMENTS SUCH AS</b>
</p>
<pre>
A = B
B = C
C = A
</pre>
<h4>Register symbols and expressions</h4>
<p>
Some assemblers (such as MAC11, MACAS, MAC68K, MAC8080 and MACZ80) may have opcodes that allow
or require registers as operands. They may, in fact, sense the type of
operand and output object data differently based on whether there is a
register referenced in the operand. Any valid expression term with a
leading percent sign (%) declares that term as a register (for example
%5 means register 5). Symbols can be defined as being register
designators by assigning them to an expression with one or more of the
terms being a register term. The symbol will inherit the register
attribute from the expression. For example:
</p>
<pre>
R0 = %0 ;general register 0
R10 = %10. ;general register 10
TEMP = R0 ;symbol TEMP becomes equivalent to R0
GR11 == %11. ;global general register 11
</pre>
<p>
Except in mac8080 and macz80, register symbols can be global and can even be defined
in other modules. Global register symbols used but not defined in a given module must be
declared with the .GLOBR pseudo-op. The register attribute of a symbol
is only significant during the operand processing of an opcode. The
register attribute of a symbol is not significant in any other assembler
expression. The register attribute is ignored in MAC65. Undefined registers
are not allowed in MAC68K. See the appendix for a list of pre-defined
register symbols for the assembler you are using.
</p>
<h2>Assembler Directives</h2>
<p>
Assembler directives, aka pseudo-ops, are statements that the
assembler intreprets as commands to itself. Directives control various
aspects of the assembler behavior and output.
</p>
<h3 id="dir_align">.ALIGN</h3>
<pre>
.ALIGN [expression]
</pre>
<p>
where expression must resolve to an absolute between the values 0 and 31
inclusive (defaults to 0 or, in effect, a nop). The value of expression becomes an exponent of 2 and the location
counter is adjusted to the next multiple of the result. The alignment
attributes of the current program section must enforce an alignment at least
as great as the one requested or a warning message will be displayed.
If the alignment attributes of the current section do not enforce an
alignment as great as the one requested, then do not expect the resultant
location after linking (LLF) to be correct. Some examples:
</p>
<pre>
.ALIGN 3 ;aligns to next multiple of 8 bytes
.ALIGN 0 ;aligns to next byte (effectively a nop)
.ALIGN 1 ;aligns to 2 byte boundary
.ALIGN fred ;aligns to whatever FRED resolves to
</pre>
<h3 id="dir_ascix">.ASCII, .ASCIIZ, .ASCIN, .STRING and DC (mac8080/macz80 only)</h3>
<pre>
.ASCII [string]
.ASCIN [string]
.ASCIZ [string]
.STRING [string] ;Same as .ASCIZ
DC [string] ;Same as .ASCIN (mac8080/macz80 only)
</pre>
<p>
Deposits a string of ASCII characters beginning at the current location.
The parameter string consists of a string of ASCII characters delimited
by a pair of ASCII characters. The first character in the string is assumed
the delimiter for the string. The delimiters are not considered part of the
string so are not inserted into the output file. Any printing character can
be a delimiter except for <b>DC</b> where the only delimiters can be
single quotes (') or double quotes ("). Expressions can be inserted in
the middle of the string by delimiting the string and enclosing the expression
in matching expression brackets (<>'s in MAC65, ()'s in the other assemblers). Ths general
format is:
</p>
<pre>
.ASCII string ;Straight ASCII string
.ASCIN string ;The last byte of the string has bit 7 set
.ASCIZ string ;An extra byte of 0 is inserted at the end
; of the string
DC 'text' [, expression [, "more text"]] ;bit 7 set on last byte (mac8080/macz80 only)
</pre>
<p>
Some examples:
</p>
<pre>
.ASCII /123/ ;puts (hex) 31 32 33 beginning at the current location
.ASCIN /123/ ;puts (hex) 31 32 B3
.ASCIZ /123/ ;puts (hex) 31 32 33 00
.ASCII \123\<expr>/456/ ;MAC65: puts 31 32 33 xx 34 35 36
;second set of delimiters doesn't have to match the
;first set of delimiters.
.ASCII \123\(expr)/456/ ;Others: puts 31 32 33 xx 34 35 36
DC '123',4,"56",7 ;puts (hex) 31 32 33 04 35 36 87
</pre>
<h3 id="dir_asect">.ASECT</h3>
<pre>
.ASECT
</pre>
<p>
This directive sets the current program section to the default absolute
section and sets the location counter to the value that was last used in
that section. It is equivalent to:
</p>
<pre>
.PSECT .ABS.
</pre>
<p>
See the <a href="#dir_psect">.PSECT</a> directive for more details.
</p>
<h3 id="dir_blkx">.BLKx and DS.x</h3>
<pre>
.BLKB expression ;allocates space for bytes (8 bits: expression*1)
.BLKW expression ;allocates space for words (16 bits: expression*2)
.BLKL expression ;allocates space for longs (32 bits: expression*4)
.BLKQ expression ;allocates space for quads (64 bits: expression*8)
.BLKM expression ;allocates space for expression*minimum addressable unit (MAU)
.BLK2M expression ;allocates space for expression*2*MAU
.BLK4M expression ;allocates space for expression*4*MAU
.BLK8M expression ;allocates space for expression*8*MAU
DS.B expression ;(identical to .BLKB)
DS.W expression ;(identical to .BLKW)
DS.L expression ;(identical to .BLKL)
DS expression ;(identical to .BLKB but mac8080/macz80 only)
</pre>
<p>
These directives allocate space in the current program section. They move the
location counter by the specified number of elements. The expression
must be absolute but does not have to be positive (a negative value will
move the location counter backwards). The .BLKW, .BLKL and .BLKQ
directives will also verify that the current location is aligned
correctly as indicated by the current section alignment attributes.
Examples:
</p>
<pre>
.BLKB 100 ;reserve 100 bytes
.BLKL 200 ;reserve 200 longwords (800 bytes)
</pre>
<h3 id="dir_bsect">.BSECT</h3>
<pre>
.BSECT
</pre>
<p>
An obsolete directive. See <a href="#dir_psect">.PSECT</a> for details.
</p>
<h3 id="dir_csect">.CSECT</h3>
<p>
An obsolete directive. See <a href="#dir_psect">.PSECT</a> for details.
</p>
<h3 id="dir_byte">DB, DC.x, .BYTE, .WORD, .LONG, .MAU, .2MAU and .4MAU</h3>
<pre>
.BYTE [expression[, expression [, ...]]]
.WORD [expression[, expression [, ...]]]
.LONG [expression[, expression [, ...]]]
DB (similar to .BYTE)
DC.W (same as .WORD)
DC.L (same as .LONG)
.MAU (same as .BYTE if MAU=8)
.2MAU (same as .WORD if MAU=8)
.4MAU (same as .LONG if MAU=8)
</pre>
<p>
All of the above directives have the same syntax. There can be 0 or more
expressions separated by any construct that is not a valid expression
term such as a comma or two terms not joined with an expression
operator. Each expression is inserted in the object code at the next
higher location. The location counter is verified to have the correct
alignment according to those specified in the current program section.
The .BYTE directive places 1 or more bytes in the object file. The .WORD
directive places one or more 16 bit words in the object file. The .LONG
directive places one or more 32 bit longwords in the object file.
Some examples:
</p>
<pre>
.BYTE ;no expression means insert a 0
.BYTE 1,2,3 ;puts a (hex) 01 02 03 in the output file
.WORD one two three ;puts 3 words (6 bytes) in the object file
.LONG fred + sam foobar ;This puts 2 longs into the output file
;because fred + sam is a legal expression
;with or without the whitespace. As a result
;the first longword output would be the
;expression fred+sam and the second longword
;would be the expression foobar.
.BYTE fred '+ sam foobar ;puts 4 expressions into the output file.
;the '+ is not a valid operator to join two
;terms, so it is assumed to be a term of its
;own. As a result, four expressions are output:
;fred, '+ (hex 2B), sam and foobar.
</pre>
<h3 id="dir_dc">DB and DC.x</h3>
<pre>
DC.B [expression[,expression[,...]]]
DB (same as DC.B but only in mac8080/macz80)
</pre>
<p>
All of the above directives have the same syntax. There can be 0 or more
expressions separated from one another by a comma. An expression can be any text string delimited with either
single or double quotes or any combination of numbers and symbols
either internal or external. Numeric expressions must resolve to an
8 bit byte. Expression value is inserted in the object code at the next
higher location. NOTE: The text string can contain standard 'C' escape
sequences. Some examples:
</p>
<pre>
DC.B '123' ;Deposits (hex) 31 32 33
DC.B "456",0 ;Deposits (hex) 34 35 36 00
DC.B '123',4+5,"678",0 ;Deposits (hex) 31 32 33 09 36 37 38 00
DC.B 1,2,3,fred+wilma/bambam ;Expression can be anything
DC.B '1\r\n\177',0 ;Deposits (hex) 31 0D 0A EF 00
DC.B ;With no argument is a no-op
</pre>
<h3 id="dir_dcb">DCB.x</h3>
<pre>
DCB.B [expression1[,expression2]]
DCB.W [expression1[,expression2]]
DCB.L [expression1[,expression2]]
</pre>
<p>
Reserve memory. Expression 1 resolves to the number of entities and
the optional expression 2 resolves to a value to insert into each
reserved location. DCB.B reserves expression 1 bytes (1mau), DCB.W
reserves expression 1 words (2mau) and DCB.L reserves expression 1
longs (4mau). Some examples:
</p>
<pre>
DCB.B ; reserves a single byte prefilled with 0
DCB.B 10 ; reserves 10 bytes prefilled with 0
DCB.B 10,0xFF ; reserves 10 bytes prefilled with 0xFF
DCB.W 100 ; reserves 100 words (200 bytes)
</pre>
<h3 id="dir_define">.DEFINE</h3>
<p>
The .DEFINE directive allows for the assignment of an arbirtary string
to a single assembler symbol. Everywhere in the source between the
.DEFINE and an .UNDEFINE where the symbol appears, the string will be
substituted. It works similar to a #define in the C language. The
general form is:
</p>
<pre>
.DEFINE symbol an_arbitrary_string [;comments]
</pre>
<p>
where symbol is the name of the symbol which is to be substituted and
"an_arbitrary_string" is any string of printable characters up to but
not including the semicolon delimiting any comments. White space
between the symbol name and the string as well as white space between
the last character of the string and the comment is not included in the
string. Only one level of substitution is performed, that is to say no
tokens on a .DEFINE or .UNDEFINE directive will be substituted with
previously .DEFINE'd symbols. Once a symbol is substituted, the text
that has been substituted is not checked for further substitutions.
Token substitution can take place embedded in strings if the token in
question is surrounded with apostrophes (the same rules as an argument
in a macro). Inside macro calls .DEFINEd tokens are replaced after all
macro arguments are inserted.
</p>
<p>
Having one or more .DEFINE'd symbols will have an adverse effect on the
assembler's performance. It is better used in small sections of source
code (such as during macro definitions), since a symbol can be
.UNDEFINE'd which will restore the assembler's performance. Examples:
</p>
<pre>
.define fred any string of chars up to a semicolon
.define foo a+b ;defines foo