-
Notifications
You must be signed in to change notification settings - Fork 1
/
playwav4.lst
6704 lines (6704 loc) · 417 KB
/
playwav4.lst
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
1 ; ****************************************************************************
2 ; PLAYWAV.ASM - ICH AC97 .wav player for DOS. PLAYWAV.COM
3 ; ----------------------------------------------------------------------------
4 ; Last Update: 19/05/2024 (Previous: 08/05/2024)
5 ; ----------------------------------------------------------------------------
6 ; Beginning: 17/02/2017
7 ; ----------------------------------------------------------------------------
8 ; Assembler: NASM version 2.15
9 ; nasm playwav.asm -l playwav.lst -o PLAYWAV.COM
10 ; ----------------------------------------------------------------------------
11 ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002
12 ; ****************************************************************************
13 ; Modidified from 'PLAYER.COM' for VIA VT8233 wav player source code by
14 ; (PLAYER.ASM) by Erdogan Tan (07/11/2016 - 08/12/2016)
15
16 ; TUNELOOP version (playing without AC97 interrupt) - 06/11/2023 - Erdogan Tan
17 ; sample rate conversion version - 18/11/2023 - Erdogan Tan
18
19 [BITS 16]
20
21 [ORG 100h]
22
23 %include 'ac97.inc' ; 17/02/2017
1 <1> ; 11/11/2023
2 <1> ; 05/11/2023
3 <1> ; 03/11/2023
4 <1> ; 17/02/2017 (Erdogan Tan, PLAYWAV.ASM)
5 <1> ; constant.inc & codec.inc (for ICH AC97 wav player, 'PLAYWAV.COM')
6 <1>
7 <1> ; ----------------------------------------------------------------------------
8 <1> ; CONSTANT.INC
9 <1> ; ----------------------------------------------------------------------------
10 <1>
11 <1> ;constants of stuff that seem hard to remember at times.
12 <1>
13 <1> TRUE EQU 1
14 <1> FALSE EQU 0
15 <1>
16 <1> ENABLED EQU 1
17 <1> DISABLED EQU 0
18 <1>
19 <1> BIT0 EQU 1
20 <1> BIT1 EQU 2
21 <1> BIT2 EQU 4
22 <1> BIT3 EQU 8
23 <1> BIT4 EQU 10h
24 <1> BIT5 EQU 20h
25 <1> BIT6 EQU 40h
26 <1> BIT7 EQU 80h
27 <1> BIT8 EQU 100h
28 <1> BIT9 EQU 200h
29 <1> BIT10 EQU 400h
30 <1> BIT11 EQU 800h
31 <1> BIT12 EQU 1000h
32 <1> BIT13 EQU 2000h
33 <1> BIT14 EQU 4000h
34 <1> BIT15 EQU 8000h
35 <1> BIT16 EQU 10000h
36 <1> BIT17 EQU 20000h
37 <1> BIT18 EQU 40000h
38 <1> BIT19 EQU 80000h
39 <1> BIT20 EQU 100000h
40 <1> BIT21 EQU 200000h
41 <1> BIT22 EQU 400000h
42 <1> BIT23 EQU 800000h
43 <1> BIT24 EQU 1000000h
44 <1> BIT25 EQU 2000000h
45 <1> BIT26 EQU 4000000h
46 <1> BIT27 EQU 8000000h
47 <1> BIT28 EQU 10000000h
48 <1> BIT29 EQU 20000000h
49 <1> BIT30 EQU 40000000h
50 <1> BIT31 EQU 80000000h
51 <1>
52 <1> ;special characters
53 <1> NUL EQU 0
54 <1> NULL EQU 0
55 <1> BELL EQU 07
56 <1> BS EQU 08
57 <1> TAB EQU 09
58 <1> LF EQU 10
59 <1> CR EQU 13
60 <1> ESCAPE EQU 27 ;ESC is a reserved word....
61 <1>
62 <1>
63 <1> ;file stuff
64 <1> READONLY EQU BIT0
65 <1> HIDDEN EQU BIT1
66 <1> SYSTEM EQU BIT2
67 <1> VOLUME EQU BIT3 ;ignored for file access
68 <1> DIRECTORY EQU BIT4 ;must be 0 for file access
69 <1> ARCHIVE EQU BIT5
70 <1> SHAREABLE EQU BIT7 ;for novell networks
71 <1> OPEN EQU 2 ; open existing file
72 <1> CREATE EQU 1 ; create new file
73 <1>
74 <1>
75 <1> ; PCI equates
76 <1> ; PCI function address (PFA)
77 <1> ; bit 31 = 1
78 <1> ; bit 23:16 = bus number (0-255)
79 <1> ; bit 15:11 = device number (0-31)
80 <1> ; bit 10:8 = function number (0-7)
81 <1> ; bit 7:0 = register number (0-255)
82 <1>
83 <1> IO_ADDR_MASK EQU 0FFFEh ; mask off bit 0 for reading BARs
84 <1> PCI_INDEX_PORT EQU 0CF8h
85 <1> PCI_DATA_PORT EQU 0CFCh
86 <1> PCI32 EQU BIT31 ; bitflag to signal 32bit access
87 <1> PCI16 EQU BIT30 ; bitflag for 16bit access
88 <1>
89 <1> PCI_FN0 EQU 0 << 8
90 <1> PCI_FN1 EQU 1 << 8
91 <1> PCI_FN2 EQU 2 << 8
92 <1> PCI_FN3 EQU 3 << 8
93 <1> PCI_FN4 EQU 4 << 8
94 <1> PCI_FN5 EQU 5 << 8
95 <1> PCI_FN6 EQU 6 << 8
96 <1> PCI_FN7 EQU 7 << 8
97 <1>
98 <1> PCI_CMD_REG EQU 04h ; reg 04, command reg
99 <1> IO_ENA EQU BIT0 ; i/o decode enable
100 <1> MEM_ENA EQU BIT1 ; memory decode enable
101 <1> BM_ENA EQU BIT2 ; bus master enable
102 <1>
103 <1> ; ----------------------------------------------------------------------------
104 <1> ; CODEC.INC
105 <1> ; ----------------------------------------------------------------------------
106 <1>
107 <1> ;Codec registers.
108 <1> ;
109 <1> ;Not all codecs are created equal. Refer to the spec for your specific codec.
110 <1> ;
111 <1> ;All registers are 16bits wide. Access to codec registers over the AC97 link
112 <1> ;is defined by the OEM.
113 <1> ;
114 <1> ;Secondary codec's are accessed by ORing in BIT7 of all register accesses.
115 <1> ;
116 <1>
117 <1> ; each codec/mixer register is 16bits
118 <1>
119 <1> CODEC_RESET_REG equ 00 ; reset codec
120 <1> CODEC_MASTER_VOL_REG equ 02 ; master volume
121 <1> CODEC_HP_VOL_REG equ 04 ; headphone volume
122 <1> CODEC_MASTER_MONO_VOL_REG equ 06 ; master mono volume
123 <1> CODEC_MASTER_TONE_REG equ 08 ; master tone (R+L)
124 <1> CODEC_PCBEEP_VOL_REG equ 0ah ; PC beep volume
125 <1> CODEC_PHONE_VOL_REG equ 0bh ; phone volume
126 <1> CODEC_MIC_VOL_REG equ 0eh ; MIC volume
127 <1> CODEC_LINE_IN_VOL_REG equ 10h ; line input volume
128 <1> CODEC_CD_VOL_REG equ 12h ; CD volume
129 <1> CODEC_VID_VOL_REG equ 14h ; video volume
130 <1> CODEC_AUX_VOL_REG equ 16h ; aux volume
131 <1> CODEC_PCM_OUT_REG equ 18h ; PCM output volume
132 <1> CODEC_RECORD_SELECT_REG equ 1ah ; record select input
133 <1> CODEC_RECORD_VOL_REG equ 1ch ; record volume
134 <1> CODEC_RECORD_MIC_VOL_REG equ 1eh ; record mic volume
135 <1> CODEC_GP_REG equ 20h ; general purpose
136 <1> CODEC_3D_CONTROL_REG equ 22h ; 3D control
137 <1> ; 24h is reserved
138 <1> CODEC_POWER_CTRL_REG equ 26h ; powerdown control
139 <1> CODEC_EXT_AUDIO_REG equ 28h ; extended audio
140 <1> CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control
141 <1> CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate
142 <1> CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate
143 <1> CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate
144 <1> CODEC_LR_ADCRATE_REG equ 32h ; PCM in sample rate
145 <1> CODEC_MIC_ADCRATE_REG equ 34h ; mic in sample rate
146 <1>
147 <1> ; registers 36-7a are reserved on the ICH
148 <1>
149 <1> CODEC_VENDORID1_REG equ 7ch ; codec vendor ID 1
150 <1> CODEC_VENDORID2_REG equ 7eh ; codec vendor ID 2
151 <1>
152 <1> ; Mixer registers 0 through 51h reside in the ICH and are not forwarded over
153 <1> ; the AC97 link to the codec, which I think is a little weird. Looks like
154 <1> ; the ICH makes it so you don't need a fully functional codec to play audio?
155 <1> ;
156 <1> ; whenever 2 codecs are present in the system, use BIT7 to access the 2nd
157 <1> ; set of registers, ie 80h-feh
158 <1>
159 <1> PRIMARY_CODEC equ 0 ; 0-7F for primary codec
160 <1> SECONDARY_CODEC equ BIT7 ; 80-8f registers for 2ndary
161 <1>
162 <1> SAMPLE_RATE_441khz equ 44100 ; 44.1Khz (cd quality) rate
163 <1>
164 <1> ; ----------------------------------------------------------------------------
165 <1> ; 17/02/2017
166 <1> PCI_IO_BASE equ 10h ; = NAMBAR register offset
167 <1> AC97_INT_LINE equ 3Ch ; AC97 Interrupt Line register offset
168 <1>
169 <1> ; ----------------------------------------------------------------------------
170 <1> ; ICH2AC97.INC
171 <1> ; ----------------------------------------------------------------------------
172 <1>
173 <1> ; PCI stuff
174 <1>
175 <1> ; Intel ICH2 equates. It is assumed that ICH0 and plain ole ICH are compatible.
176 <1>
177 <1> INTEL_VID equ 8086h ; Intel's PCI vendor ID
178 <1> ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
179 <1> SIS_VID equ 1039h
180 <1> NVIDIA_VID equ 10DEh ; Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source c.
181 <1> AMD_VID equ 1022h
182 <1>
183 <1> ICH_DID equ 2415h ; ICH device ID
184 <1> ICH0_DID equ 2425h ; ICH0
185 <1> ICH2_DID equ 2445h ; ICH2 I think there are more ICHes.
186 <1> ; they all should be compatible.
187 <1>
188 <1> ; 17/02/2017 (Erdogan Tan, ref: ALSA Device IDs, ALSA project)
189 <1> ICH3_DID equ 2485h ; ICH3
190 <1> ICH4_DID equ 24C5h ; ICH4
191 <1> ICH5_DID equ 24D5h ; ICH5
192 <1> ICH6_DID equ 266Eh ; ICH6
193 <1> ESB6300_DID equ 25A6h ; 6300ESB
194 <1> ESB631X_DID equ 2698h ; 631XESB
195 <1> ICH7_DID equ 27DEh ; ICH7
196 <1> ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
197 <1> MX82440_DID equ 7195h
198 <1> SI7012_DID equ 7012h
199 <1> NFORCE_DID equ 01B1h
200 <1> NFORCE2_DID equ 006Ah
201 <1> AMD8111_DID equ 746Dh
202 <1> AMD768_DID equ 7445h
203 <1> ; 03/11/2023 - Erdogan Tan - Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source code
204 <1> CK804_DID equ 0059h
205 <1> MCP04_DID equ 003Ah
206 <1> CK8_DID equ 008Ah
207 <1> NFORCE3_DID equ 00DAh
208 <1> CK8S_DID equ 00EAh
209 <1>
210 <1> NAMBAR_REG equ 10h ; native audio mixer BAR
211 <1> NAM_SIZE equ 256 ; 256 bytes required.
212 <1>
213 <1> NABMBAR_REG equ 14h ; native audio bus mastering BAR
214 <1> NABM_SIZE equ 64 ; 64 bytes
215 <1>
216 <1> ; BUS master registers, accessed via NABMBAR+offset
217 <1>
218 <1> ; ICH supports 3 different types of register sets for three types of things
219 <1> ; it can do, thus:
220 <1> ;
221 <1> ; PCM in (for recording) aka PI
222 <1> ; PCM out (for playback) aka PO
223 <1> ; MIC in (for recording) aka MC
224 <1>
225 <1> PI_BDBAR_REG equ 0 ; PCM in buffer descriptor BAR
226 <1> PO_BDBAR_REG equ 10h ; PCM out buffer descriptor BAR
227 <1> MC_BDBAR_REG equ 20h ; MIC in buffer descriptor BAR
228 <1>
229 <1> ; each buffer descriptor BAR holds a pointer which has entries to the buffer
230 <1> ; contents of the .WAV file we're going to play. Each entry is 8 bytes long
231 <1> ; (more on that later) and can contain 32 entries total, so each BAR is
232 <1> ; 256 bytes in length, thus:
233 <1>
234 <1> BDL_SIZE equ 32*8 ; Buffer Descriptor List size
235 <1> INDEX_MASK equ 31 ; indexes must be 0-31
236 <1>
237 <1>
238 <1>
239 <1> PI_CIV_REG equ 4 ; PCM in current Index value (RO)
240 <1> PO_CIV_REG equ 14h ; PCM out current Index value (RO)
241 <1> MC_CIV_REG equ 24h ; MIC in current Index value (RO)
242 <1> ;8bit read only
243 <1> ; each current index value is simply a pointer showing us which buffer
244 <1> ; (0-31) the codec is currently processing. Once this counter hits 31, it
245 <1> ; wraps back to 0.
246 <1> ; this can be handy to know, as once it hits 31, we're almost out of data to
247 <1> ; play back or room to record!
248 <1>
249 <1>
250 <1> PI_LVI_REG equ 5 ; PCM in Last Valid Index
251 <1> PO_LVI_REG equ 15h ; PCM out Last Valid Index
252 <1> MC_LVI_REG equ 25h ; MIC in Last Valid Index
253 <1> ;8bit read/write
254 <1> ; The Last Valid Index is a number (0-31) to let the codec know what buffer
255 <1> ; number to stop on after processing. It could be very nasty to play audio
256 <1> ; from buffers that aren't filled with the audio we want to play.
257 <1>
258 <1>
259 <1> PI_SR_REG equ 6 ; PCM in Status register
260 <1> PO_SR_REG equ 16h ; PCM out Status register
261 <1> MC_SR_REG equ 26h ; MIC in Status register
262 <1> ;16bit read/write
263 <1> ; status registers. Bitfields follow:
264 <1>
265 <1> FIFO_ERR equ BIT4 ; FIFO Over/Underrun W1TC.
266 <1>
267 <1> BCIS equ BIT3 ; buffer completion interrupt status.
268 <1> ; Set whenever the last sample in ANY
269 <1> ; buffer is finished. Bit is only
270 <1> ; set when the Interrupt on Complete
271 <1> ; (BIT4 of control reg) is set.
272 <1>
273 <1> LVBCI equ BIT2 ; Set whenever the codec has processed
274 <1> ; the last buffer in the buffer list.
275 <1> ; Will fire an interrupt if IOC bit is
276 <1> ; set. Probably set after the last
277 <1> ; sample in the last buffer is
278 <1> ; processed. W1TC
279 <1>
280 <1> ;
281 <1> CELV equ BIT1 ; Current buffer == last valid.
282 <1> ; Bit is RO and remains set until LVI is
283 <1> ; cleared. Probably set up the start
284 <1> ; of processing for the last buffer.
285 <1>
286 <1>
287 <1> DCH equ BIT0 ; DMA controller halted.
288 <1> ; set whenever audio stream is stopped
289 <1> ; or something else goes wrong.
290 <1>
291 <1>
292 <1> PI_PICB_REG equ 8 ; PCM in position in current buffer(RO)
293 <1> PO_PICB_REG equ 18h ; PCM out position in current buffer(RO)
294 <1> MC_PICB_REG equ 28h ; MIC in position in current buffer (RO)
295 <1> ;16bit read only
296 <1> ; position in current buffer regs show the number of dwords left to be
297 <1> ; processed in the current buffer.
298 <1> ;
299 <1>
300 <1> PI_PIV_REG equ 0ah ; PCM in Prefected index value
301 <1> PO_PIV_REG equ 1ah ; PCM out Prefected index value
302 <1> MC_PIV_REG equ 2ah ; MIC in Prefected index value
303 <1> ;8bit, read only
304 <1> ; Prefetched index value register.
305 <1> ; tells which buffer number (0-31) has be prefetched. I'd imagine this
306 <1> ; value follows the current index value fairly closely. (CIV+1)
307 <1> ;
308 <1>
309 <1>
310 <1> PI_CR_REG equ 0bh ; PCM in Control Register
311 <1> PO_CR_REG equ 1bh ; PCM out Control Register
312 <1> MC_CR_REG equ 2bh ; MIC in Control Register
313 <1> ; 8bit
314 <1> ; Control register *MUST* only be accessed as an 8bit value.
315 <1> ; Control register. See bitfields below.
316 <1> ;
317 <1>
318 <1>
319 <1> IOCE equ BIT4 ; interrupt on complete enable.
320 <1> ; set this bit if you want an intrtpt
321 <1> ; to fire whenever LVBCI is set.
322 <1> FEIFE equ BIT3 ; set if you want an interrupt to fire
323 <1> ; whenever there is a FIFO (over or
324 <1> ; under) error.
325 <1> LVBIE equ BIT2 ; last valid buffer interrupt enable.
326 <1> ; set if you want an interrupt to fire
327 <1> ; whenever the completion of the last
328 <1> ; valid buffer.
329 <1> RR equ BIT1 ; reset registers. Nukes all regs
330 <1> ; except bits 4:2 of this register.
331 <1> ; Only set this bit if BIT 0 is 0
332 <1> RPBM equ BIT0 ; Run/Pause
333 <1> ; set this bit to start the codec!
334 <1>
335 <1>
336 <1> GLOB_CNT_REG equ 2ch ; Global control register
337 <1> SEC_RES_EN equ BIT5 ; secondary codec resume event
338 <1> ; interrupt enable. Not used here.
339 <1> PRI_RES_EN equ BIT4 ; ditto for primary. Not used here.
340 <1> ACLINK_OFF equ BIT3 ; Turn off the AC97 link
341 <1> ACWARM_RESET equ BIT2 ; Awaken the AC97 link from sleep.
342 <1> ; registers preserved, bit self clears
343 <1> ACCOLD_RESET equ BIT1 ; Reset everything in the AC97 and
344 <1> ; reset all registers. Not self clearing
345 <1>
346 <1> GPIIE equ BIT0 ; GPI Interrupt enable.
347 <1> ; set if you want an interrupt to
348 <1> ; fire upon ANY of the bits in the
349 <1> ; GPI (general pursose inputs?) not used.
350 <1>
351 <1> GLOB_STS_REG equ 30h ; Global Status register (RO)
352 <1>
353 <1> MD3 equ BIT17 ; modem powerdown status (yawn)
354 <1> AD3 equ BIT16 ; Audio powerdown status (yawn)
355 <1> RD_COMPLETE_STS equ BIT15 ; Codec read timed out. 0=normal
356 <1> BIT3SLOT12 equ BIT14 ; shadowed status of bit 3 in slot 12
357 <1> BIT2SLOT12 equ BIT13 ; shadowed status of bit 2 in slot 12
358 <1> BIT1SLOT12 equ BIT12 ; shadowed status of bit 1 in slot 12
359 <1> SEC_RESUME_STS equ BIT11 ; secondary codec has resumed (and irqed)
360 <1> PRI_RESUME_STS equ BIT10 ; primary codec has resumed (and irqed)
361 <1> SEC_CODEC_RDY equ BIT9 ; secondary codec is ready for action
362 <1> PRI_CODEC_RDY equ BIT8 ; Primary codec is ready for action
363 <1> ; software must check these bits before
364 <1> ; starting the codec!
365 <1> MIC_IN_IRQ equ BIT7 ; MIC in caused an interrupt
366 <1> PCM_OUT_IRQ equ BIT6 ; One of the PCM out channels IRQed
367 <1> PCM_IN_IRQ equ BIT5 ; One of the PCM in channels IRQed
368 <1> MODEM_OUT_IRQ equ BIT2 ; modem out channel IRQed
369 <1> MODEM_IN_IRQ equ BIT1 ; modem in channel IRQed
370 <1> GPI_STS_CHANGE equ BIT0 ; set whenever GPI's have changed.
371 <1> ; BIT0 of slot 12 also reflects this.
372 <1>
373 <1> ACC_SEMA_REG equ 34h ; Codec write semiphore register
374 <1> CODEC_BUSY equ BIT0 ; codec register I/O is happening
375 <1> ; self clearing
376 <1> ;
377 <1> ; Buffer Descriptors List
378 <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32
379 <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
380 <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
381 <1> ; entry describe various control things detailed below.
382 <1> ;
383 <1> ; Buffer pointers must always be aligned on a Dword boundry.
384 <1> ;
385 <1>
386 <1> IOC equ BIT31 ; Fire an interrupt whenever this
387 <1> ; buffer is complete.
388 <1>
389 <1> BUP equ BIT30 ; Buffer Underrun Policy.
390 <1> ; if this buffer is the last buffer
391 <1> ; in a playback, fill the remaining
392 <1> ; samples with 0 (silence) or not.
393 <1> ; It's a good idea to set this to 1
394 <1> ; for the last buffer in playback,
395 <1> ; otherwise you're likely to get a lot
396 <1> ; of noise at the end of the sound.
397 <1>
398 <1> ;
399 <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
400 <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
401 <1> ; Luckily for us, that's the same format as .wav files.
402 <1> ;
403 <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
404 <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
405 <1> ;
406 <1> ; A value of 0 in these bits means play no samples.
407 <1> ;
408 <1>
409 <1> ; 11/11/2023
410 <1> CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready
411 <1> CODEC_REG_POWERDOWN equ 26h
24
25 _STARTUP:
26
27 ; memory allocation
28
29 00000000 E81D01 call setFree ; deallocate unused DOS mem
30
31 ; 17/02/2017
32 ; Clear BSS (uninitialized data) area
33 00000003 31C0 xor ax, ax ; 0
34 00000005 B9156E mov cx, (EOF - bss_start)/2
35 00000008 BF[351D] mov di, bss_start
36 0000000B F3AB rep stosw
37
38 ; allocate 256 bytes of data for DCM_OUT Buffer Descriptor List. (BDL)
39
40 0000000D B81000 mov ax, BDL_SIZE / 16
41 00000010 E81501 call memAlloc
42 00000013 A3[5A1D] mov [BDL_BUFFER], ax ; segment
43
44 ; allocate 2 buffers, 64k each for now.
45
46 00000016 B80010 mov ax, BUFFERSIZE / 16 ; 64k for .WAV file
47 00000019 E80C01 call memAlloc
48 0000001C A3[5C1D] mov [WAV_BUFFER1], ax ; segment
49
50 0000001F B80010 mov ax, BUFFERSIZE / 16
51 00000022 E80301 call memAlloc
52 00000025 A3[5E1D] mov [WAV_BUFFER2], ax
53
54 ; Detect/reset AC97
55
56 00000028 E87002 call pciFindDevice
57 0000002B 7342 jnc short _1
58
59 ; couldn't find the audio device!
60
61 0000002D 0E push cs
62 0000002E 1F pop ds
63 0000002F BA[3900] mov dx, noDevMsg
64 00000032 B409 mov ah, 9
65 00000034 CD21 int 21h
66 00000036 E9D700 jmp exit
67
68 ; 17/02/2017
69 00000039 4572726F723A20556E- noDevMsg db "Error: Unable to find intel ICH based audio device!",CR,LF,"$"
69 00000042 61626C6520746F2066-
69 0000004B 696E6420696E74656C-
69 00000054 204943482062617365-
69 0000005D 6420617564696F2064-
69 00000066 6576696365210D0A24
70
71 _1:
72 ; eax = BUS/DEV/FN
73 ; 00000000BBBBBBBBDDDDDFFF00000000
74 ; edx = DEV/VENDOR
75 ; DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
76
77 0000006F 66A3[601D] mov [bus_dev_fn], eax
78 00000073 668916[641D] mov [dev_vendor], edx
79
80 ; get ICH base address regs for mixer and bus master
81
82 00000078 B010 mov al, NAMBAR_REG
83 0000007A E89001 call pciRegRead16 ; read PCI registers 10-11
84 ;and dx, IO_ADDR_MASK ; mask off BIT0
85 ; 19/05/2024
86 0000007D 80E2FE and dl, 0FEh
87
88 00000080 8916[561D] mov [NAMBAR], dx ; save audio mixer base addr
89
90 00000084 B014 mov al, NABMBAR_REG
91 00000086 E88401 call pciRegRead16
92 ;and dx, IO_ADDR_MASK
93 ; 19/05/2024
94 00000089 80E2C0 and dl, 0C0h
95
96 0000008C 8916[581D] mov [NABMBAR], dx ; save bus master base addr
97
98 ; 06/11/2023
99 ;; init controller
100 ;; 17/02/2017
101 ;mov al, PCI_CMD_REG ; command register (04h)
102 ;call pciRegRead16 ; pciRegRead8
103 ;
104 ;; eax = BUS/DEV/FN/REG
105 ;; dx = PCI Command Register Content ; 17/02/2017
106 ;; 00000000CCCCCCCC
107 ;mov [stats_cmd], dx
108 ;
109 ; 06/11/2023
110 ;mov al, PCI_IO_BASE ; IO base address register (10h)
111 ;call pciRegRead32
112 ;
113 ;and dx, 0FFC0h ; IO_ADDR_MASK (0FFFE) ?
114 ;mov [ac97_io_base], dx
115
116 00000090 B03C mov al, AC97_INT_LINE ; Interrupt line register (3Ch)
117 00000092 E87001 call pciRegRead8 ; 17/02/2017
118
119 00000095 8816[551D] mov [ac97_int_ln_reg], dl
120
121 ; 05/11/2023
122 %if 0
123 ; 28/11/2016
124 mov bx, 1
125 xor dh, dh ; 17/02/2017
126 mov cx, dx
127 shl bx, cl
128
129 ; 04/11/2023
130 cli
131
132 ;not bx
133 in al, 0A1h ; irq 8-15
134 mov ah, al
135 in al, 21h ; irq 0-7
136
137 ; 04/11/2023
138 ; save IRQ status
139 mov [IRQ_status], ax
140
141 ;and ax, bx ; unmask
142 btr ax, dx ; unmask
143 out 21h, al ; enable interrupt (if irq <= 7)
144 mov al, ah
145 out 0A1h, al ; enable interrupt (if irq > 7)
146 ;not bx
147
148 ; 04/11/2023
149 ;mov dx, 4D1h ;8259 ELCR1
150 ;in al, dx
151 ;mov ah, al
152 ;mov dx, 4D0h
153 ;in al, dx
154 ;;or ax, bx
155 ;bts ax, cx
156 ;mov dx, 4D0h
157 ;out dx, al ;set level-triggered mode
158 ;mov al, ah
159 ;mov dx, 4D1h
160 ;out dx, al ;set level-triggered mode
161
162 ; 24/11/2016 - Erdogan Tan
163 mov bx, cx
164 ;mov bx, dx
165 mov bl, [bx+irq_int]
166 shl bx, 2 ; * 4
167
168 ; set up interrupt vector
169 ; 30/11/2016
170 push es
171 xor ax, ax
172 mov es, ax
173 ; 04/11/2023
174 ; save interrupt vector
175 mov ax, [es:bx]
176 mov [IRQ_vector], ax
177 mov ax, [es:bx+2]
178 mov [IRQ_vector+2], ax
179
180 mov word [es:bx], ac97_int_handler
181 mov ax, cs
182 mov [es:bx+2], ax
183 pop es
184
185 ; 04/11/2023
186 sti
187
188 %endif
189 00000099 E8F718 call write_ac97_dev_info
190
191 ; check the command line for a file to play
192
193 ;push ds
194 0000009C E89200 call processCmdline ; get the filename
195
196 ; open the file
197 0000009F B002 mov al, OPEN ; open existing file
198 000000A1 E8AD00 call openFile ; no error? ok.
199 ;pop ds
200 000000A4 7322 jnc short _gsr
201
202 ; file not found!
203
204 ;push cs
205 ;pop ds
206 000000A6 BA[AF00] mov dx, noFileErrMsg
207 000000A9 B409 mov ah, 9
208 000000AB CD21 int 21h
209 000000AD EB61 jmp exit
210
211 noFileErrMsg:
212 000000AF 4572726F723A206669- db "Error: file not found.",CR,LF,"$"
212 000000B8 6C65206E6F7420666F-
212 000000C1 756E642E0D0A24
213
214 _gsr:
215 000000C8 E8AD00 call getSampleRate ; read the sample rate
216 ; pass it onto codec.
217 000000CB 7243 jc short exit ; 19/11/2016 - nothing to do
218
219 000000CD A3[681D] mov [sample_rate], ax
220
221 ; 19/11/2016
222 000000D0 880E[6A1D] mov [stmo], cl
223 000000D4 8816[6C1D] mov [bps], dl
224
225 ; 17/02/2017
226 000000D8 C606[6E1D]00 mov byte [fbs_shift], 0 ; 0 = stereo and 16 bit
227 000000DD FEC9 dec cl
228 000000DF 7504 jnz short _gsr_1 ; stereo
229 000000E1 FE06[6E1D] inc byte [fbs_shift] ; 1 = mono or 8 bit
230 _gsr_1:
231 000000E5 80FA08 cmp dl, 8
232 000000E8 7704 ja short _gsr_2 ; 16 bit samples
233 000000EA FE06[6E1D] inc byte [fbs_shift] ; 2 = mono and 8 bit
234 _gsr_2:
235 000000EE E8F819 call write_sample_rate
236
237 ; 05/11/2023
238 _2:
239 000000F1 E83507 call check4keyboardstop ; flush keyboard buffer
240 000000F4 72FB jc short _2 ; 07/11/2023
241
242 ; 05/11/2023
243 ;mov eax, [bus_dev_fn]
244 ;mov al, PCI_CMD_REG
245 ;call pciRegRead16 ; read PCI command register
246 ; 17/02/2017
247 ;mov dx, [stats_cmd]
248 ;or dl, IO_ENA+BM_ENA ; enable IO and bus master
249 ;call pciRegWrite16 ; pciRegWrite8
250
251 ; 19/05/2024
252 ; 06/11/2023
253 ;mov eax, [bus_dev_fn]
254 ;mov al, PCI_CMD_REG
255 ;call pciRegRead8 ; read PCI command register
256 ;or dl, IO_ENA+BM_ENA ; enable IO and bus master
257 ;call pciRegWrite8
258
259 ; setup the Codec (actually mixer registers)
260 000000F6 E8E401 call codecConfig ; unmute codec, set rates.
261 ; 11/11/2023
262 000000F9 721C jc short init_err
263 ;
264 ; position file pointer to start in actual wav data
265 ; MUCH improvement should really be done here to check if sample size is
266 ; supported, make sure there are 2 channels, etc.
267 ;
268 000000FB B442 mov ah, 42h
269 000000FD B000 mov al, 0 ; from start of file
270 000000FF 8B1E[521D] mov bx, [filehandle]
271 00000103 31C9 xor cx, cx
272 00000105 BA2C00 mov dx, 44 ; jump past .wav/riff header
273 00000108 CD21 int 21h
274
275 ; play the .wav file. Most of the good stuff is in here.
276
277 0000010A E88503 call playWav
278
279 ; close the .wav file and exit.
280
281 close_exit: ; 11/11/2023
282 0000010D E85300 call closeFile
283
284 exit:
285 00000110 B8004C mov ax, 4c00h
286 00000113 CD21 int 21h
287
288 here:
289 00000115 EBFE jmp short here
290
291 ; 11/11/2023
292 init_err:
293 00000117 BA[CB1C] mov dx, msg_init_err
294 vra_err: ; 12/11/2023
295 0000011A B409 mov ah, 9
296 0000011C CD21 int 21h
297 0000011E EBED jmp short close_exit
298
299 ; MEMALLOC.ASM
300 ;-- SETFREE: Release memory not used ----------------
301 ;-- Input : ES = address of PSP
302 ;-- Output : none
303 ;-- Register : AX, BX, CL and FLAGS are changed
304 ;-- Info : Since the stack-segment is always the last segment in an
305 ; EXE-file, ES:0000 points to the beginning and SS:SP
306 ; to the end of the program in memory. Through this the
307 ; length of the program can be calculated
308 ; call this routine once at the beginning of the program to free up memory
309 ; assigned to it by DOS.
310
311 setFree:
312 00000120 BB0010 mov bx, 65536/16 ; 4K paragraphs ; 17/02/2017 (Erdogan Tan)
313
314 00000123 B44A mov ah, 4ah ;pass new length to DOS
315 00000125 CD21 int 21h
316
317 00000127 C3 retn ; back to caller
318 ; new size (allocated memory) = 64KB
319
320 memAlloc:
321 ; input: AX = # of paragraphs required
322 ; output: AX = segment of block to use
323
324 00000128 53 push bx
325 00000129 89C3 mov bx, ax
326 0000012B B448 mov ah, 48h
327 0000012D CD21 int 21h
328 0000012F 5B pop bx
329 00000130 C3 retn
330
331 ; CMDLINE.ASM
332 ; parse the command line
333 ; entry: none
334 ; exit: DS:DX to the 1st supplied item on the command line
335
336 processCmdline:
337 00000131 53 push bx
338 00000132 56 push si
339
340 ;mov ah, 51h
341 ;int 21h
342 ;mov ds, bx
343
344 00000133 BE8000 mov si, 80h
345 00000136 0FB61C movzx bx, byte [si]
346 00000139 01DE add si, bx
347 0000013B 46 inc si
348
349 0000013C C60400 mov byte [si], NULL ; zero terminate
350
351 0000013F BE8100 mov si, 81h
352
353 cmdlineloop:
354 00000142 AC lodsb
355
356 00000143 3C00 cmp al, NULL ; found end of line?
357 00000145 7404 je short exitpc
358 00000147 3C20 cmp al, ' ' ; found a space?
359 00000149 74F7 je short cmdlineloop
360
361 ; must be the filename here.
362 exitpc:
363 0000014B 4E dec si ; point to start of filename
364 0000014C 89F2 mov dx, si
365 0000014E 5E pop si
366 0000014F 5B pop bx
367 00000150 C3 retn
368
369 ; FILE.ASM
370 ;open or create file
371 ;
372 ;input: ds:dx-->filename (asciiz)
373 ; al=file Mode (create or open)
374 ;output: none cs:[filehandle] filled
375 ;
376 openFile:
377 00000151 50 push ax
378 00000152 51 push cx
379 00000153 B43B mov ah, 3bh ; start with a mode
380 00000155 00C4 add ah, al ; add in create or open mode
381 00000157 31C9 xor cx, cx
382 00000159 CD21 int 21h
383 0000015B 7203 jc short _of1
384 ;mov [cs:filehandle], ax
385 0000015D A3[521D] mov [filehandle], ax
386 _of1:
387 00000160 59 pop cx
388 00000161 58 pop ax
389 00000162 C3 retn
390
391 ; close the currently open file
392 ; input: none, uses cs:[filehandle]
393 closeFile:
394 00000163 50 push ax
395 00000164 53 push bx
396 00000165 833E[521D]FF cmp word [filehandle], -1
397 0000016A 7409 jz short _cf1
398 0000016C 8B1E[521D] mov bx, [filehandle]
399 00000170 B8003E mov ax,3e00h
400 00000173 CD21 int 21h ;close file
401 _cf1:
402 00000175 5B pop bx
403 00000176 58 pop ax
404 00000177 C3 retn
405
406 getSampleRate:
407 ; 08/12/2016
408 ; reads the sample rate from the .wav file.
409 ; entry: none - assumes file is already open
410 ; 19/11/2016 - Erdogan Tan
411 ; exit: ax = sample rate (11025, 22050, 44100, 48000)
412 ; cx = number of channels (mono=1, stereo=2)
413 ; dx = bits per sample (8, 16)
414
415 00000178 53 push bx
416
417 00000179 B442 mov ah, 42h
418 0000017B B000 mov al, 0 ; from start of file
419 0000017D 8B1E[521D] mov bx, [filehandle]
420 00000181 31C9 xor cx, cx
421 00000183 BA0800 mov dx, 08h ; "WAVE"
422 00000186 CD21 int 21h
423
424 00000188 BA[361D] mov dx, smpRBuff
425 0000018B B91C00 mov cx, 28 ; 28 bytes
426 0000018E B43F mov ah, 3fh
427 00000190 CD21 int 21h
428
429 00000192 813E[361D]5741 cmp word [smpRBuff], 'WA'
430 00000198 751C jne short gsr_stc
431
432 0000019A 813E[381D]5645 cmp word [smpRBuff+2], 'VE'
433 000001A0 7514 jne short gsr_stc
434
435 000001A2 833E[421D]01 cmp word [smpRBuff+12], 1 ; Offset 20, must be 1 (= PCM)
436 000001A7 750D jne short gsr_stc
437
438
439 000001A9 8B0E[441D] mov cx, [smpRBuff+14] ; return num of channels in CX
440 000001AD A1[461D] mov ax, [smpRBuff+16] ; return sample rate in AX
441 000001B0 8B16[501D] mov dx, [smpRBuff+26] ; return bits per sample value in DX
442 gsr_retn:
443 000001B4 5B pop bx
444 000001B5 C3 retn
445
446 gsr_stc:
447 000001B6 F9 stc
448 000001B7 EBFB jmp short gsr_retn
449
450 ;%include 'ac97.asm' ; 29/11/2016 (AC97 codec configuration)
451 %include 'ac97_vra.asm' ; 19/11/2023 (AC97 codec configuration)
1 <1> ; 19/05/2024
2 <1> ; 19/11/2023
3 <1> ; (ready status optimization -in order to prevent wrong init error- )
4 <1> ; 18/11/2023
5 <1> ; 15/11/2023
6 <1> ; 13/11/2023
7 <1> ; 12/11/2023
8 <1> ; 11/11/2023
9 <1> ; 03/11/2023 - 06/11/2023
10 <1> ; PCI and AC97 codec functions for wav player
11 <1> ; Erdogan Tan (17/02/2017)
12 <1>
13 <1> ; ----------------------------------------------------------------------------
14 <1> ; PCI.ASM
15 <1> ; ----------------------------------------------------------------------------
16 <1>
17 <1> ; PCI device register reader/writers.
18 <1> ; NASM version: Erdogan Tan (29/11/2016)
19 <1> ; Last Update: 17/02/2017
20 <1>
21 <1> ;===============================================================
22 <1> ; 8/16/32bit PCI reader
23 <1> ;
24 <1> ; Entry: EAX=PCI Bus/Device/fn/register number
25 <1> ; BIT30 set if 32 bit access requested
26 <1> ; BIT29 set if 16 bit access requested
27 <1> ; otherwise defaults to 8 bit read
28 <1> ;
29 <1> ; Exit: DL,DX,EDX register data depending on requested read size
30 <1> ;
31 <1> ; Note: this routine is meant to be called via pciRegRead8, pciRegread16,
32 <1> ; or pciRegRead32, listed below.
33 <1> ;
34 <1> ; Note2: don't attempt to read 32bits of data from a non dword aligned reg
35 <1> ; number. Likewise, don't do 16bit reads from non word aligned reg #
36 <1> ;
37 <1> pciRegRead:
38 000001B9 6653 <1> push ebx
39 000001BB 51 <1> push cx
40 000001BC 6689C3 <1> mov ebx, eax ; save eax, dh
41 000001BF 88F1 <1> mov cl, dh
42 000001C1 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
43 000001C7 660D00000080 <1> or eax, BIT31 ; make a PCI access request
44 000001CD 24FC <1> and al, ~3 ; NOT 3 ; force index to be dword
45 <1>
46 000001CF BAF80C <1> mov dx, PCI_INDEX_PORT
47 000001D2 66EF <1> out dx, eax ; write PCI selector
48 <1>
49 000001D4 BAFC0C <1> mov dx, PCI_DATA_PORT
50 000001D7 88D8 <1> mov al, bl
51 000001D9 2403 <1> and al, 3 ; figure out which port to
52 000001DB 00C2 <1> add dl, al ; read to
53 <1>
54 000001DD 66ED <1> in eax, dx ; do 32bit read
55 000001DF 66F7C300000080 <1> test ebx, PCI32
56 000001E6 7403 <1> jz short _pregr1
57 <1>
58 000001E8 6689C2 <1> mov edx, eax ; return 32bits of data
59 <1> _pregr1:
60 000001EB 89C2 <1> mov dx, ax ; return 16bits of data
61 000001ED 66F7C3000000C0 <1> test ebx, PCI32+PCI16
62 000001F4 7502 <1> jnz short _pregr2
63 000001F6 88CE <1> mov dh, cl ; restore dh for 8 bit read
64 <1> _pregr2:
65 000001F8 6689D8 <1> mov eax, ebx ; restore eax
66 000001FB 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
67 00000201 59 <1> pop cx
68 00000202 665B <1> pop ebx
69 00000204 C3 <1> retn
70 <1>
71 <1> pciRegRead8:
72 00000205 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 8 bit read size
73 0000020B EBAC <1> jmp short pciRegRead ; call generic PCI access
74 <1>
75 <1> pciRegRead16:
76 0000020D 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 16 bit read size
77 00000213 660D00000040 <1> or eax, PCI16 ; call generic PCI access
78 00000219 EB9E <1> jmp short pciRegRead
79 <1>
80 <1> pciRegRead32:
81 0000021B 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 32 bit read size
82 00000221 660D00000080 <1> or eax, PCI32 ; call generic PCI access
83 00000227 EB90 <1> jmp short pciRegRead
84 <1>
85 <1> ;===============================================================
86 <1> ; 8/16/32bit PCI writer
87 <1> ;
88 <1> ; Entry: EAX=PCI Bus/Device/fn/register number
89 <1> ; BIT31 set if 32 bit access requested
90 <1> ; BIT30 set if 16 bit access requested
91 <1> ; otherwise defaults to 8bit read
92 <1> ; DL/DX/EDX data to write depending on size
93 <1> ;
94 <1> ;
95 <1> ; note: this routine is meant to be called via pciRegWrite8, pciRegWrite16,
96 <1> ; or pciRegWrite32 as detailed below.
97 <1> ;
98 <1> ; Note2: don't attempt to write 32bits of data from a non dword aligned reg
99 <1> ; number. Likewise, don't do 16bit writes from non word aligned reg #
100 <1> ;
101 <1> pciRegWrite:
102 00000229 6653 <1> push ebx
103 0000022B 51 <1> push cx
104 0000022C 6689C3 <1> mov ebx, eax ; save eax, dx
105 0000022F 89D1 <1> mov cx, dx
106 00000231 660D00000080 <1> or eax, BIT31 ; make a PCI access request
107 00000237 6625FFFFFFBF <1> and eax, ~PCI16 ; NOT PCI16 ; clear out data size request
108 0000023D 24FC <1> and al, ~3 ; NOT 3 ; force index to be dword
109 <1>
110 0000023F BAF80C <1> mov dx, PCI_INDEX_PORT
111 00000242 66EF <1> out dx, eax ; write PCI selector
112 <1>
113 00000244 BAFC0C <1> mov dx, PCI_DATA_PORT
114 00000247 88D8 <1> mov al, bl
115 00000249 2403 <1> and al, 3 ; figure out which port to
116 0000024B 00C2 <1> add dl, al ; write to
117 <1>
118 0000024D 6689D0 <1> mov eax, edx ; put data into eax
119 00000250 89C8 <1> mov ax, cx
120 <1>
121 00000252 EE <1> out dx, al
122 00000253 66F7C3000000C0 <1> test ebx, PCI16+PCI32 ; only 8bit access? bail
123 0000025A 740C <1> jz short _pregw1
124 <1>
125 0000025C EF <1> out dx, ax ; write 16 bit value
126 0000025D 66F7C300000040 <1> test ebx, PCI16 ; 16bit requested? bail
127 00000264 7502 <1> jnz short _pregw1
128 <1>
129 00000266 66EF <1> out dx, eax ; write full 32bit
130 <1> _pregw1:
131 00000268 6689D8 <1> mov eax, ebx ; restore eax