Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

TSR vs DEVICE= (Announce)

posted by Japheth Homepage, Germany (South), 19.06.2010, 09:02

> TSR's are actually "easier" to write. While CONFIG.SYS is being processed,
> many of the DOS services that you generally take for granted (even very
> basic things like writing text to the screen, manipulating files, and
> redirection/piping) are limited or non-existent.

I think this assumption is a bit too pessimistic. When a driver is loaded, DOS usually HAS a current PSP - its value is 84xxh for MS-DOS 7.1, for FreeDOS it's 0060h. So file operations are possible, also screen output. What's probably missing, are environment variables.

Here's the test driver ("testdrv.asm") which I used to display the PSP from within a driver. Create it with "jwasm -mz testdrv.asm".



;--- dummy driver which displays the current PSP

        .286
        .model small
        .386

iodat struc
cmdlen  db      ?       ;+ 0:laenge der struktur
unit    db      ?       ;+ 1:
cmd     db      ?       ;+ 2
status  dw      ?       ;+ 3
        db      8 dup (?); reserviert
media   db      ?       ;+ 0d
trans   dd      ?       ;+ 0e
count   dw      ?       ;+ 12   bei init:offset parameterzeile
start   dw      ?       ;+ 14   bei init:segment parameterzeile
drive   db      ?       ;+ 16
iodat ends

        ASSUME DS: _TEXT

_TEXT SEGMENT

        dw 0ffffh
        dw 0ffffh
        dw 8000h                        ;attribute
        dw offset devstrat      ;device strategy
        dw offset devint        ;device interrupt
        db 'TESTDRV$'         ;devicename

befptr  dd 1 dup(?)

devstrat proc far
        mov cs:word ptr[befptr],bx
        mov cs:word ptr[befptr+2],es
        ret
devstrat endp

devint  proc far
        pusha
        push ds
        push es
        lds bx,cs:[befptr]
        mov [bx.iodat.status],8103h
        cmp [bx.iodat.cmd],00
        jnz devi1
        mov [bx.iodat.status],0100h
        mov word ptr [bx+0eh],0000
        mov word ptr [bx+10h],cs
        call main
        lds bx,cs:[befptr]
        mov word ptr [bx+0Eh],0
        mov [bx+10h],cs
devi1:
        pop ds
        pop es
        popa
        ret
devint  endp

dwordout:
        push ax
        shr eax,16
        call wordout
        pop ax
wordout:
        push ax
        mov al,ah
        call byteout
        pop ax
byteout:
        push ax
        shr al,4
        call nibout
        pop ax
nibout:
        and al,0Fh
        add al,30h
        cmp al,'9'
        jbe @F
        add al,7
@@:
if 1
        mov dl,al
        mov ah,02h
        int 21h
else
        mov ah,0Eh
        push bx
        xor bx,bx
        int 10h
        pop bx
endif
        ret

stringout:
        mov ah,09
        int 21h
        ret
charout:
        mov ah,02
        mov dl,al
        int 21h
        ret

dLF  db 13,10,'$'
dPSP db "PSP=$"

main PROC NEAR
        push cs
        pop ds
        mov dx,offset dPSP
        call stringout
        mov ah,51h
        int 21h
        mov ax,bx
        call wordout
        mov dx,offset dLF
        call stringout
        mov cx,8
        mov es,bx
        xor bx,bx
nextline:
        push cx
        mov cx,16
nextbyte:
        push cx
        mov al,es:[bx]
        inc bx
        call byteout
        mov al,' '
        call charout
        pop cx
        loop nextbyte
        mov dx,offset dLF
        call stringout
        pop cx
        loop nextline
        ret
main endp

exeint proc
        call main
        mov ax,4C00h
        int 21h
exeint endp

_TEXT ENDS

        .stack 200h

        END exeint

---
MS-DOS forever!

 

Complete thread:

Back to the forum
Board view  Mix view
22779 Postings in 2122 Threads, 402 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum