Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:12
CP/DOS DosBeep mapper                                       Page     1-1


				page 80,132
				
				title CP/DOS DosBeep mapper
				
 0000				dosxxx  segment byte public 'dos'
				        assume  cs:dosxxx,ds:nothing,es:nothing,ss:nothing
				
				;**********************************************************************
				;*
				;*   MODULE:   dosbeep
				;*
				;*   FUNCTION:  generate a tone with desired frequency and duration
				;*
				;*   CALLING SEQUENCE:
				;*
				;*       push      word   frequency
				;*       push      word   duration      (in milliseconds)
				;*       call      dosbeep
				;*
				;*   MODULES CALLED:  none
				;*
				;*********************************************************************
				
				        public  dosbeep
				        .sall
				        include macros.inc
			     C	;
			     C	
			     C	
			     C	pushal  macro
			     C	        push    bx
			     C	        push    cx
			     C	        push    dx
			     C	        push    si
			     C	        push    di
			     C	        push    ds
			     C	        push    es
			     C	        push    ss
			     C	        push    bp
			     C	        endm
			     C	;
			     C	popal   macro
			     C	        pop     bp
			     C	        pop     ss
			     C	        pop     es
			     C	        pop     ds
			     C	        pop     di
			     C	        pop     si
			     C	        pop     dx
			     C	        pop     cx
			     C	        pop     bx
			     C	        endm
			     C	;
			     C	Enter   macro   Routine
			     C	
			     C	        push    bp
			     C	        mov     bp,sp
			     C	        pushal
			     C	
			     C	        endm
			     C	;
			     C	Mexit   macro
			     C	
			     C	        popal
			     C	        mov     sp,bp
			     C	        pop     bp
			     C	
			     C	        endm
			     C	
				
 = 0002				inv_parm equ    0002h         ;invalid parameter return code
				
				str     struc
 0000  0000			old_bp  dw      ?
 0002  00000000			return  dd      ?
 0006  0000			duratn  dw      ?       ; duration
Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:12
CP/DOS DosBeep mapper                                       Page     1-2


 0008  0000			frqncy  dw      ?       ; frequency
 000A				str     ends
				
 0000				dosbeep proc    far
				        Enter   DosBeep
				
 000C  B0 B6			        mov     al,10110110b      ; Set 8253 chip channel 2
 000E  E6 43			        out     43h,al            ; to proper mode for tone
				
				; Channel 2 is now set up as a frequency divider.  The sixteen bit
				; value sent to that port (in low-high format) is divided into
				; 1.19 MHz, the clock speed.  In order to send the proper value
				; to the register, then, the frequency requested must be divided
				; into 1,190,000.
				
 0010  BA 0012			        mov     dx,012h           ; MSB of 1.19M
 0013  B8 2970			        mov     ax,2970h          ; LSB of 1.19M
 0016  8B 4E 08			        mov     cx,[bp].frqncy    ; divisor
 0019  BB 0025			        mov     bx,025h           ; check frequency range
 001C  3B CB			        cmp     cx,bx             ; frequency ok ??
 001E  7C 2B			        jl      error             ; branch if error
				
 0020  BB 7FFF			        mov     bx,7fffh
 0023  3B CB			        cmp     cx,bx
 0025  7F 24			        jg      error
 0027  F7 F1			        div     cx                ; then divide
				
 0029  E6 42			        out     42h,al            ; and output
 002B  8A C4			        mov     al,ah             ; directly to
 002D  E6 42			        out     42h,al            ; the 8253 port.
				
				; Turn on speaker
				
 002F  E4 61			        in      al,61h            ; Save original value
 0031  8A E0			        mov     ah,al             ; in ah
 0033  0C 03			        or      al,3              ; Turn on control bit
 0035  E6 61			        out     61h,al            ; in 8255 chip
				
				; Now loop for DURATN milliseconds
				
 0037  8B 4E 06			        mov     cx,[bp].duratn    ; load value
 003A  BB 00C4			delay:  mov     bx,196            ; inner loop count
 003D  4B			del2:   dec     bx                ; a millisecond
 003E  75 FD			        jne     del2              ; for each
 0040  E2 F8			        loop    delay             ; iteration
				
				; Turn speaker off
				
 0042  8A C4			        mov     al,ah             ; replace
 0044  E6 61			        out     61h,al            ; original value
				
 0046  2B C0			        sub     ax,ax             ; set no error code
 0048  EB 04 90			        jmp     exit              ; return
				
 004B  B8 0002			error:  mov     ax,inv_parm
				
 004E				exit:   MExit                     ; pop registers
 005A  CA 0004			        ret     size str - 6      ; return
				
 005D				dosbeep endp
				
 005D				dosxxx  ends
				
				        end

Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:12
CP/DOS DosBeep mapper                                       Symbols-1


Macros:

		N a m e			Lines

ENTER  . . . . . . . . . . . . .  	   3
MEXIT  . . . . . . . . . . . . .  	   3
POPAL  . . . . . . . . . . . . .  	   9
PUSHAL . . . . . . . . . . . . .  	   9

Structures and Records:

                N a m e                 Width   # fields
                                        Shift   Width   Mask    Initial

STR  . . . . . . . . . . . . . .  	000A	0004
  OLD_BP . . . . . . . . . . . .  	0000
  RETURN . . . . . . . . . . . .  	0002
  DURATN . . . . . . . . . . . .  	0006
  FRQNCY . . . . . . . . . . . .  	0008

Segments and Groups:

                N a m e         	Length	 Align	Combine Class

DOSXXX . . . . . . . . . . . . .  	005D	BYTE	PUBLIC	'DOS'

Symbols:            

                N a m e         	Type	 Value	 Attr

DEL2 . . . . . . . . . . . . . .  	L NEAR	003D	DOSXXX
DELAY  . . . . . . . . . . . . .  	L NEAR	003A	DOSXXX
dosbeep  . . . . . . . . . . . .  	F PROC	0000	DOSXXX	Global	Length = 005D

ERROR  . . . . . . . . . . . . .  	L NEAR	004B	DOSXXX
EXIT . . . . . . . . . . . . . .  	L NEAR	004E	DOSXXX

INV_PARM . . . . . . . . . . . .  	NUMBER	0002	

@CPU . . . . . . . . . . . . . .  	TEXT  0101h		
@FILENAME  . . . . . . . . . . .  	TEXT  beep		
@VERSION . . . . . . . . . . . .  	TEXT  510		


    143 Source  Lines
    167 Total   Lines
     22 Symbols

  47546 + 323073 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors
