home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Shareware Masterblend
/
cdsharewaremasterblend.iso
/
utils
/
adj-ramd
/
njramd.asm
< prev
next >
Wrap
Assembly Source File
|
1991-06-23
|
42KB
|
1,436 lines
; 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
; Version 1.30 of 05 Dec 1989
; Version 1.40 of 23 Jun 1991
; Shareware $15 Please register!
; Assemble with
; MASM NJRAMD;
; (Use MASM /DV286 NJRAMD; to assemble 286 version.)
; LINK NJRAMD;
; EXE2BIN NJRAMD.EXE NJRAMD.SYS
; DEL NJRAMD.EXE
; --> DEVICE DRIVER FORMAT FILE <--
; --> REMEMBER TO USE EXE2BIN <--
; ---------------------------------------------------------------------------
; 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
; ---------------------------------------------------------------------------
EMM equ 067h ; the E/EMS memory manager
; ---------------------------------------------------------------------------
; 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 #
; ---------------------------------------------------------------------------
; E/EMM Routines
; These are the E/EMM functions that we use. (These are specific functions
; of the EMM interrupt.)
E_PageBase equ 041h ; determine the Page Fram Base Addr
E_Counts equ 042h ; determine free/total mem
E_Open equ 043h ; open, allocate, obtain handle ID
E_MapPage equ 044h ; map a logical page into window
E_Version equ 046h ; get the E/EMM version number
E_Save equ 047h ; save mapping context
E_Restore equ 048h ; restore mapping context
; ---------------------------------------------------------------------------
; 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".
; 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.
PUBLIC NextPlace
PUBLIC Attrib, JumpTable, TopCommand, RBPoint, RBPointOff, RBPointSeg, SaveSS
PUBLIC SaveSP, SaveAX, EMMHandle, EMMBase, StackTop, STRATPROC, Strategy
PUBLIC INTPROC, Interrupt, NoSaveM, FreakOut, IOCTLInput, ReadNoWait
PUBLIC InputStatus, InputFlush, badcommand, BigLog, NoRestore, MC, MediaCheck
PUBLIC BBPB, BuildBPB, BPBArray, OurBoot, OurBPB, SecSize, SecPerCluster
PUBLIC RDirLen, DiskSize, SecPerFAT, BootCode, TAddr, TAddrOff, TAddrSeg
PUBLIC TDone, TCount, TSector, RSEC, Read, ReadLoop, ReadDone
PUBLIC ReadFinish, ReadError, WSEC, Write, WriteLoop, WriteDone, WriteFinish
PUBLIC WriteError, CLIPPER, RangeError, InRange, SPEAKERCLICK, MakeClick
PUBLIC NoClick, SpeakerFlag, LastTime, GS, GetSector, CantGet, LastResident
PUBLIC EMMPresent, GenFailHook, EMMPresent2, MemForMe, EatingWhite, GotOption
PUBLIC NoBump, NotSilence, PagesLoop, LastDigit, NotPages, NotUseAll
PUBLIC Unrecognized, EndOfLine, GoodSize, GotPages, BigBust, ReTry
PUBLIC GoodCombo, NoKludge, WipeOut, WipeOut2, FindFree, CalcEMMFree
PUBLIC CalcDiskFree, ClickOkay, MsgOkay, InitFail, GenFail, HowMuch
PUBLIC RqdPages, MajorVersion, OurVolume, Banner, EMMIDString, General
PUBLIC NoEMMThere, EMMError, Init, NoMem, TooBig, BadOption, NoClicking
PUBLIC Installed, DriveName, InstalledB, Installed2, UsedSpace, Bin2Dec
PUBLIC Bin2DecLoop, Bin2DecDigit, WorkAreaL, WorkAreaH
; --------------------