home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!news.u.washington.edu!milton.u.washington.edu!buckley
- From: buckley@milton.u.washington.edu ( )
- Newsgroups: comp.os.msdos.programmer
- Subject: Assembler troubles ...HELP!
- Message-ID: <1992Aug26.030318.24110@u.washington.edu>
- Date: 26 Aug 92 03:03:18 GMT
- References: <1992Aug25.193521.1012@sactoh0.sac.ca.us>
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington, Seattle
- Lines: 120
-
- Hello,
- I am very new to assembly language and I have a question. I am
- trying to write a tsr that will write characters typed from they
- keyboard into a file. I have been making my attempts by using
- a tsr skeleton provided in Peter Norton's Assembler book. I have
- been able to read the keystrokes and display them on a different
- section of screen,make a speaker beeping noise after each keystroke
- etc. My problem is when I try to write the characters to a file.
- I can open a file, but after about 5 or 6 keystrokes my system
- freezes up. I have tried all sorts of methods of writing the
- characters with no luck. I have enclosed the basic tsr skeleton
- below. It will open a file, set up the keyboard interrupt vector,
- and launch the tsr section of the code. Could someone help
- me in figuring out how to write the characters to a file using
- the skeleton of code below? I could really use the help!!!
- Thanks!
- Jim
- buckley@milton.u.washington.edu
-
-
- --------------------------CODE STARTS HERE--------------------------------
- INTERRUPT_NUMBER EQU 9
- .MODEL SMALL
-
- ROM_BIOS_DATA SEGMENT AT 40H ;keyboard buffer here
- ORG 1AH
- HEAD DW ? ;unread characters go from Head to Tail
- TAIL DW ?
- BUFFER DW 16 DUP (?)
- BUFFER_END LABEL WORD
- ROM_BIOS_DATA ENDS
-
- .CODE
- ORG 100H
- FIRST: JMP LOAD_PROG
-
-
- OLD_KEY_INT LABEL WORD
- OLD_KEYBOARD_INT DD ? ;location of old keybd intrpt
- FILE DB "D:\ABC.DAT",0 ;test file name to write to
- HANDLE DW 0 ;file handle
-
-
- PROG PROC
- PUSH AX
- PUSH BX
- PUSH CX
- PUSH DX
- PUSH DI
- PUSH SI
- PUSH DS
- PUSH ES
- PUSHF
- CALL OLD_KEYBOARD_INT
-
- ;get character typed
- ASSUME DS:ROM_BIOS_DATA
- MOV BX,ROM_BIOS_DATA
- MOV DS,BX
- MOV BX,TAIL
- CMP BX,HEAD
- JE EXIT
- SUB BX,2
- CMP BX,OFFSET BUFFER
- JAE NO_WRAP
- MOV BX,OFFSET BUFFER_END
- SUB BX,2
- NO_WRAP: MOV DX,[BX] ;dx contains character typed
-
- ; NEW CODE GOES HERE --
-
-
- ;say an alt-s (a DX of 1F00) closes file
-
- CMP DX,1F00H
- JNE WRITE
- ;code to close file goes here
- JMP EXIT
-
- WRITE:
- ;code to write characters to file
-
- ;end of new code--restore registers
- EXIT: POP ES
- POP DS
- POP SI
- POP DI
- POP DX
- POP CX
- POP BX
- POP AX
- IRET
- PROG ENDP
-
-
- ;initialize everything/open file (not part of tsr)
- LOAD_PROG PROC
-
- ;OPEN FILE--ASSUME IT ALREADY EXISTS FOR NOW
- MOV DX,OFFSET FILE
- MOV AX,3D02H
- INT 21H
- MOV HANDLE,AX
-
-
- ;save old intrpt vector
- MOV AH,35H
- MOV AL,INTERRUPT_NUMBER
- INT 21H
- MOV OLD_KEY_INT,BX
- MOV OLD_KEY_INT[2],ES
- ;set new interrupt vecotr
- MOV AH,25H
- LEA DX,PROG
- INT 21H
- MOV DX,OFFSET LOAD_PROG
- INT 27H
- LOAD_PROG ENDP
- END FIRST
- --------------------------------CODE ENDS HERE--------------------------------
-