File: pasmodoc.html

package info (click to toggle)
pasmo 0.5.3-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 892 kB
  • ctags: 1,805
  • sloc: cpp: 8,508; asm: 3,020; sh: 790; makefile: 627
file content (1406 lines) | stat: -rw-r--r-- 39,667 bytes parent folder | download | duplicates (13)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> 
<html>

<head>

<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" >

<title>Pasmo documentation.</title>

</head>

<body>

<h1>Pasmo documentation.</h1>

<p>
(C) 2004-2005 Juli&aacute;n Albo.
</p>

<p>
Use and distribution allowed under the terms of the GPL license.
</p>

<p>
Last revision date: 19-apr-2005
</p>

<p>
Current Pasmo version: 0.5.2
</p>

<h2>Index.</h2>

<ul>

<li>
<a href="#intro">Introduction.</a>
</li>

<li>
<a href="#install">Installation.</a>
</li>

<li>
<a href="#command">Command line use.</a>
</li>

<li>
<a href="#codegen">Code generation modes.</a>
	<ul>
	<li><a href="#codegendefault">Default mode.</a></li>
	<li><a href="#codegenbin">--bin mode.</a></li>
	<li><a href="#codegenhex">--hex mode.</a></li>
	<li><a href="#codegenprl">--prl mode.</a></li>
	<li><a href="#codegencmd">--cmd mode.</a></li>
	<li><a href="#codegentap">--tap mode.</a></li>
	<li><a href="#codegentzx">--tzx mode.</a></li>
	<li><a href="#codegencdt">--cdt mode.</a></li>
	<li><a href="#codegentapbas">--tapbas mode.</a></li>
	<li><a href="#codegentzxbas">--tzxbas mode.</a></li>
	<li><a href="#codegencdtbas">--cdtbas mode.</a></li>
	<li><a href="#codegenplus3dos">--plus3dos mode.</a></li>
	<li><a href="#codegenamsdos">--amsdos mode.</a></li>
	<li><a href="#codegenmsx">--msx mode.</a></li>
	<li><a href="#codegensymbol">Symbol table.</a></li>
	</ul>
</li>

<li>
<a href="#source">Source code format.</a>
	<ul>
	<li><a href="#sourcegeneral">Generalities.</a>
	<li><a href="#sourcelit">Literals.</a>
		<ul>
		<li><a href="#sourcelitnum">Numeric literals.</a></li>
		<li><a href="#sourcelitstr">String literals.</a></li>
		</ul>
	</li>
	<li><a href="#sourceident">Identifiers.</a>
	<li><a href="#sourcefilename">File names.</a>
	<li><a href="#sourcelabel">Labels.</a>
	</ul>
</li>

<li>
<a href="#directives">Directives.</a>
	<ul>
	<li><a href="#direrror">.ERROR</a></li>
	<li><a href="#dirshift">.SHIFT</a></li>
	<li><a href="#dirwarning">.WARNING</a></li>
	<li><a href="#dirdefb">DEFB</a></li>
	<li><a href="#dirdefl">DEFL</a></li>
	<li><a href="#dirdefm">DEFM</a></li>
	<li><a href="#dirdefs">DEFS</a></li>
	<li><a href="#dirdefw">DEFW</a></li>
	<li><a href="#dirds">DS</a></li>
	<li><a href="#dirdw">DW</a></li>
	<li><a href="#direlse">ELSE</a></li>
	<li><a href="#dirend">END</a></li>
	<li><a href="#direndif">ENDIF</a></li>
	<li><a href="#direndm">ENDM</a></li>
	<li><a href="#direndp">ENDP</a></li>
	<li><a href="#direqu">EQU</a></li>
	<li><a href="#direxitm">EXITM</a></li>
	<li><a href="#dirif">IF</a></li>
	<li><a href="#dirinclude">INCLUDE</a></li>
	<li><a href="#dirincbin">INCBIN</a></li>
	<li><a href="#dirirp">IRP</a></li>
	<li><a href="#dirlocal">LOCAL</a></li>
	<li><a href="#dirmacro">MACRO</a></li>
	<li><a href="#dirorg">ORG</a></li>
	<li><a href="#dirproc">PROC</a></li>
	<li><a href="#dirpublic">PUBLIC</a></li>
	<li><a href="#dirrept">REPT</a></li>
	</ul>
</li>

<li>
<a href="#operators">Operators.</a>
	<ul>
	<li><a href="#opergeneral">Generalities.</a></li>
	<li><a href="#opertable">Table of precedence.</a></li>
	<li><a href="#operlist">List of operators.</a></li>
	</ul>
</li>

<li>
<a href="#macros">Macros.</a>
	<ul>
	<li><a href="#macrogeneral">Generalities.</a></li>
	<li><a href="#macrodirectives">Directives.</a>
		<ul>
		<li><a href="#macroshift">.SHIFT</a></li>
		<li><a href="#macroendm">ENDM</a></li>
		<li><a href="#macroexitm">EXITM</a></li>
		<li><a href="#macroirp">IRP</a></li>
		<li><a href="#macromacro">MACRO</a></li>
		<li><a href="#macrorept">REPT</a></li>
		</ul>
	</li>
	</ul>
</li>

<li>
<a href="#discussion">About suggestions and possible improvements.</a>
</li>

<li>
<a href="#tricks">Tricks.</a>
</li>

<li>
<a href="#bugs">Bugs.</a>
</li>

<li>
<a href="#epilogue">Epilogue.</a>
</li>

</ul>

<h2><a name="intro">Introduction</a>.</h2>

<p>
Pasmo is a multiplatform Z80 cross-assembler, easy to compile and easy to
use. It can generate object code in several formats suitable for many
Z80 machines and emulators.<br>
Pasmo generates fixed position code, can not be used to create relocatable
object files for use with linkers.
</p>

<p>
Pasmo is compatible with the syntax used in several old assemblers, by
supporting several styles of numeric and string literals and by
providing several names of the most used directives.<br>
However, in Pasmo the Z80 mnemonics, register and flags names and
directives are reserved words, this may require changes of symbol
names conflicting in some programs.
</p>

<p>
Pasmo can also generate the 8086 equivalent to the z80 assembly code.
It can create COM files for ms-dos, by using the binary generation mode,
or CMD files for CP/M 86, by using
<a href="#codegencmd">the --cmd generation mode</a>.
This feature is experimental, use with care.
</p>

<h2><a name="install">Installation</a>.</h2>

<p>
Download Pasmo from
<a href="http://www.arrakis.es/~ninsesabe/pasmo/"
>http://www.arrakis.es/~ninsesabe/pasmo/</a>.<br>

Several binary executable are provided in the web, if your platform
is not between these, or wants a more recent version, you must
download the source package and compile it. If you want to compile it
in windows you can use cygwin or mingw with the Makefile provided, with
other compilers you may need to create a project, workspace or whatever
your compiler or IDE uses.<br>

To compile you need gcc version 2.95 or later, with the c++ language
included (usually a package called g++-something).<br>

Others compilers may also be used, any reasonable standard complaint
c++ compiler must compile it with few or none corrections.<br>

From version 0.5.2 a configure script is provided. You can use the
usual './configure ; make ; make install' procedure.<br>

You have also an official Debian package for testing and
unstable releases.
</p>

<h2><a name="command">Command line use</a>.</h2>

<p>
Pasmo is invoked from command line as:
</p>

<pre>
	pasmo [options] file.asm file.bin [file.symbol [file.publics] ]
</pre>

<p>
Where file.asm is the source file, file.bin is the object file to be created
and optionally file.symbol is the file where the symbol table will be
written and file.publics is the file for the public symbols table.
Both symbol file names can be an empty string for no generation or - to write
in the standard output. When the --public option is used this is handled
in another way, see below.
</p>

<p>
Options can be zero or more of the following:
</p>

<dl>

<dt>-d</dt>
<dd>
Show debug info during second pass of assembly.
</dd>

<dt>-1 (digit 'one')</dt>
<dd>
Show debug info during both passes of assembly.
</dd>

<dt>-8</dt>
<dd>Same as --w8080</dd>

<dt>-v</dt>
<dd>
Verbose mode. Show progress information about loading of files,
progress of assembly and maybe other things.
</dd>

<dt>-I (upper case i)</dt>
<dd>
Add directory to the list for searching files in INCLUDE and INCBIN.
</dd>

<dt>-B</dt>
<dd>Same as --bracket</dd>

<dt>-E</dt>
<dd>Same as --equ</dd>

<dt>--86</dt>
<dd>
Generate 8086 code instead of Z80. This feature is experimental.
</dd>

<dt>--bin</dt>
<dd>
Generate the object file in raw binary format without headers.
</dd>

<dt>--hex</dt>
<dd>
Generate the object file in Intel HEX format.
</dd>

<dt>--prl</dt>
<dd>
Generate the object file in CP/M PRL format.
</dd>

<dt>--cmd</dt>
<dd>
Generate the object file in CP/M 86 CMD format.
</dd>

<dt>--tap</dt>
<dd>
Generate the object file in .tap format.
</dd>

<dt>--tzx</dt>
<dd>
Generate the object file in .tzx format.
</dd>

<dt>--cdt</dt>
<dd>
Generate the object file in .cdt format.
</dd>

<dt>--tapbas</dt>
<dd>
Same as --tap but adding a Basic loader before the code.
</dd>

<dt>--tzxbas</dt>
<dd>
Same as --txz but adding a Basic loader before the code.
</dd>

<dt>--cdtbas</dt>
<dd>
Same as --cdt but adding a Basic loader before the code.
</dd>

<dt>--plus3dos</dt>
<dd>
Generate the object file in PLUS3DOS format.
</dd>

<dt>--amsdos</dt>
<dd>
Generate the object file in Amsdos format.
</dd>

<dt>--msx</dt>
<dd>
Generate the object file in MSX format.
</dd>

<dt>--public</dt>
<dd>
Only the public symbols table is generated, using the file.symbol name,
file.symbol must not be specified when using this option.
</dd>

<dt>--name</dt>
<dd>
Name to put in the header in the formats that use it. If unspecified
the object file name will be used.
</dd>

<dt>--err</dt>
<dd>
Direct error messages to standard output instead of error output
(except for errors in options).
</dd>

<dt>--nocase</dt>
<dd>
Make identifiers case insensitive.
</dd>

<dt>--alocal</dt>
<dd>
Use autolocal mode. In this mode all labels that begins with '_'
are locals. See <a href="#sourcelabel">the chapter about labels</a> for
details.
</dd>

<dt>--bracket</dt>
<dd>
Use bracket only mode. In this mode the parenthesis are valid only in
expressions, for indirections brackets must be used.
</dd>

<dt>--equ</dt>
<dd>
Predefine a symbol. Predefined symbol are treated in a similar way as
defineds with EQU. Some possible uses are exemplified in the black.asm
example file. The syntax is: '--equ label=value' where label must be
a valid label name and value a numeric constant in a format valid in
pasmo syntax. The part =value is optional, if not specified the value
asigned is FFFF hex.
</dd>

<dt>--w8080</dt>
<dd>
Show warnings when Z80 instructions that have no equivalent in 8080
are used. Makes easy to write programs for 8080 processor using Z80
assembler syntax.
</dd>

</dl>

<p>
When no option for code generation is specified, --bin is used by
default.
</p>

<p>
The -d option is intended to debug pasmo itself, but can also be useful
to find errors in asm code. When used the information is showed in the
standard output. Error messages goes to error ouptut unless the --err
option is used.
</p>

<h2><a name="codegen">Code generation modes</a>.</h2>

<h3><a name="codegendefault">Default mode</a></h3>

<p>
If none of the code generation options is specified, then --bin mode is
used by default.
</p>

<h3><a name="codegenbin">--bin mode</a></h3>

<p>
The --bin mode just dumps the code generated from the first
position used without any header. This mode can be used for
direct generation of CP/M or MSX COM files, supposed that you
use a ORG 100H directive at the beginning of the code, or to
generate blocks of code to be INCBINed in other programs.
</p>

<h3><a name="codegenhex">--hex mode</a></h3>

<p>
The --hex mode generates code in Intel HEX format. This format can
be used with the LOAD or HEXCOM CP/M utilities, can be transmitted
more easily than a binary format, and is also used in some PROM
programming tools.
</p>

<h3><a name="codegenprl">--prl mode</a></h3>

<p>
The prl format is used in several variants of Digital Research CP/M
operating system. In pasmo is supported only to create RSX files for
use in CP/M Plus, use for PRL files in MP/M is not supported because
I don't have a MP/M system, real or emulated, where to test it.
</p>

<h3><a name="codegencmd">--cmd mode</a></h3>

<p>
The --cmd option generates a CP/M 86 CMD mode, using the 8080 memory
model of CP/M 86. Used in conjuction with the --86 option can easily
generate CP/M 86 executables from CP/M 80 sources with minimal changes.
</p>

<h3><a name="codegentap">--tap mode</a></h3>

<p>
The --tap options generates a tap file with a code block, with the
loading position set to the beginnig of the code so you can load it
from Basic with a
<strong>LOAD&nbsp;&quot;&quot;&nbsp;CODE</strong>
instruction.
</p>

<h3><a name="codegentzx">--tzx mode</a></h3>

<p>
Same as <a href="#codegentap">--tap</a> but using tzx format instead of tap.
</p>

<h3><a name="codegencdt">--cdt mode</a></h3>

<p>
The --cdt options generates a cdt file with a code block, with the
loading position set to the beginning of the code and the start
address to the start point specified in the source, if any, so you
can use
<strong>RUN&nbsp;&quot;&quot;</strong>
to execute it or
<strong>LOAD&nbsp;&quot;&quot;</strong>
to load it.
</p>

<h3><a name="codegentapbas">--tapbas mode</a></h3>

<p>
With the --tapbas option a tap file is generated with two parts:
a Basic loader and a code block with the object code. The Basic
loader does a CLEAR before the initial address of the code, loads
the code, and executes it if a entry point is defined (see the
<a href="#dirend">END</a>
directive). That way you can directly launch the code in a emulator,
or transfer it to a tape for use in a real Spectrum.
</p>

<h3><a name="codegentzxbas">--tzxbas mode</a></h3>

<p>
Same as <a href="#codegentapbas">--tapbas</a> but using tzx format instead
of tap.
</p>

<h3><a name="codegencdtbas">--cdtbas mode</a></h3>

<p>
Same as <a href="#codegentapbas">--tapbas</a> but using cdt format instead
of tap and with a Locomotive Basic loader instead of Spectrum Basic.
</p>

<h3><a name="codegenplus3dos">--plus3dos mode</a></h3>

<p>
Generate the object file in plus3dos format, used by the Spectrum +3 disks.
The file can be loaded from Basic with a
<strong>LOAD&nbsp;&quot;filename&quot;&nbsp;CODE</strong>
instruction.
</p>

<h3><a name="codegenamsdos">--amsdos mode</a></h3>

<p>
Generate the object file with Amsdos header, used by the Amstrad CPC
on disk files. The file generated can be loaded from Basic with
<strong>LOAD&nbsp;&quot;filename&quot;,&nbsp;address</strong>
or executed with
<strong>RUN&nbsp;&quot;filename&quot;</strong>
if an entry point has been specified in the source (see the
<a href="#dirend">END</a>
directive).
</p>

<h3><a name="codegenmsx">--msx mode</a></h3>

<p>
Generate the object file with header for use with BLOAD in MSX Basic.
</p>

<h3><a name="codegensymbol">Symbol table</a></h3>

<p>
The symbol table generated contains all identifiers used in the program,
with the locals represented as a 8 digit hexadecimal number in order of
use, unless the --public option is used. In that case only the symbols
specified in PUBLIC directives are listed.
</p>

<p>
The symbol table format is a list of EQU directives. That way you can
INCLUDE it in another source to create programs composed of several
blocks.
</p>

<h2><a name="source">Source code format</a>.</h2>

<h3><a name="sourcegeneral">Generalities</a>.</h3>

<p>
Source code files must be valid text files in the platform used. The use of,
for example, unix text files under pasmo in windows, is unsupported and the
result is undefined (may depend of the compiler used to build pasmo, for
example). The result of the use of a file that contains vertical tab or
form feed characters is also undefined.
</p>

<p>
Everything after a ; in a line is a comment (unlees the ; is part of a
string literal, of course). There are no multiline comments, you can
use IF 0 .... ENDIF instead (but see <a href="#dirinclude">INCLUDE</a>).
</p>

<p>
String literals are written to the object file without any character set
translation. Then the use of any character with a different meaning in
the platform were pasmo is running and the destination machine must be
avoided, and the code of the character may be used instead. That also
means that using Pasmo in any machine that uses a non ascii compatible
character set may be difficult, and that a source written in utf-8 may
give undesired results. This may be changed in future versions of Pasmo.
</p>

<p>
A line may begin with a decimal number followed by blanks. This number
is ignored by the assembler, is allowed for compatibility with old
assemblers. The line number reported in errors is the sequential number
of the line in the file, not this.
</p>

<p>
Blanks are significative only in string literals and when they separate
lexical elements. Any number of blanks has the same meaning as one.
A blank between operators and operands is allowed but no required except
when the same character has other meaning as prefix ('$' and '%', for
example).
</p>

<h3><a name="sourcelit">Literals</a>.</h3>

<h4><a name="sourcelitnum">Numeric literals</a>.</h4>

<p>
Numeric literals can be written in decimal, binary, octal and hexadecimal
formats. Several formats are accepted to obtain compatibility with the
source format of several assemblers.
</p>

<p>
A literal that begins with $ is a hexadecimal constant, except if the
literal is only the $ symbol, in that case is an operator, see below.
</p>

<p>
A literal that begins with # is a hexadecimal constant, except if there
are two consecitives #, see the ## operator.
</p>

<p>
A literal that begins with &amp; can be hexadecimal, octal or binary
constant, depending of the character that follows the &amp;: H means
hexadecimal, O octal and X hexadecimal, if none of this the caracter
must be a valid hexadecimal digit and the constant is hexadecimal.
</p>

<p>
A literal that begins with % is a binary constant, except if the literal
is only the % symbol, in that case is an operator, see below.
</p>

<p>
A literal that begins with a decimal digit can be a decimal, binary,
octal or hexadecimal. If the digit is 0 and the following character is
an X, the number is hexadecimal. If not, the suffix of the literal is
examined: D means decimal, B binary, H hexadcimal and O or Q octal,
in any other case is taken as decimal. Take care, FFFFh for example is
not an hexadecimal constant, is an identifier, to write it with the
suffix notation you must do it as 0FFFFh.
</p>

<p>
All numeric formats can have $ signs between the digits to improve
readability. They are ignored.
</p>

<h4><a name="sourcelitstr">String literals</a>.</h4>

<p>
There are two formats of string literals: single or double quote
delimited.
</p>

<p>
A string literal delimited with single quotes is the simpler format,
all characters are included in the string without any special
interpretation, with the only exception that two consecutive single
quotes are taken as one single quote character to be included in the
string. For example: the single quote delimited string
'That''s all folks' generates the same string as the double quote
delimited &quot;That's all folks&quot;.
</p>

<p>
A string literal delimited with double quotes is interpreted in a
way similar to the C and C++ languages. The \ character is taken
as escape character, with the following interpretations: n is a
new line character (0A hex), r is a carriage return (0D hex), t is
a tabulator (09 hex), a is a bell (07 hex), x indicates that the
two next characters will be considered the hexadecimal code of
a char and a char with that code is inserted, an octal digit prefixes
and begins an octal number of up to three digits, and the corresponding
character is inserted into the string, the characters \ and &quot;
means to insert itself in the string, and any other char is reserved
for future use.
</p>

<p>
A string literal of length 1 can be used as a numeric constant with
the numeric value of the character contained. This allows expressions
such as 'A' + 80h to be evaluated as expected.
</p>

<h3><a name="sourceident">Identifiers</a>.</h3>

<p>
Identifiers are the names used for labels, EQU and DEFL symbols and
macro names and parameters. The names of the Z80 mnemonics, registers
and flag names, and of pasmo operands and assemble directives are
reserved and can not be used as names of identifiers. Reserved names
are case insensitive, even if case sensitive mode is used.
</p>

<p>
In the following 'letter' means an english letter character in
upper or lower case. Characters that correspond to letters in
other languages are not allowed in identifiers.
</p>

<p>
Identifiers begins with a letter, '_', '?', '@' or '.', followed for
zero or more letter, decimal digit, '_', '?', '@', '.' or '$'.
The '$' are ignored, but a reserved word with a '$' embedded or appended
is not recognized as such.
</p>

<p>
Identifiers that begins with '_' are special when using autolocal mode,
see the --alocal option and
<a href="#sourcelabel">the chapter about labels</a>
for details.
</p>

<p>
Identifiers are case sensitive if the option --nocase is not used.
When using --nocase, they are always converted to upper case.
</p>

<h3><a name="sourcefilename">File names</a>.</h3>

<p>
File names are used in the INCLUDE and INCBIN directives. They follow
special rules.
</p>

<p>
A file name that begins with a double quote character must end with
another double quote, and the file name contains all character between
them without any special interpretation.
</p>

<p>
A file name that begins with a single quote character must end with
another single quote, and the file name contains all character between
them without any special interpretation.
</p>

<p>
In any other case all characteres until the next blank or the end of line
are considered part of the file name. Blank characters are space and tab.
</p>

<h3><a name="sourcelabel">Labels</a>.</h3>

<p>
A label can be placed at the beginning of any line, before any
assembler mnemonic or directive. Optionally can be followed by
a ':', but is not recommended to use it in directives, for
compatibility with other assemblers. A line that has a label
with no mnemonic nor directive is also valid.
</p>

<p>
The label has special meaning in the MACRO, EQU and DEFL directives,
in any other case the value of the current code generation position is
assigned to the label.
</p>

<p>
Labels can be used before his definition, but the result of doing this
with labels assigned with DEFL is undefined.
</p>

<p>
The value of a label cannot be changed unless DEFL is used in all
assignments of that label. If the value assigned to a label is
different in the two passes of the assembly the program is illegal,
but is not guaranteed that an error is generated. However, is legal
to assign a value undefined in the first pass (by using an expression
that contains a label not yet defined, for example).
</p>

<p>
In the default mode a label is global unless declared as LOCAL into
a MACRO, REPT or IRP block, see the
<a href="#dirlocal">LOCAL</a>
directive for details.
</p>

<p>
In the autolocal mode, introduced by using the --alocal command line
option, all labels that begins with a '_' are locals. His ambit ends
at the next non local label or in the next PROC, LOCAL, MACRO, ENDP
or ENDM directive.
</p>

<p>
Both automatic and explicit local labels are represented in the symbol
table listing as 8 digit hexadecimal numbers, corresponding to the first
use of the label in the source.
</p>

<h2><a name="directives">Directives</a>.</h2>

<p>
List of directives supported in Pasmo, in alphabetical order.
<p>

<dl>

<dt><a name="direrror">.ERROR</a></dt>
<dd>
Generates an error during assembly if the line is actively used, that is,
in a macro if it gets expanded, in an IF if the current branch is taken.
All text following the directive is used as error message.
</dd>

<dt><a name="dirshift">.SHIFT</a></dt>
<dd>
Shift MACRO arguments, see <a href="#macros">the chapter about macros</a>.
</dd>

<dt><a name="dirwarning">.WARNING</a></dt>
<dd>
Same as <a href="#direrror">.ERROR</a> but emiting a a warning message
instead of generating an error.
</dd>

<dd><a name="dirdb">DB</a></dd>
<dd>
Define Byte. The argument is a comma separated list of string literals
or numeric expressions. The string literals are inserted in the object
code, and the result of the numeric expression is inserted as a single
byte, truncating it if needed.
</dd>

<dt><a name="dirdefb">DEFB</a></dt>
<dd>DEFine Byte, same as <a href="#dirdb">DB</a>.</dd>

<dt><a name="dirdefl">DEFL</a></dt>
<dd>
DEFine Label. Must be preced by a label. The argument must be a
numeric expression, the result is assigned to the label. The label
used can be redefined with other DEFL directive.
</dd>

<dt><a name="dirdefm">DEFM</a></dt>
<dd>DEFine Message, same as <a href="#dirdb">DB</a>.</dd>

<dt><a name="dirdefs">DEFS</a></dt>
<dd>DEFine Space, same as <a href="#dirds">DS</a>.</dd>

<dt><a name="dirdefw">DEFW</a></dt>
<dd>Same as <a href="#dirdw">DW</a>.</dd>

<dt><a name="dirds">DS</a></dt>
<dd>
Define Space. Take one or two comma separated arguments.
The first or only argument is the amount of space to define,
in bytes. The second is the value used to fill the space,
if absent 0 will be used.
</dd>

<dt><a name="dirdw">DW</a></dt>
<dd>
Define Word. The argument is a comma separated list of numeric
expressions. Each numeric expression is evaluated as a two byte word
and the result inserted in the code in the Z80 word format.
</dd>

<dt><a name="direlse">ELSE</a></dt>
<dd>See <a href="#dirif">IF</a>.
</dd>

<dt><a name="dirend">END</a></dt>
<dd>
Ends the assembly. All lines after this directive are ignored.
If it has an argument is evaluated as a numeric expression and the result
is set as the program entry point. The result of setting an entry point
depends of the type of code generation used, may be none but even in this
case may be used for documentation purposes.
</dd>

<dt><a name="direndif">ENDIF</a></dt>
<dd>See <a href="#dirif">IF</a>.</dd>

<dt><a name="direndm">ENDM</a></dt>
<dd>Ends a macro, see <a href="#macros">the chapter about macros</a>.</dd>

<dt><a name="direndp">ENDP</a></dt>
<dd>Marks the end of a PROC block, see PROC.</dd>

<dt><a name="direqu">EQU</a></dt>
<dd>
EQUate. Must be preceded by a label. The argument must be a numeric
expression, the result is assigned to the label. The label used can't be
redefined.
</dd>

<dt><a name="direxitm">EXITM</a></dt>
<dd>Exits a macro, see <a href="#macros">the chapter about macros</a>.</dd>

<dt><a name="dirif">IF</a></dt>
<dd>
Contional assembly. The argument must be a numeric expression, a result
of 0 is considered as false, any other as true. If the argument is true the
following code is assembled until the end of the IF section or an ELSE
directive is encountered, else is ignored. If the ELSE direcive is present
the following code is ignored if the argument was true, or is assembled if
was false.<br>
The IF section is ended with a ENDIF or a ENDM directive (in the last case
the ENDM has also his usual effect).<br>
IF can be nested, in that case each ELSE and ENDIF takes effect only on his
corresponding IF, but ENDM ends all pending IF sections.
</dd>

<dt><a name="dirinclude">INCLUDE</a></dt>
<dd>
Include a file. See
<a href="#sourcefilename">the file names chapter</a>
for the conventions used in the argument. The file is readed and the result
is the same as if the file were copied in the current file instead of the
INCLUDE line.<br>
The file included may contain INCLUDE directives, and so on.<br>
INCLUDE directives are processed before the assembly phases, so the use
of IF directives to conditionally include different files is not allowed.
</dd>

<dt><a name="dirincbin">INCBIN</a></dt>
<dd>
INClude BINary. Include a binary file. Reads a binary file and insert
his content in the generated code at the current position. See
<a href="#sourcefilename">the file names chapter</a>
for the conventions used in the argument.
</dd>

<dt><a name="dirirp">IRP</a></dt>
<dd>
Repeat a block of code substituing arguments. See
<a href="#macros">the chapter about macros</a>.
</dd>

<dt><a name="dirlocal">LOCAL</a></dt>
<dd>
Marks identifiers as local to the current block. The block may be
a MACRO, REPT, IRP or PROC directive, the local ambit ends in the
corresponding ENDM or ENDP directive. The ambit begins at the LOCAL
directive, not at the beginning of the block, take care with that.<br>
If several LOCAL declations of the same identifier are used in the same
block, only the first has effect, the others are ignored.
</dd>

<dt><a name="dirmacro">MACRO</a></dt>
<dd>
Defines a macro, see
<a href="#macros">the chapter about macros</a>.
</dd>

<dt><a name="dirorg">ORG</a></dt>
<dd>
ORiGin. Establishes the origin position where to place generated
code. Several ORG directives can be used in the same program, but if
the result is that code generated overwrites previous, the result is
undefined.
</dd>

<dt><a name="dirproc">PROC</a></dt>
<dd>
Marks the begin of a PROC block. The only effect is to define
an ambit for LOCAL directives. The block ends with a corresponding
ENDP directive. The recommended use is to enclose a subroutine in
a PROC block, but can also be used in any other situation.
</dd>

<dt><a name="dirpublic">PUBLIC</a></dt>
<dd>
The argument is a comma separated list of identifiers. Each identifier
is marked as public. When using the --public command line option only the
identifiers marked as public are included in the symbol table listing.
</dd>

<dt><a name="dirrept">REPT</a></dt>
<dd>
REPeaTs a block. See <a href="#macros">the chapter about macros</a>.
</dd>

</dl>

<h2><a name="operators">Operators</a>.</h2>

<h3><a name="opergeneral">Generalities</a>.</h3>

<p>
All numeric values are taken as 16 bits unsigned, using 2 complement or
trucating when required. Logical operators return FFFF hex for true and 0
for false, in the arguments 0 is false and any other value true.
</p>

<p>
Parenthesis may be used to group parts of expressions. They are also used
to express indirections in the z80 instructions that allows or require it.
This can cause some errors when a parenthesized expression is used in a
place were an indirections is allowed. Pasmo uses some heuristic to
allow the expression to be correctly interpreted, but are far from perfect.
</p>

<p>
Using the bracket only mode the parenthesis have the unique meaning of
grouping expressions, brackets are required for indirections, thus solving
ambiguities.
</p>

<p>
Short circuit evaluation: the && and || operators and the conditional
expression are short circuited. This means that if one of his operators
need not be evaluted, it can include undefined symbols or divisions by 0
without generating an error (but still must have correct syntax). In the
conditional expression this applies to the branch not taken, in the &&
operator to the second operand if the first is false, and in the ||
operator to the second operand if the first is true.
</p>

<h3><a name="opertable">Table of precedence</a>.</h3>

<p>
Table of operators by order of precedence, those in the same line have the
same precedence:
</p>

<pre>
	## (see note)
	$, NUL, DEFINED
	*, /, MOD, %, SHL, SHR, <<, >>
	+, - (binary)
	EQ, NE, LT, LE, GT, GE, =, !=, <, >, <=, >=
	NOT, ~, !, +, - (unary)
	AND, &
	OR, |, XOR
	&&
	||
	HIGH, LOW
	?
</pre>

<p>
The ## operator is an special case, is processed during the macro expansion,
see <a href="#macros">the chapter about macros</a>.
</p>

<h3><a name="operlist">Alphabetic list of operators</a>.</h3>

<dl>

<dt>!</dt>
<dd>
Logical not. Returns true if his argument is 0, false otherwise.
</dd>

<dt>!=</dt>
<dd>Same as NE.</dd>

<dt>##</dt>
<dd>
Identifier pasting operator, see
<a href="#macros">the chapter about macros</a>.
</dd>

<dt>$</dt>
<dd>
Gives the value of the position counter at the begin of the current sentence.
For example, in a DW directive it gives the position of the first item in
the list, not the current item.
</dd>

<dt>%</dt>
<dd>Same as MOD.</dd>

<dt>&</dt>
<dd>Same as AND.</dd>

<dt>&&</dt>
<dd>
Logical and. True if both operands are true.
</dd>

<dt>*</dt>
<dd>Multiplication.</dd>

<dt>+</dt>
<dd>Addition or unary +.</dd>

<dt>-</dt>
<dd>Substraction or unary -.</dd>

<dt>/</dt>
<dd>Integer division, truncated.</dd>

<dt>&lt;</dt>
<dd>Same as LT</dd>

<dt>&lt;&lt;</dt>
<dd>Same as SHL</dd>

<dt>&lt;=</dt>
<dd>Same as LE</dd>

<dt>=</dt>
<dd>Same as EQ</dd>

<dt>&gt;</dt>
<dd>Same as GT</dd>

<dt>&gt;=</dt>
<dd>Same as GE</dd>

<dt>&gt;&gt;</dt>
<dd>Same as SHR</dd>

<dt>?</dt>
<dd>
Condtional expression. Must be followed by two expressions separated by a :,
if the expression on the right of ? is true, the first expressions is
evaluted, if false, the second.
</dd>

<dt>|</dt>
<dd>Same as OR.</dd>

<dt>||</dt>
<dd>
Logical or. True if one of his operands is true.
</dd>

<dt>~</dt>
<dd>Same as NOT</dd>

<dt>AND</dt>
<dd>Bitwise and operator.</dd>

<dt>DEFINED</dt>
<dd>
The argument must be a identifier. The result is true if the identifier is
defined, false otherwise.
</dd>

<dt>EQ</dt>
<dd>
Equals. True if both operands are equal, false otherwise.
</dd>

<dt>GE</dt>
<dd>
Greater or equal. True if the left operand is greater or equal than the right.
</dd>

<dt>GT</dt>
<dd>
Greater than. True if the left operand is greater than the right.
</dd>

<dt>HIGH</dt>
<dd>
Returns the high order byte of the argument.
</dd>

<dt>LE</dt>
<dd>
Less or equal. True if the left operand is lesser or equal than the right.
</dd>

<dt>LOW</dt>
<dd>
Returns the low order byte of the argument.
</dd>

<dt>LT</dt>
<dd>
Less than. True if the lefth operand is lesser than the right.
</dd>

<dt>MOD</dt>
<dd>
Modulus. The remainder of the integer division.
</dd>

<dt>NE</dt>
<dd>
Not equal. False if both operands are equal, true otherwise.
</dd>

<dt>NOT</dt>
<dd>
Bitwise not. Return the ones complement of his operand.
</dd>

<dt>NUL</dt>
<dd>
Returns true if there is something at his right, false in other case.
Useful if the arguments are parameters of macros.
</dd>

<dt>OR</dt>
<dd>
Bitwise or operator.
</dd>

<dt>SHL</dt>
<dd>
Shif left. Returns the left operand shifted to the left the number of bits
specified in the right operand, filling with zeroes.
</dd>

<dt>SHR</dt>
<dd>
Shif right. Returns the left operand shifted to the right the number of bits
specified in the right operand, filling with zeroes.
</dd>

<dt>XOR</dt>
<dd>
Bitwise xor (exclusive or) operator.
</dd>

</dl>

<h2><a name="macros">Macros</a>.</h2>

<h3><a name="macrogeneral">Generalities</a>.</h3>

<p>
There are two types of macro directives: the proper MACRO directive
and the repetition directives REPT and IRP. In addition the ENDM and
EXITM directives controls the end of the macro expansion.
</p>

<p>
A macro parameter is an indentifier that when the macro is expanded
is substitued by the value of the argument applied. The argument can
be empty, or be composed by one or more tokens. If a MACRO is defined
inside another macro directive the external parameters are not
substitued, with the other macro directives the parameter substitution
is done beginnig by the most external directive. The NUL operator
can be used to check if an argument is not empty. The .SHIFT directive
can be used to work with an undeterminated number of arguments.
</p>

<p>
Identifier pasting: inside a MACRO the operator ## can be used to join
two idenfiers resulting in another identifier. This is intended to allow
the creation of identifiers dependent of macro arguments.
</p>

<h3><a name="macrodirectives">Directives</a>.</h3>

<dl>

<dt><a name="macroshift">.SHIFT</a></dt>
<dd>
Can be used only inside a MACRO. The MACRO arguments are shitted one
place to the left, the first argument is discarded. If there are not
enough arguments to fill the parameter list after the shift, the
remaining arguments get undefined.
</dd>

<dt><a name="macroendm">ENDM</a></dt>
<dd>
Marks the end of the current MACRO definition, or the current REPT or
IRP block. All IF blocks contained in the macro block are also closed.
</dd>

<dt><a name="macroexitm">EXITM</a></dt>
<dd>
Exits the curren MACRO, REPT or IRP block. In the case of MACRO, the
macro expansion is finished, in the other cases the code generation
of the block is terminated and the assembly continues after the
corresponding ENDM.
</dd>

<dt><a name="macroirp">IRP</a></dt>
<dd>
<pre>
	IRP parameter, argument list.
</pre>
Repeats the block of code between the IRP directive and his corresponding
ENDM one time for each of the arguments.
</dd>

<dt><a name="macromacro">MACRO</a></dt>
<dd>
Defines a macro. There are two forms that can be used:
<pre>
	name	MACRO [ list of parameters]
</pre>
or:
<pre>
	MACRO name [ , list of parameters]
</pre>
In all cases, list of paramenters is a comma separated list of identifiers,
and name is the name assigned to the macro created.<br>
A macro is used by simply specifying his name, and optionally a list of
arguments. The arguments list does not need to have the same length as the
parameter list of the macro. If it is longer, the extra arguments are not
used, but can be retrieved by using .SHIFT inside the MACRO. If it is
shorter some parameters get undefined, this can be tested inside the MACRO
by using the NUL operator.
</dd>

<dt><a name="macrorept">REPT</a></dt>
<dd>
Repeats the block of code between the REPT directive and his corresponding
ENDM the number of times specified in his argument. The argument can be
0, in that case the block is skipped.<br>
Additionally a loop var can be specified. This var is not a macro parameter,
is used as a LOCAL DEFL symbol, whose value is incremented in every loop
iteration. The initial value and incement can be specified, with defaults of
0 and 1 respectively.
</dd>

</dl>

<h2><a name="discussion">About suggestions and possible improvements</a>.</h2>

<p>
The assumption of Pasmo if that, being a cross-assembler, it will be
used on a machine with many available resources. Then I do not make
any effort to provide means to do things that can be easily made
with other utilities, unless I think (or other people convince me)
that including it in Pasmo can be much more convenient.<br>
For example, if you want to create a sin table you can write a program
in your favourite language that writes a file with the table and
INCLUDE that file, and if you want to automate that type of things you
can use make.
</p>

<p>
Taken that into account, I am open to suggestions to improve Pasmo
and to patches that implements it. In the later case please take
care to write things in a portable way, without operating system
or compiler dependences.
</p>

<h3>Why Pasmo can not generate linkable code?</h3>

<p>
Pasmo has a simple code generator that uses absolute address of memory.
That will make difficult to adapt it to generate relocatable code for
use with linkers.
I don't have plans to do it for the moment, maybe someone want to
contribute?
</p>

<h3>Game Boy.</h3>

<p>
Some people suggested to add support for Game Boy programming. There
are two problems, the simplified way used to generate code in Pasmo,
and my inexistent knowledge of the Game Boy.
</p>

<h3>Thanks.</h3>

<p>
Thanks to all people that has made suggestions and notified or
corrected bugs. And to these that show me the beautiful things they
do with Pasmo.
</p>

<h2><a name="tricks">Tricks</a>.</h2>

<p>
You can use Pasmo to convert any binary file to .tap, just write a tiny
program called for example convert.asm:
</p>

<pre>
	ORG address_to_load_the_file
	INCBIN file.bin
</pre>

<p>
Assemble it with: pasmo --tap convert.asm file.tap, and you have it.
The same may be done for the other formats supported.
</p>

<h2><a name="bugs">Bugs</a>.</h2>

<p>
Pasmo emits a warning when using a expression that looks line a non
existent z80 instruction, such as 'ld b, (nn)', but the simplified
way used to detect that also warns in cases like
'ld b,(i1+i2)*(i3+i4)'.<br>
A way to avoid the warning in that case is to prefix the expression
with parenthesis with '+' or '0 +'.<br>
Using the bracket only mode the problem does not exist, in that case
the parenthesis are always taken as expresssions (and the programmer
is supposed to know that), thus the warning is not emitted.<br>
More suggestions about that are wellcome.
</p>

<p>
There is no way to include a file whose name contains blanks, single
and double quoutes. Someone use file names like that?
</p>

<h2><a name="epilogue">Epilogue</a>.</h2>

<p>That's all folks!</p>

<p>
Send comments and criticisms to:
</p>
<address><a href="mailto:julian.notfound@gmail.com"
>julian.notfound@gmail.com</a>
</address>

<p>
<a href="http://validator.w3.org/check?uri=referer">Valid HTML 4.0!</a>
</p>

</body>

</html>