1. Machine level file I/O
- Posted by Brian Jackson <bjackson at PRINTINGINC.COM> Feb 28, 1999
- 425 views
Ok. I've hit a roadblock with FILEMAN.E, and I need some help to figure it out. The problem stems from using the DosSeek() function of DOSWRAP.E, which is a machine level call to int21h, function 4200h. My problem is that when I attempt to do a seek, I get some strange results. For example, if I try to seek to the 1,024th byte in a file, using DosSeek(fn, 1024, 0), I end up much deeper into the file (more like 1024 * 256). That led me to believe that DOS automatically assumes a 256 byte sector, but it's not that simple either. When I tried DosSeek(fn, 4, 0), I wound up at the 4th byte in the file, and thus, am totally perplexed. If anyone has some information on how this routine actually works, I could really use the help. Thanks, Brian Jackson bjackson at printinginc.com
2. Re: Machine level file I/O
- Posted by Pete Eberlein <eberlein at ALTA.CS.ORST.EDU> Feb 28, 1999
- 415 views
There a are some bugs in the DosSeek function. It should read: global function DosSeek(integer Handle, integer Distance, integer Origin) -- Move the file read/write pointer to specified position -- return new pointer position or -1 if error. -- parameters: Handle is DosOpen() handle -- Distance is distance to move to -- Origin from where Distance is added -- Origin = 0 beginning of file + Distance -- Origin = 1 current location + Distance -- Origin = 2 end of file + Distance sequence regs regs = repeat(0,10) regs[REG_AX] = #4200+Origin regs[REG_BX] = Handle regs[REG_CX] = floor(Distance/#10000) regs[REG_DX] = remainder(Distance,#10000) regs = dos_interrupt(#21,regs) if and_bits(regs[REG_FLAGS],1) then return -1 -- failed end if return regs[REG_AX] + #10000 * regs[REG_DX] end function --DosSeek() On Sun, 28 Feb 1999, Brian Jackson wrote: > Ok. I've hit a roadblock with FILEMAN.E, and I need some help to figure it > out. The problem stems from using the DosSeek() function of DOSWRAP.E, > which is a machine level call to int21h, function 4200h. My problem is that > when I attempt to do a seek, I get some strange results. For example, if I > try to seek to the 1,024th byte in a file, using DosSeek(fn, 1024, 0), I > end up much deeper into the file (more like 1024 * 256). That led me to > believe that DOS automatically assumes a 256 byte sector, but it's not that > simple either. When I tried DosSeek(fn, 4, 0), I wound up at the 4th byte > in the file, and thus, am totally perplexed. If anyone has some information > on how this routine actually works, I could really use the help. > > Thanks, > Brian Jackson > bjackson at printinginc.com >
3. Re: Machine level file I/O
- Posted by Bernie Ryan <bwryan at PCOM.NET> Feb 28, 1999
- 417 views
I took a quick look at the dosseek and it looks like a problem is caused when you use a multiple of 256. Try a seek that is one byte more or less 1023 or 1025. DOSWRAP may have overlooked this condition in calculating the CX:DX values. Bernie
4. Re: Machine level file I/O
- Posted by Brian Jackson <bjackson at PRINTINGINC.COM> Feb 28, 1999
- 411 views
- Last edited Mar 01, 1999
Thanks Bernie and Pete for replying so quickly. Once I installed the new code into DOSWRAP, it seemed to work just fine. One more question though. If int21h, 4200h uses 4-bytes execute the seek (CX:DX), how would I do a seek to a position greater than 256^4, or it this the DOS limit on low level I/O? Thanks again, Brian Jackson bjackson at printinginc.com