-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqemm.asm
3105 lines (2302 loc) · 71.6 KB
/
sqemm.asm
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
; BUILD FLAGS - uncomment one
SCAMP_CHIPSET = 1
SCAT_CHIPSET = 2
HT18_CHIPSET = 3
HT12_CHIPSET = 4
HEDAKA_CHIPSET = 5
LOTECH_BOARD = 6
NEAT_CHIPSET = 7
INTEL_ABOVEBOARD = 8
SARC_RC2016A = 9
STANDARD_EMS_BOARD = 10
;COMPILE_CHIPSET = SCAMP_CHIPSET
;COMPILE_CHIPSET = SCAT_CHIPSET
;COMPILE_CHIPSET = HT18_CHIPSET
;COMPILE_CHIPSET = HT12_CHIPSET
;COMPILE_CHIPSET = HEDAKA_CHIPSET
;COMPILE_CHIPSET = LOTECH_BOARD
;COMPILE_CHIPSET = NEAT_CHIPSET
COMPILE_CHIPSET = INTEL_ABOVEBOARD
;COMPILE_CHIPSET = SARC_RC2016A
;COMPILE_CHIPSET = STANDARD_EMS_BOARD
IF COMPILE_CHIPSET EQ LOTECH_BOARD
.8086
ELSEIF COMPILE_CHIPSET EQ INTEL_ABOVEBOARD
.8086
ELSE
.286
ENDIF
.MODEL tiny
.DATA
CONST_HANDLE_TABLE_LENGTH = 0FFh
CONST_PAGE_COUNT = 256
; 80h represents 2 MB offset beyond EMS start point
SCAMP_PAGE_OFFSET_AMT = 68h
SCAMP_PAGE_SELECT_REGISTER = 0E8h
SCAMP_PAGE_SET_REGISTER = 0EAh
SCAMP_PAGE_FRAME_COUNT = 36
; 18h for D000. 1Ch for E000 if we were to use that.
SCAT_PAGE_REGISTER_OFFSET = 018h
SCAT_CHIPSET_CONFIG_REGISTER_SELECT = 022h
SCAT_CHIPSET_CONFIG_REGISTER_READWRITE = 023h
SCAT_EMS_CONFIG_REGISTER = 04Fh
SCAT_PAGE_SELECT_REGISTER = 020Ah
SCAT_PAGE_SET_REGISTER = 0208h
SCAT_PAGE_FRAME_COUNT = 32
; 8000 is to mark bit 15 for free "ems enabled"
; 0080 is [currently hardcoded] 2 MB offset for beginning of EMS pagination,
SCAT_PAGE_OFFSET_AMT = 08080h
SCAT_CHIPSET_UNMAP_VALUE = 03FFh
; 1Ch for D000. 18h for C000 if we were to use that.
HT18_PAGE_REGISTER_OFFSET = 01Ch
HT18_EMS_CONFIG_REGISTER = 00h
HT18_CHIPSET_CONFIG_REGISTER_SELECT = 1EDh
HT18_CHIPSET_CONFIG_REGISTER_READWRITE = 1EFh
; todo correct?
HT18_PAGE_OFFSET_AMT = 0280h
HT18_PAGE_SELECT_REGISTER = 01EEh
HT18_PAGE_SET_REGISTER = 01ECh
HT18_PAGE_FRAME_COUNT = 32
HT18_CHIPSET_UNMAP_VALUE = 0000h
HEDAKA_PAGE_REGISTER_0 = 00208h
HEDAKA_PAGE_REGISTER_1 = 04208h
HEDAKA_PAGE_REGISTER_2 = 08208h
HEDAKA_PAGE_REGISTER_3 = 0C208h
; A8 puts us right after 9c00...
; chipset doesnt seem to allow for more than 2MB EMS addressable INCLUDING conventional memory (?)
HEDAKA_PAGE_OFFSET_AMT = 0B8h
HEDAKA_PAGE_FRAME_COUNT = 4
; no real unmap support?
HEDAKA_CHIPSET_UNMAP_VALUE = 7Fh
HEDAKA_CONST_PAGE_COUNT = 72
HT12_PAGE_REGISTER_0 = 020h
HT12_PAGE_REGISTER_1 = 021h
HT12_PAGE_REGISTER_2 = 022h
HT12_PAGE_REGISTER_3 = 023h
HT12_EMS_CONFIG_REGISTER = 019h
HT12_CHIPSET_CONFIG_REGISTER_SELECT = 1EDh
HT12_CHIPSET_CONFIG_REGISTER_READWRITE = 1EFh
HT12_PAGE_OFFSET_AMT = 48h
HT12_PAGE_SELECT_REGISTER = 01EDh
HT12_PAGE_SET_REGISTER = 01EFh
HT12_PAGE_FRAME_COUNT = 4
LOTECH_PAGE_REGISTER_0 = 0260h
LOTECH_PAGE_REGISTER_1 = 0261h
LOTECH_PAGE_REGISTER_2 = 0262h
LOTECH_PAGE_REGISTER_3 = 0263h
LOTECH_CHIPSET_UNMAP_VALUE = 0FFh
LOTECH_PAGE_FRAME_COUNT = 4
LOTECH_CONST_PAGE_COUNT = 128
NEAT_CHIPSET_CONFIG_REGISTER_SELECT = 022h
NEAT_CHIPSET_CONFIG_REGISTER_READWRITE = 023h
NEAT_PAGE_REGISTER_0 = 00208h
NEAT_PAGE_REGISTER_1 = 04208h
NEAT_PAGE_REGISTER_2 = 08208h
NEAT_PAGE_REGISTER_3 = 0C208h
NEAT_PAGE_OFFSET_AMT = 080h
NEAT_PAGE_FRAME_COUNT = 4
; no real unmap support?
NEAT_CHIPSET_UNMAP_VALUE = 7Fh
NEAT_CONST_PAGE_COUNT = 128
; this is for 240 settings..
INTEL_AB_ENABLE_REGISTER = 0024Fh
INTEL_AB_4000_REGISTER = 00240h
INTEL_AB_PAGE_REGISTER_0 = 00248h
INTEL_AB_PAGE_REGISTER_1 = 04248h
INTEL_AB_PAGE_REGISTER_2 = 08248h
INTEL_AB_PAGE_REGISTER_3 = 0C248h
INTEL_AB_PAGE_OFFSET_AMT = 0A0h
INTEL_AB_CHIPSET_UNMAP_VALUE = 00h
INTEL_AB_PAGE_FRAME_COUNT = 28
INTEL_AB_CONST_PAGE_COUNT = 96
SARC_RC2016_CHIPSET_INDEX_PORT = 022h
SARC_RC2016_CHIPSET_VALUE_PORT = 023h
SARC_RC2016_PAGE_REGISTER_0 = 088h
SARC_RC2016_PAGE_REGISTER_1 = 08Ah
SARC_RC2016_PAGE_REGISTER_2 = 08Ch
SARC_RC2016_PAGE_REGISTER_3 = 08Eh
; sets pages d000, d400, d800, dc00 to
SARC_RC2016_BASE_PAGE_REGISTER_0 = 0c4h
SARC_RC2016_PAGE_OFFSET_AMT = 020h
SARC_RC2016_CHIPSET_UNMAP_VALUE = 00h
SARC_RC2016_PAGE_FRAME_COUNT = 4
SARC_RC2016_CONST_PAGE_COUNT = 128
; for standard lim ems 3.2 style boards with page frame and usually 2 mb.
; this can be 208h, 218h, etc... todo parse port, etc
STANDARD_BOARD_PAGE_REGISTER_0 = 00208h
STANDARD_BOARD_PAGE_REGISTER_1 = 04208h
STANDARD_BOARD_PAGE_REGISTER_2 = 08208h
STANDARD_BOARD_PAGE_REGISTER_3 = 0C208h
STANDARD_BOARD_PAGE_OFFSET_AMT = 080h
STANDARD_BOARD_PAGE_FRAME_COUNT = 4
; no real unmap support?
STANDARD_BOARD_CHIPSET_UNMAP_VALUE = 00h
STANDARD_BOARD_CONST_PAGE_COUNT = 128
.CODE
;00000h
dw 0FFFFh
dw 0FFFFh
dw 8000h
;dw 6200h
dw OFFSET EMS_DRIVER_INIT
;dw 6D00h
dw OFFSET EMS_DRIVER_CALL
;0000Ah
db 'EMMXXXX0 DTK VL82C311 Expended Memory Manager V 1.03 06/29/92'
;00048h
pointer_to_ems_init dw OFFSET DRIVER_INIT
;0004Ah various pointers to various possible entry points - most go to "unrecognized command"
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
;00054h Seems to be the pointer used in ems_driver_call?
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_SUCCESS
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
dw OFFSET RETURN_UNRECOGNIZED_COMMAND
; 00062h
EMS_DRIVER_INIT:
; store 32 bit pointer to reques theader
mov word ptr cs:[request_header_pointer], bx
mov word ptr cs:[request_header_pointer+2], es
retf
; todo clean this up
EMS_DRIVER_CALL:
push dx
push cx
push bx
push ax
push si
push di
push ds
push es
push bp
push cs
pop ds
mov bx, ds:word ptr [request_header_pointer]
mov es, ds:word ptr [request_header_pointer+2]
mov ax, word ptr es:[bx + 2]
mov ah, 0
cmp al, 0ch
jb CHECK_SOMETHING_IN_PARAMS ; not sure what we're checking or doing here exactly...
mov al, 0ch
CHECK_SOMETHING_IN_PARAMS:
shl ax, 1
mov si, OFFSET pointer_to_ems_init
add si, ax
call word ptr [si]
pop bp
pop es
pop ds
pop di
pop si
pop ax
pop bx
pop cx
pop dx
retf
;0009Fh
RETURN_SUCCESS:
mov word ptr [bx + 3], 0100h
ret
;000a5h
RETURN_UNRECOGNIZED_COMMAND:
mov word ptr [bx + 3], 08103h
ret
; Two-word pairs. first word is page frame (04000h, 04400h... etc) up to f000.
; second word its physical ems index port
; 144 bytes long
; i think a clone of the above struct in practice except pre-formatted for return in function 5800h (2nd arg a word, ordered lowest segment first)
; CHIPSET SPECIFIC START
mappable_phys_page_struct:
IF COMPILE_CHIPSET EQ SCAMP_CHIPSET
; you can hardcode the chipset's mappable page list here for call 5800
dw 04000h, 000Ch, 04400h, 000Dh, 04800h, 000Eh, 04C00h, 000Fh
dw 05000h, 0010h, 05400h, 0011h, 05800h, 0012h, 05C00h, 0013h
dw 06000h, 0014h, 06400h, 0015h, 06800h, 0016h, 06C00h, 0017h
dw 07000h, 0018h, 07400h, 0019h, 07800h, 001Ah, 07C00h, 001Bh
dw 08000h, 001Ch, 08400h, 001Dh, 08800h, 001Eh, 08C00h, 001Fh
dw 09000h, 0020h, 09400h, 0021h, 09800h, 0022h, 09C00h, 0023h
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
dw 0E000h, 0004h, 0E400h, 0005h, 0E800h, 0006h, 0EC00h, 0007h
dw 0C000h, 0008h, 0C400h, 0009h, 0C800h, 000Ah, 0CC00h, 000Bh
ELSEIF COMPILE_CHIPSET EQ SCAT_CHIPSET
dw 04000h, 0000h, 04400h, 0001h, 04800h, 0002h, 04C00h, 0003h
dw 05000h, 0004h, 05400h, 0005h, 05800h, 0006h, 05C00h, 0007h
dw 06000h, 0008h, 06400h, 0009h, 06800h, 000Ah, 06C00h, 000Bh
dw 07000h, 000Ch, 07400h, 000Eh, 07800h, 000Eh, 07C00h, 000Fh
dw 08000h, 0010h, 08400h, 0011h, 08800h, 0012h, 08C00h, 0013h
dw 09000h, 0014h, 09400h, 0015h, 09800h, 0016h, 09C00h, 0017h
dw 0D000h, 0018h, 0D400h, 0019h, 0D800h, 001Ah, 0DC00h, 001Bh
dw 0E000h, 001Ch, 0E400h, 001Dh, 0E800h, 001Eh, 0EC00h, 001Fh
ELSEIF COMPILE_CHIPSET EQ HT18_CHIPSET
dw 04000h, 0000h, 04400h, 0001h, 04800h, 0002h, 04C00h, 0003h
dw 05000h, 0004h, 05400h, 0005h, 05800h, 0006h, 05C00h, 0007h
dw 06000h, 0008h, 06400h, 0009h, 06800h, 000Ah, 06C00h, 000Bh
dw 07000h, 000Ch, 07400h, 000Eh, 07800h, 000Eh, 07C00h, 000Fh
dw 08000h, 0010h, 08400h, 0011h, 08800h, 0012h, 08C00h, 0013h
dw 09000h, 0014h, 09400h, 0015h, 09800h, 0016h, 09C00h, 0017h
dw 0C000h, 0018h, 0C400h, 0019h, 0C800h, 001Ah, 0CC00h, 001Bh
dw 0D000h, 001Ch, 0D400h, 001Dh, 0D800h, 001Eh, 0DC00h, 001Fh
ELSEIF COMPILE_CHIPSET EQ HT12_CHIPSET
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
ELSEIF COMPILE_CHIPSET EQ HEDAKA_CHIPSET
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
ELSEIF COMPILE_CHIPSET EQ LOTECH_BOARD
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
ELSEIF COMPILE_CHIPSET EQ NEAT_CHIPSET
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
ELSEIF COMPILE_CHIPSET EQ INTEL_ABOVEBOARD
dw 04000h, 0000h, 04400h, 0001h, 04800h, 0002h, 04C00h, 0003h
dw 05000h, 0004h, 05400h, 0005h, 05800h, 0006h, 05C00h, 0007h
dw 06000h, 0008h, 06400h, 0009h, 06800h, 000Ah, 06C00h, 000Bh
dw 07000h, 000Ch, 07400h, 000Eh, 07800h, 000Eh, 07C00h, 000Fh
dw 08000h, 0010h, 08400h, 0011h, 08800h, 0012h, 08C00h, 0013h
dw 09000h, 0014h, 09400h, 0015h, 09800h, 0016h, 09C00h, 0017h
dw 0E000h, 0018h, 0E400h, 0019h, 0E800h, 001Ah, 0EC00h, 001Bh
default_page_struct:
db 090h, 091h, 092h, 093h
db 094h, 095h, 096h, 097h
db 098h, 099h, 09Ah, 09Bh
db 09Ch, 09Dh, 09Eh, 09Fh
db 080h, 081h, 082h, 083h
db 084h, 085h, 086h, 087h
db 08Ch, 08Dh, 08Eh, 08Fh
ELSEIF COMPILE_CHIPSET EQ SARC_RC2016A
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
ELSEIF COMPILE_CHIPSET EQ STANDARD_EMS_BOARD
dw 0D000h, 0000h, 0D400h, 0001h, 0D800h, 0002h, 0DC00h, 0003h
ENDIF
; CHIPSET SPECIFIC END
; 32-bit pointer to arguments to driver
request_header_pointer dd 00000000h
; segment of pageframe
page_frame_segment dw 0000h
; used to hold a jump addr. could maybe be combined with another temp
temporary_jump_addr dw 0000h
; number of ems handles..
handle_count dw 0000h
; stores total logical page count
total_page_count dw 0000h
; stores unallocated logical page count
unallocated_page_count dw 0000h;
; number of (physically) addressable pages. eg usually 4 for 3.2 style hardware, 28+ for 4.0 style hardware
pageable_frame_count dw 0000h
; EMS Function pointer table
EMS_FUNCTION_POINTERS:
dw OFFSET EMS_FUNCTION_040h
dw OFFSET EMS_FUNCTION_041h
dw OFFSET EMS_FUNCTION_042h
dw OFFSET EMS_FUNCTION_043h
dw OFFSET EMS_FUNCTION_044h
dw OFFSET EMS_FUNCTION_045h
dw OFFSET EMS_FUNCTION_046h
dw OFFSET EMS_FUNCTION_047h
dw OFFSET EMS_FUNCTION_048h
dw OFFSET EMS_FUNCTION_049h
dw OFFSET EMS_FUNCTION_04ah
dw OFFSET EMS_FUNCTION_04bh
dw OFFSET EMS_FUNCTION_04ch
dw OFFSET EMS_FUNCTION_04dh
dw OFFSET EMS_FUNCTION_04eh
dw OFFSET EMS_FUNCTION_04fh
dw OFFSET EMS_FUNCTION_050h
dw OFFSET EMS_FUNCTION_051h
dw OFFSET EMS_FUNCTION_052h
dw OFFSET EMS_FUNCTION_053h
dw OFFSET EMS_FUNCTION_054h
dw OFFSET EMS_FUNCTION_055h
dw OFFSET EMS_FUNCTION_056h
dw OFFSET EMS_FUNCTION_057h
dw OFFSET EMS_FUNCTION_058h
dw OFFSET EMS_FUNCTION_059h
dw OFFSET EMS_FUNCTION_05ah
dw OFFSET EMS_FUNCTION_05bh
dw OFFSET EMS_FUNCTION_05ch
dw OFFSET EMS_FUNCTION_05dh
; BEEP function. unused?
;BEEP:
;push ax
;mov ax, 0e07h
;int 010h
;pop ax
;ret
MAIN_EMS_INTERRUPT_VECTOR:
; inline the main function(s) here.
cmp ah, 050h
jne NOT_FUNC_50h
; CHIPSET SPECIFIC START
; implement the inlined function 50 and/or 44 for pagination
; namely, change the registers that are being written to,
; properly handle the 'unmap' case with bx = FFFF/-1, and
; otherwise offset registers if necessary. For example, in the
; case of SCAMP we must offset page registers by 50h or so to
; avoid them mapping to default conventional memory ranges.
EMS_FUNCTION_050h:
IF COMPILE_CHIPSET EQ SCAMP_CHIPSET
push cx
push bx
push si
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
mov bx, ax
lodsw
; read two words - bx and ax
cmp ax, 12
; default, lets assume backfill
jb PAGEFRAME_REGISTER_5000
out SCAMP_PAGE_SELECT_REGISTER, al ; select EMS page
cmp bx, 0FFFFh ; -1 check
je handle_default_page_with_add
; default is not the -1 case
mov ax, bx
add ax, SCAMP_PAGE_OFFSET_AMT ; offset by default starting page
out SCAMP_PAGE_SET_REGISTER, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; exits if we fall thru loop with no error
xor ax, ax
pop si
pop bx
pop cx
iret
PAGEFRAME_REGISTER_5000:
add ax, 4 ; need to add 4 for d000 case for scamp... c000, e000 not supported
out SCAMP_PAGE_SELECT_REGISTER, al ; select EMS page
cmp bx, 0FFFFh ; -1 check
je handle_default_page
mov ax, bx
add ax, SCAMP_PAGE_OFFSET_AMT ; offset by default starting page
out SCAMP_PAGE_SET_REGISTER, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; exits if we fall thru loop with no error
xor ax, ax
pop si
pop bx
pop cx
iret
handle_default_page_with_add:
add ax, 4
handle_default_page:
; mapping to page -1
out SCAMP_PAGE_SET_REGISTER, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; fall thru if done..
xor ax, ax
pop si
pop bx
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ SCAT_CHIPSET
push cx
push bx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
mov bx, ax
lodsw
; read two words - bx and ax
mov dx, SCAT_PAGE_SELECT_REGISTER
out dx, al ; select EMS page
mov dx, SCAT_PAGE_SET_REGISTER
cmp bx, 0FFFFh ; -1 check
je handle_default_page
mov ax, SCAT_PAGE_OFFSET_AMT ; offset by default starting page
add ax, bx
out dx, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
handle_default_page:
; mapping to page -1
mov ax, SCAT_CHIPSET_UNMAP_VALUE
out dx, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ HT18_CHIPSET
push cx
push bx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
mov bx, ax
lodsw
; read two words - bx and ax
mov dx, HT18_PAGE_SELECT_REGISTER
out dx, al ; select EMS page
mov dx, HT18_PAGE_SET_REGISTER
cmp bx, 0FFFFh ; -1 check
je handle_default_page
mov ax, HT18_PAGE_OFFSET_AMT ; offset by default starting page
add ax, bx
out dx, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
handle_default_page:
; mapping to page -1
mov ax, HT18_CHIPSET_UNMAP_VALUE
out dx, ax ; write 16 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ HT12_CHIPSET
push cx
push si
push dx
push bx
; physical page number mode
DO_NEXT_PAGE_5000:
; preselect the register for the page on/off
mov dx, HT12_CHIPSET_CONFIG_REGISTER_SELECT
mov ax, HT12_EMS_CONFIG_REGISTER
out dx, al
mov dx, HT12_CHIPSET_CONFIG_REGISTER_READWRITE
in al, dx ; read in the port. we are going to AND the page on...
mov bl, al ; store value in bl..
; lets load next argument.
lodsw
push cx
mov cl, al
; read two words - dx and ax
mov dl, 1
sal dl, cl ; turn on the bit for this page
lodsw
; bl has previous config register contents
; cl has page number
; dl is ready to be ored etc
cmp ax, 0FFFFh ; -1 check
je handle_default_page
xchg ax, bx
or al, dl ; page is turned on
mov dx, HT12_CHIPSET_CONFIG_REGISTER_READWRITE
out dx, al ; page has been turned on (in case it was off)
mov ax, cx
add al, HT12_PAGE_REGISTER_0 ; add by page 0 offset
mov dx, HT12_CHIPSET_CONFIG_REGISTER_SELECT
out dx, al ; select page
mov dx, HT12_CHIPSET_CONFIG_REGISTER_READWRITE
mov ax, bx
add al, HT12_PAGE_OFFSET_AMT
out dx, al ; write page
pop cx
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop bx
pop dx
pop si
pop cx
iret
handle_default_page:
; mapping to page -1
mov al, bl
not dl
and al, dl ; page is turned off
mov dx, HT12_CHIPSET_CONFIG_REGISTER_READWRITE
out dx, al ; page has been turned on (in case it was off)
pop cx
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop bx
pop dx
pop si
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ HEDAKA_CHIPSET
push cx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
mov dx, ax
lodsw
; read two words - bx and ax
ror ax, 2
; 0-4 becomes 0208, 4208, 8208, c208
add ax, HEDAKA_PAGE_REGISTER_0
xchg dx, ax
cmp ax, 0FFFFh ; -1 check
je handle_default_page
add ax, HEDAKA_PAGE_OFFSET_AMT ; turn on EMS ON bit and add conventional offset
out dx, al ; write 8 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop cx
iret
handle_default_page:
; mapping to page -1
mov ax, HEDAKA_CHIPSET_UNMAP_VALUE
out dx, al ; write 8 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ LOTECH_BOARD
push cx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
add ax, LOTECH_PAGE_REGISTER_0
mov dx, ax
lodsw
out dx, al ; write 8 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ NEAT_CHIPSET
push cx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
mov dx, ax
lodsw
; read two words - bx and ax
ror ax, 2
; 0-4 becomes 0208, 4208, 8208, c208
add ax, NEAT_PAGE_REGISTER_0
xchg dx, ax
cmp ax, 0FFFFh ; -1 check
je handle_default_page
add ax, NEAT_PAGE_OFFSET_AMT ; turn on EMS ON bit
out dx, al ; write 8 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop cx
iret
handle_default_page:
; mapping to page -1
mov ax, NEAT_CHIPSET_UNMAP_VALUE
out dx, al ; write 8 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ SARC_RC2016A
push cx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
mov dx, ax
lodsw
cmp dx, 0FFFFh
je handle_default_page
mov ah, al
sal al, 1
add al, SARC_RC2016_PAGE_REGISTER_0
out SARC_RC2016_CHIPSET_INDEX_PORT, al
mov al, ah
add al, 0C4h ; pages 0-4 map to d000-dc000
mov ah, dl
and ah, 03h
sal ah, 4
add al, ah
out SARC_RC2016_CHIPSET_VALUE_PORT, al
and al, 03h ; restore page number
sal al, 1
add al, SARC_RC2016_PAGE_REGISTER_0 + 1
out SARC_RC2016_CHIPSET_INDEX_PORT, al
mov ax, dx
sar ax, 2
add ax, SARC_RC2016_PAGE_OFFSET_AMT
out SARC_RC2016_CHIPSET_VALUE_PORT, al
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop cx
iret
handle_default_page:
; mapping to page -1
; dx is scratch, ax is page
mov dx, ax
add dx, SARC_RC2016_PAGE_REGISTER_0
add dx, ax
xchg dx, ax
; select page register
out SARC_RC2016_CHIPSET_INDEX_PORT, al
inc ax ; dx has next register
xchg dx, ax
mov al, 0h
out SARC_RC2016_CHIPSET_VALUE_PORT, al
xchg dx, ax
out SARC_RC2016_CHIPSET_INDEX_PORT, al
xor ax, ax
out SARC_RC2016_CHIPSET_VALUE_PORT, al
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop bx
pop cx
iret
ELSEIF COMPILE_CHIPSET EQ INTEL_ABOVEBOARD
push cx
push si
push dx
; physical page number mode
DO_NEXT_PAGE_5000:
; next page in ax....
lodsw
; 0: 240, 1: 4240, 2: 8240, 3: C240...
; 4: 241, 5: 4241, 6: 8241, 7: C241...
; 8: 242, 9: 4242, A: 8242, B: C242...
; get port number
mov dx, ax
lodsw
cmp dx, 0FFFFh ; -1 check
je handle_default_page
ror ax, 1
ror ax, 1
add ax, INTEL_AB_4000_REGISTER
xchg dx, ax
add al, INTEL_AB_PAGE_OFFSET_AMT
out dx, al ; write 8 bit page num.
loop DO_NEXT_PAGE_5000
; exit fall thru
xor ax, ax
pop dx
pop si
pop cx
iret
handle_default_page:
; mapping to page -1
; get the value again
mov dx, ax
ror ax, 1
ror ax, 1
add ax, INTEL_AB_4000_REGISTER
xchg dx, ax
cmp al, 010h
jae gte_8000
add al, 90h