Hello,
Doing some work with pointers in PowerBasic 3.2 I discovered that
they are handled just as double words. This can lead to errors. For
instance, declare
dim bptr as byte ptr
and give it the value
bptr = &h3000ffff
It's a perfectly legal pointer, and you can print the byte at that
address by
print @bptr
Now you want to print the next byte. You should think this could be
accomplished by
incr bptr
print @bptr
Alas, here the similarity between pointers en double words breaks.
After the increment PowerBasic says the value of the pointer is
&h30010000
but now it's not pointing to the next byte in memory! On the
contrary, it points way back in the old segment. In pointer
arithmetic
&h30010000 is the same as &h30000010
The real addres is segment * 16 + offset, and in both cases it is
&h30010, as you can see.
The real address with pointer value &h3000ffff is &3ffff. One more
is &h40000, so the new value of the pointer after the increment
should be
&h40000000
or also &h3001fff0 etc. You could fill in every possible segment
from &h3001 to &h4000 inclusive, and add the appropriate offset.
Another related problem is the following. In principle you should be
able to read the integer at address &h3000ffff. The second, high,
byte however is outside the segment boundary. When you try to read an
integer from this address DOS hangs. That happens also when you try
such a thing in assembler. But with PB pointers I think PB should
internally adjust the segment and offset, for instance to
&h3001ffef, in order to be able to read the integer value at that
address.
Friendly greeting you,
Hans Lunsing, Fido : 2:281/607.214, 2:282/610.12
Internet : jlunsing@doge.nl
--- Terminate 4.00/Pro
# Origin: BBS De Lauwers For BASIC Programmers! ++31594688407 (2:282/610.12)
---------------
* Origin: United Bbs Systems Europe MailGate to -> Fido USA (2:2802/337.0)
|