Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 10th, 2006, 2:30 PM   #1
Roku
Newbie
 
Join Date: Apr 2006
Posts: 1
Rep Power: 0 Roku is on a distinguished road
Writing to a file from a TSR (MASM16)

Hi,

I am having a hard time writing to a file from a TSR routine. The routine is supposed to write a line of text to a file when the F9 key is pressed. Instead it just prints the line to the screen. I am only posting the parts of the routine I having problems with. I thikn I setup the IVT table correctly.

Thanks,
Kevin

; --------------------------------------------------
; Example layout for interrupt handler.

.model tiny
.486
text segment public 'CODE'

; Note, must put start of program at 100 hex,

org 100h
start:
jmp init

; note, required to "start" just past the "org",
; so jump, not call, since we will not return.

myint proc far
pushf
call CS:oldn

push ax
push bx
push cx
push dx
push ds
push es

mov ax,cs
mov ds,ax

; Check for F9 down
cmp ax, 43h
je no_err

; Check for F9 up, file write
cmp ax, 0c3h
je filewrite

; If we see any other key, just beep
jmp err

; write the stars line to the file
filewrite:
mov ah, 40h
mov bx, es:fhand
mov cx, 82
lea dx, es:stars
int 21h
jc err

; Commit the line
mov ah, 68h
mov bx, es:fhand
int 21h
jmp no_err

Last edited by Roku; Apr 10th, 2006 at 2:43 PM. Reason: Cleaing this up to conform with the forum rules (I am a newbie)
Roku is offline   Reply With Quote
Old Apr 10th, 2006, 2:37 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
As a new member, it would seem prudent to read the forum's rules/FAQ and a "How to Post...." thread, just to get in tune with this (and many similar) community(s), right? Attention to the part regarding code tags would certainly be in order.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Apr 29th, 2006, 8:08 PM   #3
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,193
Rep Power: 5 lectricpharaoh will become famous soon enough
Your problem might be that DOS is non-reentrant, and you're trying to call it from what appears to be an interrupt context. Without seeing exactly how you get those scancodes into AX, or under what conditions your TSR is invoked, I can't say for sure (since, according to the code, AX has your program's CS value).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is online now   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:33 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC