home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 8801 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  3.3 KB

  1. Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!news.u.washington.edu!milton.u.washington.edu!buckley
  2. From: buckley@milton.u.washington.edu ( )
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Assembler troubles ...HELP!
  5. Message-ID: <1992Aug26.030318.24110@u.washington.edu>
  6. Date: 26 Aug 92 03:03:18 GMT
  7. References: <1992Aug25.193521.1012@sactoh0.sac.ca.us>
  8. Sender: news@u.washington.edu (USENET News System)
  9. Organization: University of Washington, Seattle
  10. Lines: 120
  11.  
  12. Hello,
  13.   I am very new to assembly language and I have a question.  I am
  14. trying to write a tsr that will write characters typed from they
  15. keyboard into a file.  I have been making my attempts by using
  16. a tsr skeleton provided in Peter Norton's Assembler book.  I have
  17. been able to read the keystrokes and display them on a different
  18. section of screen,make a speaker beeping noise after each keystroke
  19. etc.  My problem is when I try to write the characters to a file.
  20. I can open a file, but after about 5 or 6 keystrokes my system
  21. freezes up.  I have tried all sorts of methods of writing the
  22. characters with no luck.  I have enclosed the basic tsr skeleton
  23. below.  It will open a file, set up the keyboard interrupt vector,
  24. and launch the tsr section of the code.  Could someone help
  25. me in figuring out how to write the characters to a file using
  26. the skeleton of code below?  I could really use the help!!!
  27. Thanks!
  28. Jim
  29. buckley@milton.u.washington.edu
  30.  
  31.  
  32. --------------------------CODE STARTS HERE--------------------------------
  33. INTERRUPT_NUMBER        EQU     9
  34.     .MODEL SMALL
  35.  
  36. ROM_BIOS_DATA   SEGMENT AT 40H   ;keyboard buffer here
  37.     ORG     1AH
  38.     HEAD    DW      ?     ;unread characters go from Head to Tail
  39.     TAIL    DW      ?
  40.     BUFFER  DW      16 DUP (?)
  41.     BUFFER_END      LABEL   WORD
  42. ROM_BIOS_DATA   ENDS
  43.  
  44.     .CODE
  45.     ORG     100H
  46. FIRST:  JMP     LOAD_PROG
  47.  
  48.  
  49.     OLD_KEY_INT     LABEL   WORD
  50.     OLD_KEYBOARD_INT        DD      ?    ;location of old keybd intrpt
  51.     FILE    DB      "D:\ABC.DAT",0        ;test file name to write to
  52.     HANDLE  DW    0            ;file handle
  53.  
  54.  
  55. PROG    PROC
  56.     PUSH    AX
  57.     PUSH    BX
  58.     PUSH    CX
  59.     PUSH    DX
  60.     PUSH    DI
  61.     PUSH    SI
  62.     PUSH    DS
  63.     PUSH    ES
  64.     PUSHF
  65.     CALL    OLD_KEYBOARD_INT
  66.  
  67. ;get character typed
  68.     ASSUME DS:ROM_BIOS_DATA
  69.     MOV     BX,ROM_BIOS_DATA
  70.     MOV     DS,BX
  71.     MOV     BX,TAIL
  72.     CMP     BX,HEAD
  73.     JE      EXIT
  74.     SUB     BX,2
  75.     CMP     BX,OFFSET BUFFER
  76.     JAE     NO_WRAP
  77.     MOV     BX,OFFSET BUFFER_END
  78.     SUB     BX,2
  79. NO_WRAP: MOV    DX,[BX]  ;dx contains character typed
  80.  
  81. ; NEW CODE GOES HERE --
  82.  
  83.  
  84. ;say an alt-s  (a DX of 1F00)  closes file
  85.  
  86.     CMP     DX,1F00H
  87.     JNE    WRITE
  88.     ;code to close file goes here
  89.     JMP    EXIT
  90.     
  91. WRITE:
  92.     ;code to write characters to file
  93.  
  94. ;end of new code--restore registers
  95. EXIT:   POP     ES
  96.     POP     DS
  97.     POP     SI
  98.     POP     DI
  99.     POP     DX
  100.     POP     CX
  101.     POP     BX
  102.     POP     AX
  103.     IRET
  104. PROG    ENDP
  105.  
  106.  
  107. ;initialize everything/open file (not part of tsr)
  108. LOAD_PROG       PROC
  109.     
  110.     ;OPEN FILE--ASSUME IT ALREADY EXISTS FOR NOW
  111.     MOV     DX,OFFSET FILE
  112.     MOV     AX,3D02H
  113.     INT     21H
  114.     MOV     HANDLE,AX
  115.  
  116.  
  117.     ;save old intrpt vector
  118.     MOV     AH,35H        
  119.     MOV     AL,INTERRUPT_NUMBER
  120.     INT     21H
  121.     MOV     OLD_KEY_INT,BX
  122.     MOV     OLD_KEY_INT[2],ES
  123.     ;set new interrupt vecotr
  124.     MOV     AH,25H
  125.     LEA     DX,PROG
  126.     INT     21H
  127.     MOV     DX,OFFSET LOAD_PROG
  128.     INT     27H
  129. LOAD_PROG       ENDP
  130. END     FIRST
  131. --------------------------------CODE ENDS HERE--------------------------------
  132.