-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsymbols.s
executable file
·960 lines (938 loc) · 14.2 KB
/
symbols.s
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
|symbols.asm
|
|This file contains the symbol tables for the assembler.
|
MatchKeyword:
lodsb
movb bl,al
xorb bh,bh
MatchKeyword1:
mov bp,si
mov di, #InputWord
lodsb
cmpb al,#0
jz SymbolNotFound
movb cl,al
xorb ch,ch
mov dx,cx
rep
cmpsb
jnz NotThisSymbol
cmpb -1[di],#0
jz ThisSymbol
cmpb [di],#0
jnz NotThisSymbol
ThisSymbol:
clc
ret
NotThisSymbol:
mov si,bp
add si,dx
add si,bx |Number of bytes to skip
inc si |One more for the length
jmps MatchKeyword1
SymbolNotFound:
stc
ret
|The pseudo instructions that are accepted by the assembler are
| .align n align on multiple of n bytes
| .ascii str assemble a string
| .asciz str assemble a zero terminated string
| .bss What follows goes to the bss segment
| .byte n Assemble one or more bytes
| .data What follows goes to the data segment
| .define sym Export Sym from the file
| .errnz n Force error if n is nonzero
| .even Align to an even address
| .extern sym Declare sym external
| .globl sym Same as Extern
| .long n Assemble n as a long
| .org adr Set Address within current segment
| .short n Assemble n as a short
| .space n Skip n bytes
| .text What follows goes to the text segment
| .word n Assemble n as a word
| .zerow n Assemble n words of zeros
| .include filename Include the specified file
Directives:
.byte 2
|0fddwi.byte f,s .ascii j0fddwi.word j
.byte 6
.ascii ".align"
.word ProcAlign
.byte 6
.ascii ".ascii"
.word ProcAscii
.byte 6
.ascii ".asciz"
.word ProcAsciz
.byte 4
.ascii ".bss"
.word NotImplemented
.byte 5
.ascii ".byte"
.word ProcByte
.byte 5
.ascii ".data"
.word NotImplemented
.byte 7
.ascii ".define"
.word NotImplemented
.byte 6
.ascii ".errnz"
.word ProcErrnz
.byte 5
.ascii ".even"
.word ProcEven
.byte 7
.ascii ".extern"
.word NotImplemented
.byte 6
.ascii ".globl"
.word NotImplemented
.byte 8
.ascii ".include"
.word ProcInclude
.byte 5
.ascii ".long"
.word ProcWord
.byte 4
.ascii ".org"
.word ProcOrg
.byte 6
.ascii ".short"
.word ProcWord
.byte 6
.ascii ".space"
.word ProcSpace
.byte 5
.ascii ".text"
.word NotImplemented
.byte 5
.ascii ".word"
.word ProcWord
.byte 6
.ascii ".zerow"
.word ProcZeroWords
.byte 0
Instructions:
.byte 4
|0fddwi.byte f,s .ascii j0fddwi.word j0fddwi.byte f,s .byte j
.byte 3
.ascii "aaa"
.word NothingElse
.byte 55
.byte 0
.byte 3
.ascii "aad"
.word NothingElse
.byte 213
.byte 10
.byte 3
.ascii "aam"
.word NothingElse
.byte 214
.byte 10
.byte 3
.ascii "aas"
.word NothingElse
.byte 63
.byte 0
.byte 3
.ascii "adc"
.word AddType
.byte 21
.byte 17
.byte 5
.ascii "adcb"
.byte 0
.word AddType
.byte 20
.byte 16
.byte 3
.ascii "add"
.word AddType
.byte 5
.byte 1
.byte 5
.ascii "addb"
.byte 0
.word AddType
.byte 4
.byte 0
.byte 3
.ascii "and"
.word AddType
.byte 37
.byte 33
.byte 5
.ascii "andb"
.byte 0
.word AddType
.byte 36
.byte 32
.byte 4
.ascii "call"
.word JmpCallType
.byte 232
.byte 16
.byte 5
.ascii "callf"
.word JmpCallFarType
.byte 0154
.byte 24
.byte 3
.ascii "cbw"
.word NothingElse
.byte 152
.byte 0
.byte 3
.ascii "clc"
.word NothingElse
.byte 248
.byte 0
.byte 3
.ascii "cld"
.word NothingElse
.byte 252
.byte 0
.byte 3
.ascii "cli"
.word NothingElse
.byte 250
.byte 0
.byte 3
.ascii "cmc"
.word NothingElse
.byte 245
.byte 0
.byte 3
.ascii "cmp"
.word AddType
.byte 61
.byte 57
.byte 5
.ascii "cmpb"
.byte 0
.word AddType
.byte 60
.byte 56
.byte 5
.ascii "cmpsb"
.word NothingElse
.byte 166
.byte 0
.byte 5
.ascii "cmpsw"
.word NothingElse
.byte 167
.byte 0
.byte 3
.ascii "cwd"
.word NothingElse
.byte 153
.byte 0
.byte 3
.ascii "daa"
.word NothingElse
.byte 39
.byte 0
.byte 3
.ascii "das"
.word NothingElse
.byte 47
.byte 0
.byte 3
.ascii "dec"
.word IncDecType
.byte 72
.byte 8
.byte 5
.ascii "decb"
.byte 0
.word RegOrMem
.byte 254
.byte 8
.byte 3
.ascii "div"
.word DivMulRegMem
.byte 247
.byte 48
.byte 5
.ascii "divb"
.byte 0
.word DivMulRegMem
.byte 246
.byte 48
.byte 3
.ascii "esc"
.word NothingElse
.byte 216
.byte 0
.byte 3
.ascii "hlt"
.word NothingElse
.byte 244
.byte 0
.byte 4
.ascii "idiv"
.word DivMulRegMem
.byte 247
.byte 56
.byte 6
.ascii "idivb"
.byte 0
.word DivMulRegMem
.byte 246
.byte 56
.byte 4
.ascii "imul"
.word DivMulRegMem
.byte 247
.byte 40
.byte 6
.ascii "imulb"
.byte 0
.word DivMulRegMem
.byte 246
.byte 40
.byte 2
.ascii "in"
.word InOutPort
.byte 229
.byte 0
.byte 4
.ascii "inb"
.byte 0
.word InOutPort
.byte 228
.byte 0
.byte 3
.ascii "inc"
.word IncDecType
.byte 64
.byte 0
.byte 5
.ascii "incb"
.byte 0
.word RegOrMem
.byte 254
.byte 0
.byte 3
.ascii "int"
.word OneByteOnly
.byte 205
.byte 0
.byte 4
.ascii "int3"
.word NothingElse
.byte 204
.byte 0
.byte 4
.ascii "into"
.word NothingElse
.byte 206
.byte 0
.byte 4
.ascii "iret"
.word NothingElse
.byte 207
.byte 0
.byte 2
.ascii "ja"
.word OneRelativeLabel
.byte 119
.byte 0
.byte 3
.ascii "jae"
.word OneRelativeLabel
.byte 115
.byte 0
.byte 2
.ascii "jb"
.word OneRelativeLabel
.byte 114
.byte 0
.byte 2
.ascii "jc"
.word OneRelativeLabel
.byte 114
.byte 0
.byte 4
.ascii "jcxz"
.word OneRelativeLabel
.byte 227
.byte 0
.byte 2
.ascii "je"
.word OneRelativeLabel
.byte 116
.byte 0
.byte 2
.ascii "jg"
.word OneRelativeLabel
.byte 127
.byte 0
.byte 3
.ascii "jge"
.word OneRelativeLabel
.byte 125
.byte 0
.byte 2
.ascii "jl"
.word OneRelativeLabel
.byte 124
.byte 0
.byte 3
.ascii "jle"
.word OneRelativeLabel
.byte 126
.byte 0
.byte 3
.ascii "jmp"
.word JmpCallType
.byte 233
.byte 32
.byte 4
.ascii "jmpf"
.word JmpCallFarType
.byte 234
.byte 40
.byte 4
.ascii "jmps"
.word OneRelativeLabel
.byte 235
.byte 0
.byte 3
.ascii "jna"
.word OneRelativeLabel
.byte 118
.byte 0
.byte 3
.ascii "jnb"
.word OneRelativeLabel
.byte 115
.byte 0
.byte 3
.ascii "jnc"
.word OneRelativeLabel
.byte 115
.byte 0
.byte 3
.ascii "jne"
.word OneRelativeLabel
.byte 117
.byte 0
.byte 3
.ascii "jnz"
.word OneRelativeLabel
.byte 117
.byte 0
.byte 3
.ascii "jno"
.word OneRelativeLabel
.byte 113
.byte 0
.byte 3
.ascii "jnp"
.word OneRelativeLabel
.byte 123
.byte 0
.byte 3
.ascii "jns"
.word OneRelativeLabel
.byte 121
.byte 0
.byte 2
.ascii "jo"
.word OneRelativeLabel
.byte 112
.byte 0
.byte 2
.ascii "jp"
.word OneRelativeLabel
.byte 122
.byte 0
.byte 2
.ascii "js"
.word OneRelativeLabel
.byte 120
.byte 0
.byte 2
.ascii "jz"
.word OneRelativeLabel
.byte 116
.byte 0
.byte 4
.ascii "lahf"
.word NothingElse
.byte 159
.byte 0
.byte 3
.ascii "lds"
.word RegisterMemory
.byte 197
.byte 0
.byte 3
.ascii "lea"
.word RegisterMemory
.byte 0141
.byte 0
.byte 3
.ascii "les"
.word RegisterMemory
.byte 196
.byte 0
.byte 4
.ascii "lock"
.word NothingElse
.byte 240
.byte 0
.byte 5
.ascii "lodsb"
.word NothingElse
.byte 172
.byte 0
.byte 5
.ascii "lodsw"
.word NothingElse
.byte 173
.byte 0
.byte 4
.ascii "loop"
.word OneRelativeLabel
.byte 226
.byte 0
.byte 5
.ascii "loopz"
.word OneRelativeLabel
.byte 225
.byte 0
.byte 6
.ascii "loopnz"
.word OneRelativeLabel
.byte 224
.byte 0
.byte 3
.ascii "mov"
.word MovType
.byte 1
.byte 0
.byte 5
.ascii "movb"
.byte 0
.word MovType
.byte 0
.byte 0
.byte 5
.ascii "movsb"
.word NothingElse
.byte 164
.byte 0
.byte 5
.ascii "movsw"
.word NothingElse
.byte 165
.byte 0
.byte 3
.ascii "mul"
.word DivMulRegMem
.byte 247
.byte 32
.byte 5
.ascii "mulb"
.byte 0
.word DivMulRegMem
.byte 246
.byte 32
.byte 3
.ascii "neg"
.word RegOrMem
.byte 247
.byte 24
.byte 5
.ascii "negb"
.byte 0
.word RegOrMem
.byte 246
.byte 24
.byte 3
.ascii "nop"
.word NothingElse
.byte 0144
.byte 0
.byte 3
.ascii "not"
.word RegOrMem
.byte 247
.byte 16
.byte 5
.ascii "notb"
.byte 0
.word RegOrMem
.byte 246
.byte 16
.byte 2
.ascii "or"
.word AddType
.byte 13
.byte 9
.byte 4
.ascii "orb"
.byte 0
.word AddType
.byte 12
.byte 8
.byte 3
.ascii "out"
.word InOutPort
.byte 231
.byte 0
.byte 5
.ascii "outb"
.byte 0
.word InOutPort
.byte 230
.byte 0
.byte 3
.ascii "pop"
.word PushPopType
.byte 143
.byte 9
.byte 4
.ascii "popf"
.word NothingElse
.byte 157
.byte 0
.byte 4
.ascii "push"
.word PushPopType
.byte 255
.byte 48
.byte 5
.ascii "pushf"
.word NothingElse
.byte 156
.byte 0
.byte 3
.ascii "rcl"
.word ShiftRotate
.byte 209
.byte 16
.byte 5
.ascii "rclb"
.byte 0
.word ShiftRotate
.byte 208
.byte 16
.byte 3
.ascii "rcr"
.word ShiftRotate
.byte 209
.byte 24
.byte 5
.ascii "rcrb"
.byte 0
.word ShiftRotate
.byte 208
.byte 24
.byte 3
.ascii "rep"
.word NothingElse
.byte 243
.byte 0
.byte 4
.ascii "repz"
.word NothingElse
.byte 243
.byte 0
.byte 5
.ascii "repnz"
.word NothingElse
.byte 242
.byte 0
.byte 3
.ascii "ret"
.word ReturnType
.byte 195
.byte 194
.byte 4
.ascii "retf"
.word ReturnType
.byte 203
.byte 202
.byte 3
.ascii "rol"
.word ShiftRotate
.byte 209
.byte 0
.byte 5
.ascii "rolb"
.byte 0
.word ShiftRotate
.byte 208
.byte 0
.byte 3
.ascii "ror"
.word ShiftRotate
.byte 209
.byte 8
.byte 5
.ascii "rorb"
.byte 0
.word ShiftRotate
.byte 208
.byte 8
.byte 4
.ascii "sahf"
.word NothingElse
.byte 158
.byte 0
.byte 3
.ascii "sal"
.word ShiftRotate
.byte 209
.byte 32
.byte 5
.ascii "salb"
.byte 0
.word ShiftRotate
.byte 208
.byte 32
.byte 3
.ascii "sar"
.word ShiftRotate
.byte 209
.byte 56
.byte 5
.ascii "sarb"
.byte 0
.word ShiftRotate
.byte 208
.byte 56
.byte 3
.ascii "sbb"
.word AddType
.byte 29
.byte 25
.byte 5
.ascii "sbbb"
.byte 0
.word AddType
.byte 28
.byte 24
.byte 5
.ascii "scasb"
.word NothingElse
.byte 174
.byte 0
.byte 5
.ascii "scasw"
.word NothingElse
.byte 175
.byte 0
.byte 3
.ascii "seg"
.word SegmentRegister
.byte 38
.byte 0
.byte 3
.ascii "shl"
.word ShiftRotate
.byte 209
.byte 32
.byte 5
.ascii "shlb"
.byte 0
.word ShiftRotate
.byte 208
.byte 32
.byte 3
.ascii "shr"
.word ShiftRotate
.byte 209
.byte 40
.byte 5
.ascii "shrb"
.byte 0
.word ShiftRotate
.byte 208
.byte 40
.byte 3
.ascii "stc"
.word NothingElse
.byte 249
.byte 0
.byte 3
.ascii "std"
.word NothingElse
.byte 253
.byte 0
.byte 3
.ascii "sti"
.word NothingElse
.byte 251
.byte 0
.byte 5
.ascii "stosb"
.word NothingElse
.byte 170
.byte 0
.byte 5
.ascii "stosw"
.word NothingElse
.byte 171
.byte 0
.byte 3
.ascii "sub"
.word AddType
.byte 45
.byte 41
.byte 5
.ascii "subb"
.byte 0
.word AddType
.byte 44
.byte 40
.byte 4
.ascii "test"
.word AddType
.byte 199
.byte 133
.byte 6
.ascii "testb"
.byte 0
.word AddType
.byte 199
.byte 132
.byte 4
.ascii "wait"
.word NothingElse
.byte 0155
.byte 0
.byte 4
.ascii "xchg"
.word XchgType
.byte 199
.byte 135
.byte 6
.ascii "xchgb"
.byte 0
.word XchgType
.byte 199
.byte 134
.byte 4
.ascii "xlat"
.word NothingElse
.byte 215
.byte 0
.byte 3
.ascii "xor"
.word AddType
.byte 53
.byte 49
.byte 5
.ascii "xorb"
.byte 0
.word AddType
.byte 52
.byte 48
.byte 0
|End of symbols.asm
AddressingModes:
.byte 1
|0fddwi.byte f,s .ascii j0fddwi.byte j
.byte 5
.ascii "bx_si"
.byte 00
.byte 5
.ascii "bx_di"
.byte 01
.byte 5
.ascii "bp_si"
.byte 02
.byte 5
.ascii "bp_di"
.byte 03
.byte 2
.ascii "si"
.byte 04
.byte 2
.ascii "di"
.byte 05
.byte 2
.ascii "bp"
.byte 06
.byte 2
.ascii "bx"
.byte 07
.byte 0
BigRegisters:
.byte 1
.byte 2
.ascii "ax"
.byte 0
.byte 2
.ascii "cx"
.byte 1
.byte 2
.ascii "dx"
.byte 2
.byte 2
.ascii "bx"
.byte 3
.byte 2
.ascii "sp"
.byte 4
.byte 2
.ascii "bp"
.byte 5
.byte 2
.ascii "si"
.byte 6
.byte 2
.ascii "di"
.byte 7
.byte 0
SmallRegisters:
.byte 1
.byte 2
.ascii "al"
.byte 0
.byte 2
.ascii "cl"
.byte 1
.byte 2
.ascii "dl"
.byte 2
.byte 2
.ascii "bl"
.byte 3
.byte 2
.ascii "ah"
.byte 4
.byte 2
.ascii "ch"
.byte 5
.byte 2
.ascii "dh"
.byte 6
.byte 2
.ascii "bh"
.byte 7
.byte 0
SegmentRegisters:
.byte 1
.byte 2
.ascii "es"
.byte 0
.byte 2
.ascii "cs"
.byte 1
.byte 2
.ascii "ss"
.byte 2
.byte 2
.ascii "ds"
.byte 3
.byte 0