

            how to call dfgnbel3 from an assembly program



	what does dfgnbel3 do?

	dfgnbel3 will ...

	1)  beep until any key hit.  beeps should be about 2 per second
	    regardless of your computer's clock speed

	2)  put the ascii value of the key hit on the top of the stack

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

	any restrictions on this program?

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

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

	how do i call it from an assembly 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 dfgnbel3:proc


;**********************************************************************
;     /variables
;**********************************************************************
keystroke	dw	0	;keystroke returned from dfgnbel3
		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
bel3top:
;**********************************************************************
;	cycle through menu items until keystroke = 'x'
;**********************************************************************
;----------------------------------------------------------------------
;	beep forever until any key hit
;	put keystroke on top of stack
;----------------------------------------------------------------------
	call	far ptr dfgnbel3	;beep forever until any key hit
	pop	keystroke		;get keystroke from dfgnbel3
	cmp	keysascii,'a'		;was the keystroke a?
	jne	bel3nota			;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	bel3top			;pick another menu option
bel3nota:   
	cmp	keysascii,'b'		;was the keystroke b?
	jne	bel3notb			;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	bel3top			;pick another menu option
bel3notb:   
	cmp	keysascii,'x'		;was the keystroke x?
	jne	bel3top			;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 into caller program  
	assemble caller program
	add dfgnbel3 to your link.  dfgnbel3.obj included in package
	run linker
	run caller program

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

	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

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