

            how to call dfgnbel1 from an assembly program


	what does dfgnbel1 do?

	DFGNBEL1 will ...

	1)  beep a user-specified number of times and then cycle 
	    silently until any key hit.  beeps should be about 2 
	    per second regardless of your clock speed.  it can also
	    beep 0 times (cycle silently) until any key hit.	

	2)  put the ascii value of the keystroke on top of the stack

	

;----------------------------------------------------------------------
	
	any restrictions on this program?

	ms-dos/windows/xp operating systems
	386 cpu or better

;----------------------------------------------------------------------

	how do i call it from an assembley program?


	add the following code to the caller program.  
	(note:  the following is written in borland turbo assembler 
	3.0 in masm mode.  masm mode = microsoft assembler conventions.)

	
;**********************************************************************
;	/extrns
;**********************************************************************
	extrn dfgnbel1:proc

;**********************************************************************
;     /variables
;**********************************************************************
keystroke	dw	0	;keystroke returned from dfgnbel1
		org	keystroke
keysascii      	db	0	;ascii value of keystoke
keyscan        	db	0	;scan value of keystroke
keys_ln	equ	$-keystroke
		org	keystroke+keys_ln

;**********************************************************************
;      /code
;**********************************************************************
;----------------------------------------------------------------------
;      display menu
;----------------------------------------------------------------------
	lea	dx,hitkey	;'hit any key to continue'
	mov	ah,9		;display msg on scrn
	int	21h		;display msg on scrn
bel1top:
;----------------------------------------------------------------------
;	beep user-specified nbr of times, then cycle silently
;	put keystroke on top of stack
;----------------------------------------------------------------------
	push	12			;beep 12 times then cycle silently
	call	far ptr dfgnbel1	;beep 12 times then cycle silently
	pop	keystroke		;dfgnbel1 puts keys on top of stack
	cmp	keysascii,'a'		;was the keystroke a?
	jne	bel1nota			;no
;----------------------------------------------------------------------
;       keystroke = a
;----------------------------------------------------------------------
	lea	dx,a			;'hit any key to continue'
	mov	ah,9			;display msg on scrn
	int	21h			;display msg on scrn
	jmp	bel1top			;pick another menu option
bel1nota:   
	cmp	keysascii,'b'		;was the keystroke b?
	jne	bel1notb			;no
;----------------------------------------------------------------------
;       keystroke = b
;----------------------------------------------------------------------
	lea	dx,b			;'hit any key to continue'
	mov	ah,9			;display msg on scrn
	int	21h			;display msg on scrn
	jmp	bel1top			;pick another menu option
bel1notb:   
	cmp	keysascii,'x'		;was the keystroke x?
	jne	bel1top			;no, pick another menu option
;----------------------------------------------------------------------
;       continue with rest of program
;----------------------------------------------------------------------
;**********************************************************************
;      /messages
;**********************************************************************
a	equ	$
	db	13,10
	db	'  a'
	db	'$'
b	equ	$
	db	13,10
	db	'  b'
	db	'$'
hitkey	equ	$
	db	13,10
	db	'  a - print a'
	db	13,10		;line feed/carriage return
	db	'  b - print b'
	db	13,10		;line feed/carriage return
	db	'  x - exit program'
	db	'$'	

	install above code to caller program  
	assemble caller program
	add dfgnbel1 to link.  dfgnbel1.obj included for linker
	run linker
	run caller program
	


	to cycle silently until any key hit:

;----------------------------------------------------------------------
;	cycle silently until any key hit
;----------------------------------------------------------------------
	push	0			;beep 0 times, then cycle silently
	call	far ptr dfgnbel1	;beep 0 times, then cycle silently

	the rest of the call is identical to 'beep 12 times' call, above

;----------------------------------------------------------------------

	any warnings about this program?


	THE BEEP IS NOT VERY LOUD.  you may not hear it if tv or radio
	is playing loudly.

;----------------------------------------------------------------------

	can i control the sound volume?

	no.  the hardware does not allow it

;----------------------------------------------------------------------

