experchange > delphi

skybuck2000 (03-06-20, 06:10 AM)
Type
PtrRec = record
lo, hi : word
end;

Some Turbo Pascal 7 code is reading a file with BlockRead api, after reading some bytes to a pointer^ it checks the bytes read and adjusts the pointer by 4K if high byte is set or something ?

{ adjust when cross segment }
if not Boolean(Hi(wByteRead)) then
PtrRec(lpTmpPtr).hi := PtrRec(lpTmpPtr).hi + $1000;

Why would code adjust/increment a pointer by 4K ? in ms-dos real mode ?

Bye,
Skybuck.
JJ (03-06-20, 07:45 PM)
On Thu, 5 Mar 2020 20:10:11 -0800 (PST), skybuck2000 wrote:
> Type
> PtrRec = record
> lo, hi : word end;
> Some Turbo Pascal 7 code is reading a file with BlockRead api, after
> reading some bytes to a pointer^ it checks the bytes read and adjusts the
> pointer by 4K if high byte is set or something ?
> { adjust when cross segment } if not Boolean(Hi(wByteRead)) then
> PtrRec(lpTmpPtr).hi := PtrRec(lpTmpPtr).hi + 00;
> Why would code adjust/increment a pointer by 4K ? in ms-dos real mode ?
> Bye, Skybuck.


That's for adjusting the buffer pointer to the next 64K.

e.g. if the initial buffer is at $1000:0000, it's same as linear address
$10000. Note: 1 segment is 1 paragraph, or 16 bytes. i.e.:

$1000 (segment)
$0000 (offset)
------ +
$10000

After the first block read, the buffer would be filled from $10000 to
$1FFFF. So, the next buffer location should be at linear address $20000. In
segmented addressing, this is $2000:$0000. The code above increases the
segment by $1000 or 4096.
JJ (03-06-20, 07:50 PM)
On Sat, 7 Mar 2020 00:45:32 +0700, JJ wrote:

[..]
> segmented addressing, this is 00:
> On Thu, 5 Mar 2020 20:10:11 -0800 (PST), skybuck2000 wrote:
> That's for adjusting the buffer pointer to the next 64K.
> e.g. if the initial buffer is at 00:0000, it's same as linear address
> 000. Note: 1 segment is 1 paragraph, or 16 bytes. i.e.:
> 00 (segment)
>
> On Thu, 5 Mar 2020 20:10:11 -0800 (PST), skybuck2000 wrote:
>> Type
>> PtrRec = record
>> lo, hi : word end;
>> Some Turbo Pascal 7 code is reading a file with BlockRead api, after
>> reading some bytes to a pointer^ it checks the bytes read and adjusts the
>> pointer by 4K if high byte is set or something ?
>> { adjust when cross segment } if not Boolean(Hi(wByteRead)) then
>> PtrRec(lpTmpPtr).hi := PtrRec(lpTmpPtr).hi + $1000;
>> Why would code adjust/increment a pointer by 4K ? in ms-dos real mode ?
>> Bye, Skybuck.

> That's for adjusting the buffer pointer to the next 64K.
> e.g. if the initial buffer is at $1000:0000, it's same as linear address
> $10000. Note: 1 segment is 1 paragraph, or 16 bytes. i.e.:
> $1000 (segment)
> $0000 (offset)
> ------ +
> $10000
> After the first block read, the buffer would be filled from $10000 to
> $1FFFF. So, the next buffer location should be at linear address $20000. In
> segmented addressing, this is $2000:$0000. The code above increases the
> segment by $1000 or 4096.00 (offset)
> ------ +
> 000
> After the first block read, the buffer would be filled from 000 to
> FFFF. So, the next buffer location should be at linear address 000. In
> segmented addressing, this is 00:
> On Thu, 5 Mar 2020 20:10:11 -0800 (PST), skybuck2000 wrote:
>> Type
>> PtrRec = record
>> lo, hi : word end;
>> Some Turbo Pascal 7 code is reading a file with BlockRead api, after
>> reading some bytes to a pointer^ it checks the bytes read and adjusts the
>> pointer by 4K if high byte is set or something ?
>> { adjust when cross segment } if not Boolean(Hi(wByteRead)) then
>> PtrRec(lpTmpPtr).hi := PtrRec(lpTmpPtr).hi + $1000;
>> Why would code adjust/increment a pointer by 4K ? in ms-dos real mode ?
>> Bye, Skybuck.

> That's for adjusting the buffer pointer to the next 64K.
> e.g. if the initial buffer is at $1000:0000, it's same as linear address
> $10000. Note: 1 segment is 1 paragraph, or 16 bytes. i.e.:
> $1000 (segment)
> $0000 (offset)
> ------ +
> $10000
> After the first block read, the buffer would be filled from $10000 to
> $1FFFF. So, the next buffer location should be at linear address $20000. In
> segmented addressing, this is $2000:$0000. The code above increases the
> segment by $1000 or 4096.00. The code above increases the
> segment by 00 or 4096.00. The code above increases the
> segment by 00 or 4096.00. The code above increases the
> segment by 00 or 4096.


Checking the high byte of the number of bytes read, is not really needed -
assuming that the requested number of byte to read is 64K. In fact, if not
used properly, it may cause a bug. But can't know for use since the whole
code is not provided.
Similar Threads