Mail Archives: djgpp/2010/04/14/14:45:25.1
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
From: | "Rod Pemberton" <do_not_have AT havenone DOT cmm>
|
Newsgroups: | comp.os.msdos.djgpp,comp.os.msdos.programmer
|
Subject: | NASM version of John Santic's stderr to stdout TSR
|
Date: | Wed, 14 Apr 2010 14:25:49 -0400
|
Organization: | Aioe.org NNTP Server
|
Lines: | 52
|
Message-ID: | <hq5193$5pq$1@speranza.aioe.org>
|
NNTP-Posting-Host: | pldq+kT97bAAp/ObDwnZyQ.user.speranza.aioe.org
|
X-Complaints-To: | abuse AT aioe DOT org
|
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2800.1983
|
X-Notice: | Filtered by postfilter v. 0.8.2
|
X-Newsreader: | Microsoft Outlook Express 6.00.2800.1983
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
Bytes: | 2536
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
The code below is a binary compatible NASM conversion
of John Santic's stderr to stdout TSR from:
http://johnsantic.com/comp/tsr.html
Rod Pemberton
; STDERROR.ASM
BITS 16
ORG 0x100 ; require for .COM file
SECTION .text
start: jmp short start1
nop
old_vector: dw 00h,00h ; save old DOS int 21 vector
start1:
mov ax, 0
mov es, ax
les bx, [es:21h * 4] ; read the vector for DOS int 21
mov [old_vector], bx ; save it so we can chain to it
mov [old_vector + 2], es
mov ax, 0
mov es, ax
cli ; disable interrupts while we write
mov word [es:21h * 4], isr ; chain our handler to DOS int 21
mov [es:(21h * 4) + 2], cs
sti ; enable interrupts
mov ax, 3100h ; function code to become resident
mov dx, last / 16 + 11h ; reserve memory paragraphs for us
int 21h ; return to DOS but remain resident
; This interrupt service routine is chained to the main DOS int 21 vector.
isr: cmp ah, 40h ; function code = write to file?
jne exit ; jump if no, don't do anything
cmp bx, byte 2 ; handle = stderr?
jne exit ; jump if no, don't do anything
dec bx ; force handle to stdout
exit: jmp far [cs:old_vector] ; let DOS do its thing
last equ $ - start ; how much memory we use
- Raw text -