home *** CD-ROM | disk | FTP | other *** search
- (*
- REFORMAT.INC
- Inline code for Int25 and Int26 procedures, REFORMAT.PAS
- Author David Kirschbaum (kirsch@braggvax.arpa)
- REFORMAT.PAS author Jos Wennmacker (URC) apr '86.
-
- Jos originally had two .ASM files to produce external procedures
- for absolute disk read and write.
-
- Rather than force the user to go through the assembly routine and keep
- track of a bogus .COM file, I've used INLINE and two different hacks of
- the original .ASM code to create Turbo Pascal inline code.
-
- Since we only use one Registers record variable, AND it's a global one,
- I stripped out passing its address as a parameter and just rely on it
- being in the DS data segment.
-
- Because the code is so redundant (only the interrupt number is different),
- I combined the two procedures, Int25 and Int26, into a new single procedure,
- Int2526. Now you must pass the interrupt number you desire (25H or 26H).
- I resisted (with difficulty) the temptation for a little self-modifying code,
- rather than listen to the screams on the networks!
-
- This code (plus other changes I made to REFORMAT.PAS to tighten and speed
- it up a little) runs perfectly on an XT clone (Gulfstream Micro Systems
- 80286 with a 10 Meg hard disk, 5.25" floppy, PC-DOS 3.1).
-
- Full credit, honors and glory for REFORMAT.PAS to the original author.
- This extension is released to the Public Domain with no constraints.
-
- David Kirschbaum, Toad Hall
- kirsch@braggvax.arpa
- *)
-
- PROCEDURE Int2526(R : BYTE);
- {Uses global variable Register. Pass $25 (read) or $26 (write)
- as R for the function you desire.
- }
- BEGIN
- Inline(
- $1E { push ds ; save what we are about to clobber}
- /$BE/>REGISTERS { mov si,>Registers ; load DS:Regs (global) address}
- /$8A/$04 { mov al,byte ptr[si] ;Regs.al}
- /$8B/$5C/$02 { mov bx,[si+2] ;Regs.bx}
- /$8B/$4C/$04 { mov cx,[si+4] ;Regs.cx}
- /$8B/$54/$06 { mov dx,[si+6] ;Regs.dx}
- /$56 { push SI ;save Regs addr}
- /$8B/$74/$0E { mov si,[si+14] ;Regs.DS}
- /$8E/$DE { mov ds,si ;DS=Regs.DS}
- /$55 { push bp ; DOS destroys it}
- /$FC { cld ; if you don't, DOS makes a mess!}
- /$80/$BE/>R/$25 { cmp byte ptr >R[BP],$25 ;doing a read?}
- /$75/$05 { jne Do26 ; nope}
- /$CD/$25 { int $25 ; yep, do the read}
- /$E9/$02/$00 { jmp Done ; and skip}
- {Do26:}
- /$CD/$26 { int $26 ;do the write}
- {Done: ;old flags are still on the stack!}
- /$5F { pop DI ;so save them here a sec}
- /$5D { pop BP}
- /$5E { pop SI ;Regs addr}
- /$1F { pop DS ;Regs seg}
- /$9C { pushf ;move the new flags...}
- /$8F/$44/$12 { pop [si+18] ;into as Reg.Flags}
- /$89/$04 { mov [si],ax ;possible errors}
- /$57 { push DI ;old flags..}
- /$9D { popf ;..restored}
- );
- {BX,CX,DX should not have changed, so no need to post Regs.}
- END; {of Int2526}
-