Annotation of pmsdk/samples/petzold/chap08/speaker.asm, revision 1.1.1.1

1.1       root        1: ;-------------------------------------------------
                      2: ; SPEAKER.ASM -- Ring 2 routine for ORGAN program
                      3: ;                (Accesses Intel 8255 Timer chip)
                      4: ;-------------------------------------------------
                      5: 
                      6:                PUBLIC    Speaker
                      7:                .286
                      8:                .MODEL    MEDIUM, PASCAL
                      9: 
                     10:                .DATA
                     11: ClockFreq      dd   1193180
                     12: 
                     13:                .CODE     SPEAKER_TEXT
                     14: Speaker        PROC FAR  Frequency:WORD
                     15:                Cli                                ; Disable interrupts
                     16: 
                     17:                Mov  BX, Frequency                 ; Get parameter from stack
                     18:                Or   BX, BX                        ; Check if it's zero
                     19:                Jz   TurnOff                       ; If so, turn off sound
                     20: 
                     21:                Mov  AL, 10110110b                 ; Set flags for programming
                     22:                Out  43h, AL
                     23: 
                     24:                Mov  AX, WORD PTR [ClockFreq]      ; Calculate timer frequency
                     25:                Mov  DX, WORD PTR [ClockFreq + 2]
                     26:                Div  BX
                     27: 
                     28:                Out  42h, AL                       ; Output low byte
                     29:                Jmp  $ + 2                         ; Delay
                     30: 
                     31:                Mov  AL, AH                        ; Output high byte
                     32:                Out  42h, AL
                     33:                Jmp  $ + 2                         ; Delay
                     34: 
                     35:                In   AL, 61h                       ; Get 8255 bits
                     36:                Jmp  $ + 2                         ; Delay
                     37: 
                     38:                Or   AL, 00000011b                 ; Set bits for speaker
                     39:                Out  61h, AL                       ; Set 8255 bits
                     40:                Jmp  Return
                     41: 
                     42: TurnOff:       In   AL, 61h                       ; Get 8255 bits
                     43:                Jmp  $ + 2                         ; Delay
                     44:                And  AL, 11111101b                 ; Set bits for no speaker
                     45:                Out  61h, AL                       ; Set 8255 bits
                     46: 
                     47: Return:        Sti                                ; Enable interrupts
                     48:                Ret
                     49: Speaker        ENDP
                     50:                END

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.