-
Notifications
You must be signed in to change notification settings - Fork 1
/
playwav2.lst
3451 lines (3451 loc) · 218 KB
/
playwav2.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
18 [BITS 16]
19
20 [ORG 100h]
21
22 %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
23
24 _STARTUP:
25
26 ; memory allocation
27
28 00000000 E81D01 call setFree ; deallocate unused DOS mem
29
30 ; 17/02/2017
31 ; Clear BSS (uninitialized data) area
32 00000003 31C0 xor ax, ax ; 0
33 00000005 B91D40 mov cx, (EOF - bss_start)/2
34 00000008 BF[700A] mov di, bss_start
35 0000000B F3AB rep stosw
36
37 ; allocate 256 bytes of data for DCM_OUT Buffer Descriptor List. (BDL)
38
39 0000000D B81000 mov ax, BDL_SIZE / 16
40 00000010 E81501 call memAlloc
41 00000013 A3[940A] mov [BDL_BUFFER], ax ; segment
42
43 ; allocate 2 buffers, 64k each for now.
44
45 00000016 B80010 mov ax, BUFFERSIZE / 16 ; 64k for .WAV file
46 00000019 E80C01 call memAlloc
47 0000001C A3[960A] mov [WAV_BUFFER1], ax ; segment
48
49 0000001F B80010 mov ax, BUFFERSIZE / 16
50 00000022 E80301 call memAlloc
51 00000025 A3[980A] mov [WAV_BUFFER2], ax
52
53 ; Detect/reset AC97
54
55 00000028 E87002 call pciFindDevice
56 0000002B 7342 jnc short _1
57
58 ; couldn't find the audio device!
59
60 0000002D 0E push cs
61 0000002E 1F pop ds
62 0000002F BA[3900] mov dx, noDevMsg
63 00000032 B409 mov ah, 9
64 00000034 CD21 int 21h
65 00000036 E9D700 jmp exit
66
67 ; 17/02/2017
68 00000039 4572726F723A20556E- noDevMsg db "Error: Unable to find intel ICH based audio device!",CR,LF,"$"
68 00000042 61626C6520746F2066-
68 0000004B 696E6420696E74656C-
68 00000054 204943482062617365-
68 0000005D 6420617564696F2064-
68 00000066 6576696365210D0A24
69
70 _1:
71 ; eax = BUS/DEV/FN
72 ; 00000000BBBBBBBBDDDDDFFF00000000
73 ; edx = DEV/VENDOR
74 ; DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
75
76 0000006F 66A3[9A0A] mov [bus_dev_fn], eax
77 00000073 668916[9E0A] mov [dev_vendor], edx
78
79 ; get ICH base address regs for mixer and bus master
80
81 00000078 B010 mov al, NAMBAR_REG
82 0000007A E89001 call pciRegRead16 ; read PCI registers 10-11
83 ;and dx, IO_ADDR_MASK ; mask off BIT0
84 ; 19/05/2024
85 0000007D 80E2FE and dl, 0FEh
86
87 00000080 8916[900A] mov [NAMBAR], dx ; save audio mixer base addr
88
89 00000084 B014 mov al, NABMBAR_REG
90 00000086 E88401 call pciRegRead16
91 ;and dx, IO_ADDR_MASK
92 ; 19/05/2024
93 00000089 80E2C0 and dl, 0C0h
94
95 0000008C 8916[920A] mov [NABMBAR], dx ; save bus master base addr
96
97 ; 06/11/2023
98 ;; init controller
99 ;; 17/02/2017
100 ;mov al, PCI_CMD_REG ; command register (04h)
101 ;call pciRegRead16 ; pciRegRead8
102 ;
103 ;; eax = BUS/DEV/FN/REG
104 ;; dx = PCI Command Register Content ; 17/02/2017
105 ;; 00000000CCCCCCCC
106 ;mov [stats_cmd], dx
107 ;
108 ; 06/11/2023
109 ;mov al, PCI_IO_BASE ; IO base address register (10h)
110 ;call pciRegRead32
111 ;
112 ;and dx, 0FFC0h ; IO_ADDR_MASK (0FFFE) ?
113 ;mov [ac97_io_base], dx
114
115 00000090 B03C mov al, AC97_INT_LINE ; Interrupt line register (3Ch)
116 00000092 E87001 call pciRegRead8 ; 17/02/2017
117
118 00000095 8816[8F0A] mov [ac97_int_ln_reg], dl
119
120 ; 05/11/2023
121 %if 0
122 ; 28/11/2016
123 mov bx, 1
124 xor dh, dh ; 17/02/2017
125 mov cx, dx
126 shl bx, cl
127
128 ; 04/11/2023
129 cli
130
131 ;not bx
132 in al, 0A1h ; irq 8-15
133 mov ah, al
134 in al, 21h ; irq 0-7
135
136 ; 04/11/2023
137 ; save IRQ status
138 mov [IRQ_status], ax
139
140 ; 12/05/2024 (enable AC97 IRQ)
141 ;mov cl, dl
142 ;mov bx, 1
143 ;shl bx, cl
144 ;not bx
145 ;and ax, bx
146 ;out 21h, al
147 ;mov al, ah
148 ;out 0A1h, al
149
150 ;and ax, bx ; unmask
151 btr ax, dx ; unmask
152 out 21h, al ; enable interrupt (if irq <= 7)
153 mov al, ah
154 out 0A1h, al ; enable interrupt (if irq > 7)
155 ;not bx
156
157 ; 04/11/2023
158 ;mov dx, 4D1h ;8259 ELCR1
159 ;in al, dx
160 ;mov ah, al
161 ;mov dx, 4D0h
162 ;in al, dx
163 ;;or ax, bx
164 ;bts ax, cx
165 ;mov dx, 4D0h
166 ;out dx, al ;set level-triggered mode
167 ;mov al, ah
168 ;mov dx, 4D1h
169 ;out dx, al ;set level-triggered mode
170
171 ; 24/11/2016 - Erdogan Tan
172 mov bx, cx
173 ;mov bx, dx
174 mov bl, [bx+irq_int]
175 shl bx, 2 ; * 4
176
177 ; set up interrupt vector
178 ; 30/11/2016
179 push es
180 xor ax, ax
181 mov es, ax
182 ; 04/11/2023
183 ; save interrupt vector
184 ;mov ax, [es:bx]
185 ; 13/05/2024
186 mov ax, ac97_int_handler
187 xchg ax, [es:bx]
188 mov [IRQ_vector], ax
189 ;mov ax, [es:bx+2]
190 ; 13/05/2024
191 mov ax, cs
192 xchg ax, [es:bx+2]
193 mov [IRQ_vector+2], ax
194
195 ; 13/05/2024
196 ;mov word [es:bx], ac97_int_handler
197 ;mov ax, cs
198 ;mov [es:bx+2], ax
199
200 pop es
201
202 ; 04/11/2023
203 sti
204
205 %endif
206
207 00000099 E83206 call write_ac97_dev_info
208
209 ; check the command line for a file to play
210
211 ;push ds
212 0000009C E89200 call processCmdline ; get the filename
213
214 ; open the file
215 0000009F B002 mov al, OPEN ; open existing file
216 000000A1 E8AD00 call openFile ; no error? ok.
217 ;pop ds
218 000000A4 7322 jnc short _gsr
219
220 ; file not found!
221
222 ;push cs
223 ;pop ds
224 000000A6 BA[AF00] mov dx, noFileErrMsg
225 000000A9 B409 mov ah, 9
226 000000AB CD21 int 21h
227 000000AD EB61 jmp exit
228
229 noFileErrMsg:
230 000000AF 4572726F723A206669- db "Error: file not found.",CR,LF,"$"
230 000000B8 6C65206E6F7420666F-
230 000000C1 756E642E0D0A24
231
232 _gsr:
233 000000C8 E8AD00 call getSampleRate ; read the sample rate
234 ; pass it onto codec.
235 000000CB 7243 jc short exit ; 19/11/2016 - nothing to do
236
237 000000CD A3[A20A] mov [sample_rate], ax
238
239 ; 19/11/2016
240 000000D0 880E[A40A] mov [stmo], cl
241 000000D4 8816[A60A] mov [bps], dl
242
243 ; 17/02/2017
244 000000D8 C606[A80A]00 mov byte [fbs_shift], 0 ; 0 = stereo and 16 bit
245 000000DD FEC9 dec cl
246 000000DF 7504 jnz short _gsr_1 ; stereo
247 000000E1 FE06[A80A] inc byte [fbs_shift] ; 1 = mono or 8 bit
248 _gsr_1:
249 000000E5 80FA08 cmp dl, 8
250 000000E8 7704 ja short _gsr_2 ; 16 bit samples
251 000000EA FE06[A80A] inc byte [fbs_shift] ; 2 = mono and 8 bit
252 _gsr_2:
253 000000EE E83307 call write_sample_rate
254
255 ; 05/11/2023
256 _2:
257 000000F1 E87605 call check4keyboardstop ; flush keyboard buffer
258 000000F4 72FB jc short _2 ; 07/11/2023
259
260 ; 05/11/2023
261 ;mov eax, [bus_dev_fn]
262 ;mov al, PCI_CMD_REG
263 ;call pciRegRead16 ; read PCI command register
264 ; 17/02/2017
265 ;mov dx, [stats_cmd]
266 ;or dl, IO_ENA+BM_ENA ; enable IO and bus master
267 ;call pciRegWrite16 ; pciRegWrite8
268
269 ; 19/05/2024
270 ; 06/11/2023
271 ;mov eax, [bus_dev_fn]
272 ;mov al, PCI_CMD_REG
273 ;call pciRegRead8 ; read PCI command register
274 ;or dl, IO_ENA+BM_ENA ; enable IO and bus master
275 ;call pciRegWrite8
276
277 ; setup the Codec (actually mixer registers)
278 000000F6 E8E301 call codecConfig ; unmute codec, set rates.
279 ; 11/11/2023
280 000000F9 721C jc short init_err
281 ;
282 ; position file pointer to start in actual wav data
283 ; MUCH improvement should really be done here to check if sample size is
284 ; supported, make sure there are 2 channels, etc.
285 ;
286 000000FB B442 mov ah, 42h
287 000000FD B000 mov al, 0 ; from start of file
288 000000FF 8B1E[8C0A] mov bx, [filehandle]
289 00000103 31C9 xor cx, cx
290 00000105 BA2C00 mov dx, 44 ; jump past .wav/riff header
291 00000108 CD21 int 21h
292
293 ; play the .wav file. Most of the good stuff is in here.
294
295 0000010A E88403 call playWav
296
297 ; close the .wav file and exit.
298
299 close_exit: ; 11/11/2023
300 0000010D E85300 call closeFile
301
302 exit:
303 00000110 B8004C mov ax, 4c00h
304 00000113 CD21 int 21h
305
306 here:
307 00000115 EBFE jmp short here
308
309 ; 11/11/2023
310 init_err:
311 00000117 BA[060A] mov dx, msg_init_err
312 vra_err: ; 12/11/2023
313 0000011A B409 mov ah, 9
314 0000011C CD21 int 21h
315 0000011E EBED jmp short close_exit
316
317 ; MEMALLOC.ASM
318 ;-- SETFREE: Release memory not used ----------------
319 ;-- Input : ES = address of PSP
320 ;-- Output : none
321 ;-- Register : AX, BX, CL and FLAGS are changed
322 ;-- Info : Since the stack-segment is always the last segment in an
323 ; EXE-file, ES:0000 points to the beginning and SS:SP
324 ; to the end of the program in memory. Through this the
325 ; length of the program can be calculated
326 ; call this routine once at the beginning of the program to free up memory
327 ; assigned to it by DOS.
328
329 setFree:
330 00000120 BB0010 mov bx, 65536/16 ; 4K paragraphs ; 17/02/2017 (Erdogan Tan)
331
332 00000123 B44A mov ah, 4ah ; pass new length to DOS
333 00000125 CD21 int 21h
334
335 00000127 C3 retn ; back to caller
336 ; new size (allocated memory) = 64KB
337
338 memAlloc:
339 ; input: AX = # of paragraphs required
340 ; output: AX = segment of block to use
341
342 00000128 53 push bx
343 00000129 89C3 mov bx, ax
344 0000012B B448 mov ah, 48h
345 0000012D CD21 int 21h
346 0000012F 5B pop bx
347 00000130 C3 retn
348
349 ; CMDLINE.ASM
350 ; parse the command line
351 ; entry: none
352 ; exit: DS:DX to the 1st supplied item on the command line
353
354 processCmdline:
355 00000131 53 push bx
356 00000132 56 push si
357
358 ;mov ah, 51h
359 ;int 21h
360 ;mov ds, bx
361
362 00000133 BE8000 mov si, 80h
363 00000136 0FB61C movzx bx, byte [si]
364 00000139 01DE add si, bx
365 0000013B 46 inc si
366
367 0000013C C60400 mov byte [si], NULL ; zero terminate
368
369 0000013F BE8100 mov si, 81h
370
371 cmdlineloop:
372 00000142 AC lodsb
373
374 00000143 3C00 cmp al, NULL ; found end of line?
375 00000145 7404 je short exitpc
376 00000147 3C20 cmp al, ' ' ; found a space?
377 00000149 74F7 je short cmdlineloop
378
379 ; must be the filename here.
380 exitpc:
381 0000014B 4E dec si ; point to start of filename
382 0000014C 89F2 mov dx, si
383 0000014E 5E pop si
384 0000014F 5B pop bx
385 00000150 C3 retn
386
387 ; FILE.ASM
388 ;open or create file
389 ;
390 ;input: ds:dx-->filename (asciiz)
391 ; al=file Mode (create or open)
392 ;output: none cs:[filehandle] filled
393 ;
394 openFile:
395 00000151 50 push ax
396 00000152 51 push cx
397 00000153 B43B mov ah, 3bh ; start with a mode
398 00000155 00C4 add ah, al ; add in create or open mode
399 00000157 31C9 xor cx, cx
400 00000159 CD21 int 21h
401 0000015B 7203 jc short _of1
402 ;mov [cs:filehandle], ax
403 0000015D A3[8C0A] mov [filehandle], ax
404 _of1:
405 00000160 59 pop cx
406 00000161 58 pop ax
407 00000162 C3 retn
408
409 ; close the currently open file
410 ; input: none, uses cs:[filehandle]
411 closeFile:
412 00000163 50 push ax
413 00000164 53 push bx
414 00000165 833E[8C0A]FF cmp word [filehandle], -1
415 0000016A 7409 jz short _cf1
416 0000016C 8B1E[8C0A] mov bx, [filehandle]
417 00000170 B8003E mov ax,3e00h
418 00000173 CD21 int 21h ;close file
419 _cf1:
420 00000175 5B pop bx
421 00000176 58 pop ax
422 00000177 C3 retn
423
424 getSampleRate:
425 ; 08/12/2016
426 ; reads the sample rate from the .wav file.
427 ; entry: none - assumes file is already open
428 ; 19/11/2016 - Erdogan Tan
429 ; exit: ax = sample rate (11025, 22050, 44100, 48000)
430 ; cx = number of channels (mono=1, stereo=2)
431 ; dx = bits per sample (8, 16)
432
433 00000178 53 push bx
434
435 00000179 B442 mov ah, 42h
436 0000017B B000 mov al, 0 ; from start of file
437 0000017D 8B1E[8C0A] mov bx, [filehandle]
438 00000181 31C9 xor cx, cx
439 00000183 BA0800 mov dx, 08h ; "WAVE"
440 00000186 CD21 int 21h
441
442 00000188 BA[700A] mov dx, smpRBuff
443 0000018B B91C00 mov cx, 28 ; 28 bytes
444 0000018E B43F mov ah, 3fh
445 00000190 CD21 int 21h
446
447 00000192 813E[700A]5741 cmp word [smpRBuff], 'WA'
448 00000198 751C jne short gsr_stc
449
450 0000019A 813E[720A]5645 cmp word [smpRBuff+2], 'VE'
451 000001A0 7514 jne short gsr_stc
452
453 000001A2 833E[7C0A]01 cmp word [smpRBuff+12], 1 ; Offset 20, must be 1 (= PCM)
454 000001A7 750D jne short gsr_stc
455
456
457 000001A9 8B0E[7E0A] mov cx, [smpRBuff+14] ; return num of channels in CX
458 000001AD A1[800A] mov ax, [smpRBuff+16] ; return sample rate in AX
459 000001B0 8B16[8A0A] mov dx, [smpRBuff+26] ; return bits per sample value in DX
460 gsr_retn:
461 000001B4 5B pop bx
462 000001B5 C3 retn
463
464 gsr_stc:
465 000001B6 F9 stc
466 000001B7 EBFB jmp short gsr_retn
467
468 %include 'ac97.asm' ; 29/11/2016 (AC97 codec configuration)
1 <1> ; 19/05/2024
2 <1> ; 12/11/2023
3 <1> ; 11/11/2023
4 <1> ; 06/11/2023
5 <1> ; 05/11/2023
6 <1> ; 04/11/2023
7 <1> ; 03/11/2023
8 <1> ; PCI and AC97 codec functions for wav player
9 <1> ; Erdogan Tan (17/02/2017)
10 <1>
11 <1> ; ----------------------------------------------------------------------------
12 <1> ; PCI.ASM
13 <1> ; ----------------------------------------------------------------------------
14 <1>
15 <1> ; PCI device register reader/writers.
16 <1> ; NASM version: Erdogan Tan (29/11/2016)
17 <1> ; Last Update: 17/02/2017
18 <1>
19 <1> ;===============================================================
20 <1> ; 8/16/32bit PCI reader
21 <1> ;
22 <1> ; Entry: EAX=PCI Bus/Device/fn/register number
23 <1> ; BIT30 set if 32 bit access requested
24 <1> ; BIT29 set if 16 bit access requested
25 <1> ; otherwise defaults to 8 bit read
26 <1> ;
27 <1> ; Exit: DL,DX,EDX register data depending on requested read size
28 <1> ;
29 <1> ; Note: this routine is meant to be called via pciRegRead8, pciRegread16,
30 <1> ; or pciRegRead32, listed below.
31 <1> ;
32 <1> ; Note2: don't attempt to read 32bits of data from a non dword aligned reg
33 <1> ; number. Likewise, don't do 16bit reads from non word aligned reg #
34 <1> ;
35 <1> pciRegRead:
36 000001B9 6653 <1> push ebx
37 000001BB 51 <1> push cx
38 000001BC 6689C3 <1> mov ebx, eax ; save eax, dh
39 000001BF 88F1 <1> mov cl, dh
40 000001C1 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
41 000001C7 660D00000080 <1> or eax, BIT31 ; make a PCI access request
42 000001CD 24FC <1> and al, ~3 ; NOT 3 ; force index to be dword
43 <1>
44 000001CF BAF80C <1> mov dx, PCI_INDEX_PORT
45 000001D2 66EF <1> out dx, eax ; write PCI selector
46 <1>
47 000001D4 BAFC0C <1> mov dx, PCI_DATA_PORT
48 000001D7 88D8 <1> mov al, bl
49 000001D9 2403 <1> and al, 3 ; figure out which port to
50 000001DB 00C2 <1> add dl, al ; read to
51 <1>
52 000001DD 66ED <1> in eax, dx ; do 32bit read
53 000001DF 66F7C300000080 <1> test ebx, PCI32
54 000001E6 7403 <1> jz short _pregr1
55 <1>
56 000001E8 6689C2 <1> mov edx, eax ; return 32bits of data
57 <1> _pregr1:
58 000001EB 89C2 <1> mov dx, ax ; return 16bits of data
59 000001ED 66F7C3000000C0 <1> test ebx, PCI32+PCI16
60 000001F4 7502 <1> jnz short _pregr2
61 000001F6 88CE <1> mov dh, cl ; restore dh for 8 bit read
62 <1> _pregr2:
63 000001F8 6689D8 <1> mov eax, ebx ; restore eax
64 000001FB 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
65 00000201 59 <1> pop cx
66 00000202 665B <1> pop ebx
67 00000204 C3 <1> retn
68 <1>
69 <1> pciRegRead8:
70 00000205 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 8 bit read size
71 0000020B EBAC <1> jmp short pciRegRead ; call generic PCI access
72 <1>
73 <1> pciRegRead16:
74 0000020D 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 16 bit read size
75 00000213 660D00000040 <1> or eax, PCI16 ; call generic PCI access
76 00000219 EB9E <1> jmp short pciRegRead
77 <1>
78 <1> pciRegRead32:
79 0000021B 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 32 bit read size
80 00000221 660D00000080 <1> or eax, PCI32 ; call generic PCI access
81 00000227 EB90 <1> jmp short pciRegRead
82 <1>
83 <1> ;===============================================================
84 <1> ; 8/16/32bit PCI writer
85 <1> ;
86 <1> ; Entry: EAX=PCI Bus/Device/fn/register number
87 <1> ; BIT31 set if 32 bit access requested
88 <1> ; BIT30 set if 16 bit access requested
89 <1> ; otherwise defaults to 8bit read
90 <1> ; DL/DX/EDX data to write depending on size
91 <1> ;
92 <1> ;
93 <1> ; note: this routine is meant to be called via pciRegWrite8, pciRegWrite16,
94 <1> ; or pciRegWrite32 as detailed below.
95 <1> ;
96 <1> ; Note2: don't attempt to write 32bits of data from a non dword aligned reg
97 <1> ; number. Likewise, don't do 16bit writes from non word aligned reg #
98 <1> ;
99 <1> pciRegWrite:
100 00000229 6653 <1> push ebx
101 0000022B 51 <1> push cx
102 0000022C 6689C3 <1> mov ebx, eax ; save eax, dx
103 0000022F 89D1 <1> mov cx, dx
104 00000231 660D00000080 <1> or eax, BIT31 ; make a PCI access request
105 00000237 6625FFFFFFBF <1> and eax, ~PCI16 ; NOT PCI16 ; clear out data size request
106 0000023D 24FC <1> and al, ~3 ; NOT 3 ; force index to be dword
107 <1>
108 0000023F BAF80C <1> mov dx, PCI_INDEX_PORT
109 00000242 66EF <1> out dx, eax ; write PCI selector
110 <1>
111 00000244 BAFC0C <1> mov dx, PCI_DATA_PORT
112 00000247 88D8 <1> mov al, bl
113 00000249 2403 <1> and al, 3 ; figure out which port to
114 0000024B 00C2 <1> add dl, al ; write to