home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Shareware Masterblend
/
cdsharewaremasterblend.iso
/
utils
/
adj-ramd
/
njramdx.asm
< prev
next >
Wrap
Assembly Source File
|
1991-06-23
|
39KB
|
1,331 lines
; DEBUG EQU TRUE
V286 EQU TRUE ; No XMS on 8088 PC's!
; Nifty James' Famous Expanded Memory Disk Drive
; (C) Copyright 1987 by Mike Blaszczak. All Rights Reserved
; Version 1.01 of 24 May 1987
; Version 1.10 of 25 May 1987
; Version 1.15 of 31 May 1987
; Version 1.20 of 16 Oct 1987
; Modified Terje Mathisen 20 March 90
; Version 1.02 of XMS-compatible NJRAMDX 14 Sep 1990
; Version 1.40 of 23 Jun 1991 by Mike Blaszczak
; Shareware $15 Please contribute!
; Assemble with
; TASM NJRAMDX
; (Comment out V286 EQU TRU for 8088 version.)
; TLINK /t NJRAMDX, NJRAMDX.SYS
; --> DEVICE DRIVER FORMAT FILE <--
; ---------------------------------------------------------------------------
; ASCII Characters
bell equ 7 ; bell character
tab equ 9 ; tab character
lf equ 10 ; linefeed
cr equ 13 ; carriage return
space equ 32 ; space
eos equ '$' ; end of DOS string
; ---------------------------------------------------------------------------
; I/O Ports
Speak equ 061h ; speaker port
SpeakMask equ 011111110b ; mask for speaker set bit
SpeakToggle equ 000000010b ; toggle bit for the speaker
; ---------------------------------------------------------------------------
; DOS Calls
; These are DOS functions used by the driver.
DisplayOut equ 002h ; call to print a single character
PrintString equ 009h ; call to print a '$' string
GetDOSVersion equ 030h ; call to get the DOS version #
; ---------------------------------------------------------------------------
; XMS Routines
; These are the XMS functions that we use. (These are specific functions
; of the XMS call.)
X_Counts equ 08h ; determine free/total mem
X_Alloc equ 09h ; open, allocate, obtain handle ID
X_Version equ 00h ; get the XMS version number
X_Move equ 0Bh ; move an XMS block
; ---------------------------------------------------------------------------
; Driver Equates
; This is the media descriptor byte. Since our RAM drive is not 2 sided,
; does not have 8 sectors per track, and is not removable, we use 0F8h.
; At least, that's what the IBM DTR manual says.
MediaD equ 0F8h
; These are equates used by the driver. They are all status and
; error flags, as defined in the DOS Technical Reference Manual.
; FEDCBA9876543210 <- BIT NUMBERS
errorflag equ 01000000000000000b ; error bit flag
busystat equ 00000001000000000b ; busy status bit flag
donestat equ 00000000100000000b ; done status bit flag
err_writeprot equ 0 ; write protect violation
err_badunit equ 1 ; unknown unit number
err_notready equ 2 ; device not ready
err_unknown equ 3 ; unknown command
err_CRC equ 4 ; error CRC command
err_reqlen equ 5 ; bad request length
err_seek equ 6 ; seek failure
err_badmedia equ 7 ; bad media
err_badsector equ 8 ; sector not found
err_badwrite equ 10 ; write fault
err_badread equ 11 ; read fault
err_general equ 12 ; general failure
; ---------------------------------------------------------------------------
; Structure Definitions
; The structures defined here are used to find information in the
; various request header formats. Of course, being structures, they
; don't take up space... they are used to define offsets for the
; addressing of the request header.
rq equ es:bx ; base address used in routines
; -- Request Header (General Format)
rhead struc
rlen db ? ; length of the structure
unitn db ? ; unit number
command db ? ; command code
status dw ? ; status code (returned by us)
db 8 dup(?); reserved bytes
rhead ends
; -- Request Header (INIT Command)
inithead struc
db (type rhead) dup (?)
units db ? ; number of units
ndadro dw ? ; ending address offset
ndadrs dw ? ; ending address segment
bpboff dw ? ; BPB offset pointer
bpbseg dw ? ; BPB segment pointer
taglet db ? ; drive tag letter
inithead ends
; -- Request Header (Media Check)
mediahead struc
db (type rhead) dup (?)
media db ? ; our meida descriptor byte
change db ? ; changed media flag
mediahead ends
; -- Request Header (Build BPB)
bbpbhead struc
db (type rhead) dup (?)
db ? ; media descriptor byte
baoff dw ? ; transferr buffer address offset
baseg dw ? ; transferr buffer address segment
dw ? ; BIOS parameter block pointer
dw ? ; BIOS parameter block pointer
bbpbhead ends
; -- Request Header (Read and Write)
rwhead struc
db (type rhead) dup (?)
db ? ; media descriptor byte
tbaoff dw ? ; transferr buffer address offset
tbaseg dw ? ; transferr buffer address segment
count dw ? ; sector count
strtsec dw ? ; starting sector number
rwhead ends
; With these headers defined as they are, access to the request header
; and command info fields is greatly simplified. By setting ES:BX to
; point to the request header, the information can be easily referenced
; by using constructs such as
; mov [rq.count],ax
; or
; mov al,[rq.command]
; Note that any part of the program can easily reference any particular
; command's structure, since the line
; db (type rhead) dup (?)
; makes all the command-specific structures "equivalent".
; XMS Extended Memory Move structure
ExtendedMemoryMove STRUC
NrOfBytes dw 0,0
SourceHandle dw 0
SourceOffset dw 0,0
DestHandle dw 0
DestOffset dw 0,0
ExtendedMemoryMove ENDS
; Check to see if this is the 286 version
ifdef V286
.286
; if1
%OUT Enhanced processor version
; endif
ifdef PCL
; if1
%OUT for the PC's Limited 286/386
; endif
endif
else
; if1
%OUT Standard Version
; endif
endif
; This macro is used during debugging. It prints a single character
; via the BIOS screen interface, and leaves the registers unchanged.
ifdef DEBUG
; if1
%OUT DEBUG Version
; endif
PrintChar macro Char
ifdef PCL
push ax
mov al,Char
out 095h,al ; put it digit 3 of smartvu
pop ax
else
push ax ; save the regs
push bx
push dx
mov ah,15
int 010h ; get the current page
mov al,Char
mov ah,14 ; print the character
int 010h
xor dx,dx
mov ah,0 ; also to printer
mov al,Char
; int 017h
pop dx
pop bx ;restore the regs
pop ax
endif
endm
else
PrintChar macro Char ; if not debugging, blow it off
endm
endif
; ---------------------------------------------------------------------------
; Public declarations for SYMDEB
; These are public declarations included to allow SYMDEB to know where
; various lables and addresses are. They are only needed for debugging,
; and serve no other useful purpose.
IF 1
PUBLIC NextPlace
PUBLIC Attrib, JumpTable, TopCommand, RBPoint, RBPointOff, RBPointSeg, SaveSS
PUBLIC SaveSP, StackTop, STRATPROC, Strategy
PUBLIC INTPROC, Interrupt, FreakOut, IOCTLInput, ReadNoWait
PUBLIC InputStatus, InputFlush, badcommand, BigLog, MC, MediaCheck
PUBLIC BBPB, BuildBPB, BPBArray, OurBoot, OurBPB, SecSize, SecPerCluster
PUBLIC RDirLen, DiskSize, SecPerFAT, BootCode
PUBLIC RSEC, Read
PUBLIC WSEC, Write
PUBLIC TestValues, RangeError, SPEAKERCLICK, MakeClick
PUBLIC SpeakerFlag, LastResident
PUBLIC EatingWhite, GotOption
PUBLIC NoBump, NotSilence, PagesLoop, LastDigit, NotPages, NotUseAll
PUBLIC Unrecognized, EndOfLine, BigBust, ReTry
PUBLIC GoodCombo, WipeOut
PUBLIC CalcDiskFree, ClickOkay, MsgOkay, InitFail, GenFail, HowMuch
PUBLIC RqdPages, MajorVersion, OurVolume, Banner, General
PUBLIC NoEMMThere, EMMError, Init, NoMem, TooBig, BadOption, NoClicking
PUBLIC Installed, DriveName, InstalledB, Installed2, UsedSpace, Bin2Dec
PUBLIC Bin2DecLoop, Bin2DecDigit, WorkAreaL, WorkAreaH
ENDIF
; ---------------------------------------------------------------------------
driver segment para public
assume cs:driver,ds:driver,es:driver,ss:driver
org 0 ; drivers begin at zero
firstplace equ this byte ; this is the first byte
; ---------------------------------------------------------------------------
; Device Head