I am trying to generate a beep when a program is finished; for a long string of prime
numbers the program takes a few minutes to complete. Placing 07H in my output
buffer doesn't work; can someone suggest another way of doing this, or identify my
mistake?
Thanks,
Michael
try this one...
mov al,7
int 29h
Hi,
Or try:
MOV DL,7
MOV AH,2 ; DOS Console output function
INT 21H ; repeat as needed
Slightly more standard than INT 29H.
Steve N.
Thanks for both suggestions; the int 29h works, and now I'll try the second suggestion.
Michael
the difference is:
INT 29h output cannot be re-directed
INT 21h output may be redirected (functions 2 and 9)
so, if someone wants to create a text file of the output:
C:\> MyProgram >output.txt
the text will go to the file
the bell will go to the speaker, not the file
if you were to disassemble DOS:
INT 21h, function 2 and 9 test for redirection
then, if the output has not been redirected, those functions use INT 29h to put the character(s) on the screen
on a side note, using INT 10h (BIOS) functions to output characters to the screen are also never redirected
if you have ANSI.SYS loaded, DOS INT 29h and INT 21h output passes through the ANSI filter
BIOS INT 10h functions do not pass through the ANSI filter
the ANSI filter allows characters to be re-mapped, positioned, or attributes set
by selecting the function, you may control which characters are redirected and/or filtered
Hi,
Some of what Dave said didn't quite sit well, so I wrote up a
program to see what happens. And of course I read through
some references that don't quite sound alike. But all's well
apparently. Notes in the proram comments. Done without
much double checking, so report any errors.
Obsolete or superceded, function 2 is easier to use than its
replacement. The BIOS functions need some getting used to.
Regards,
Steve N.
PAGE ,132
TITLE TestOut
NAME TestOut
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Test various ways of outputing a character, SRN 8 August 2009.
; Question posed (more or less) by comments from MASM Forum deadndave.
; Note possible redirection and control functionality.
; MASM TestOut;
; LINK TestOut;
; EXE2BIN TestOut.EXE TestOut.COM
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
ORG 100H ; COM file opening
START:
JMP Setup
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Data for main program.
Hello DB ' Test various ways of outputing a character. A beep'
DB ' or bell {7}, ', 13, 10, ' a tab {9}, and a hack {92} '
DB ' will be output for each method.', 13, 10, 13, 10
DB ' Hit a key to progress between tests.',13, 10, '$'
First DB 13, 10, ' Int 29H, "Fast Console Output" ', 13, 10, '$'
Second DB 13, 10, ' Int 21H, 02H Display Character ', 13, 10, '$'
Third DB 13, 10, ' Int 21H, 06H Direct Console I/O ', 13, 10, '$'
Fourth DB 13, 10, ' Int 21H, 40H Write File or Device ', 13, 10, '$'
Buffer DB ?
Fifth DB 13, 10, ' Int 10H, 0AH Video BIOS Write Character ', 13, 10, '$'
Sixth DB 13, 10, ' Int 10H, 0EH Display Character in Teletype Mode ', 13, 10, '$'
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Main program, setup.
Setup:
MOV AX,CS ;\ If run as an EXE...
MOV DS,AX ;/
MOV DX,OFFSET Hello
MOV AH,9 ; DOS Out String Fn
INT 21H
; - - - First way, by deadndave. - - -
; Int 29H undocumented fast console output function.
; ref. deadndave and "Undocumented DOS" 2nd ed.
; A wrapper around the BIOS 0EH output function if ANSI.SYS not
; loaded, will use ANSI.SYS if it is loaded (untested).
; Not redirected.
MOV AH,10H ; Read Extended Keyboard Input function.
INT 16H ; BIOS Keyboard interrupt.
MOV DX,OFFSET First ; message.
MOV AH,9 ; OUTSTR
INT 21H
MOV AL,7 ; Output character in AL
INT 29H ; fast console output interrupt.
MOV AL,9
INT 29H
MOV AL,92
INT 29H
; - - - Second way. - - -
; Int 21H Display Character function 2.
; ref. "Microsoft MS-DOS Programmer's Reference" version 5.
; M$ lists this as 'superseded'
; Will use ANSI.SYS if it is loaded. Redirected. Tabs expanded to spaces.
MOV AH,10H ; {Just used for a pause.}
INT 16H
MOV DX,OFFSET Second ; message.
MOV AH,9
INT 21H
MOV AH,2 ; CONOUT
MOV DL,7
INT 21H
MOV AH,2 ; <= In practice, doing this again is not needed,
MOV DL,9 ; but it is a good idea as, theory says, register
INT 21H ; contents might not be preserved.
MOV AH,2
MOV DL,92
INT 21H
; - - - Third way. - - -
; Int 21H Direct Console I/O function 6.
; ref. "Microsoft MS-DOS Programmer's Reference".
; M$ lists this as 'superseded'
; Redirected. Tabs not expanded.
MOV AH,10H ; pause.
INT 16H
MOV DX,OFFSET Third ; message.
MOV AH,9
INT 21H
MOV AH,6 ; DRCIO
MOV DL,7
INT 21H
MOV AH,6
MOV DL,9
INT 21H
MOV AH,6
MOV DL,92
INT 21H
; - - - Fourth way. - - -
; Int 21H Write file with handle function 40H.
; ref. "Microsoft MS-DOS Programmer's Reference".
; M$ lists this as the preferred way, to replace 'superseded' functions.
; Redirected. Tabs not expanded in redirected file, expanded to console.
MOV AH,10H ; pause.
INT 16H
MOV DX,OFFSET Fourth ; message.
MOV AH,9
INT 21H
MOV DI,OFFSET Buffer ; Put the character into a buffer.
MOV BYTE PTR [DI],7
MOV AH,40H ; WRITEH
MOV BX,1 ; Handle, 1 = Standard Output.
MOV CX,1 ; Byte count.
MOV DX,OFFSET Buffer
INT 21H
MOV BYTE PTR [DI],9
MOV AH,40H ; AX (at least) needs to be refilled as it
MOV BX,1 ; contains a return value.
MOV CX,1
MOV DX,OFFSET Buffer
INT 21H
MOV BYTE PTR [DI],92
MOV AH,40H
MOV BX,1
MOV CX,1
MOV DX,OFFSET Buffer
INT 21H
; - - - Fifth way. - - -
; Int 10H write character at current cursor position, function 0AH.
; ref. "Computer Shopper's Best of TECH Help!", "Programmer's Guide to
; PC Video Systems"
; Non-DOS BIOS video function. Note: Use Fn 09H when in graphics modes.
; References disagree about fn 0AH usage in graphics mode.
; Not redirected. Beep and tab printed over unless you update the cursor.
; Beep and tab printed as symbols.
MOV AH,10H ; pause.
INT 16H
MOV DX,OFFSET Fifth ; message.
MOV AH,9
INT 21H
MOV AH,0AH ; Write Character
MOV AL,7
MOV BX,0 ; BH = video page number (0-based)
MOV CX,1 ; repeat count.
INT 10H ; Video Int.
MOV AH,03H ; Get Cursor Status
MOV BX,0 ; BH = video page number (0-based)
INT 10H
MOV AH,02H ; Set Cursor Status
MOV BX,0
INC DL ; Cursor Column
INT 10H
MOV AH,0AH
MOV AL,9
MOV BX,0
MOV CX,1
INT 10H
MOV AH,03H
MOV BX,0
INT 10H
MOV AH,02H
MOV BX,0
INC DL
INT 10H
MOV AH,0AH
MOV AL,92
MOV BX,0
MOV CX,1
INT 10H
MOV AH,03H
MOV BX,0
INT 10H
MOV AH,02H
MOV BX,0
INC DL
INT 10H
; - - - Sixth way. - - -
; Int 10H Display Character in Teletype Mode, function 0EH.
; ref. "Programmer's Guide to PC Video Systems"
; Non-DOS BIOS video function. BL used in graphics modes.
; Not redirected.
; Bell, backspace, linefeed, and carriage return are treated as control.
; Tab printed as symbol.
MOV AH,10H ; pause.
INT 16H
MOV DX,OFFSET Sixth ; message.
MOV AH,9
INT 21H
MOV AH,0EH ; Write Teletype
MOV AL,7 ; ASCII bell code
INT 10H ; Video Int.
MOV AH,0EH
MOV AL,9
INT 10H
MOV AH,0EH
MOV AL,92
INT 10H
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Exit processing.
MOV AH,4CH ; DOS 2+ End Program
MOV AL,0 ; return value
INT 21H ; Exit to DOS
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CODE ENDS
END START
QuoteSome of what Dave said didn't quite sit well
was it something i said ?
did it work as expected, Steve ?
i think INT 29h is documented - you just have to look at the right document - lol
by reading your references, i'd say you could use a set of Ralf Brown's Interrupt List files
http://www.cs.cmu.edu/~ralf/files.html
Hi Dave,
Quote from: dedndave on August 08, 2009, 03:34:18 PM
was it something i said ?
Sort of, Why would ANSI work when redirection doesn't?
Quote
did it work as expected, Steve ?
After reading up, sorta. Kinda. So I wrote the program to filter
out the bats in the belfry.
Quote
i think INT 29h is documented - you just have to look at the right document - lol
Well yes. But not by Microsoft. Many "unofficial" sources do. But,
as M$ doesn't, it's "undocumneted". Perhaps a nit pick.
Quote
by reading your references, i'd say you could use a set of Ralf Brown's Interrupt List files
http://www.cs.cmu.edu/~ralf/files.html
Got them thanks. The "Undocumented DOS" appendix is essentialy a
hard copy of an early version. Ralf Brown is one of the authours. At one
time I had the list all set up nicely. That got eaten somewhere along
the line. Probably ought to restore it...
Regards,
Steve N.
QuoteSort of, Why would ANSI work when redirection doesn't?
as i said before, DOS INT 21h functions 2 and 9 (and others) use INT 29h to output characters to the screen
DOS INT 21h
--------->
redirection
<--------- no yes --------->
DOS INT 29h
--------->
ANSI.SYS
<---------
BIOS INT 10h
years ago, i wrote an ANSI.SYS driver for VGA displays (i.e. VGAANSI.SYS)
i added the function of a screen-saver that blanks the (DOS) screen after so much time of inactivity
for the screen saver, you could configure the timeout duration and which BIOS INT's would cause the screen to un-blank
also, i added the ability to control the size of the sequence and key reassignment buffers
in that driver, i wrote an INT 29h handler
it was documented in ms ansi.sys device driver documentation that you had to do so in order to handle esc sequences
so, it was documented by ms, just not in a very obvious place - lol
i probably have a copy of the source someplace if anyone is interested