On Feb 22, 3:26=A0pm, "Jason Burgon" <jayn...@[EMAIL PROTECTED]
> wrote:
> "HubbleBubble" <phil_simm...@[EMAIL PROTECTED]
> wrote:
> > Right, this is where I get deeply confused - I'm trying to write code
> > which will work in both real and protected mode. Maybe this is an
> > unrealistic ambition.
>
> No, it's trivial in 16:16 protected mode.
>
> > Your suggestion of using les di,[buff] is one I tried (and many
variatio=
ns
>
> until I > tore most of my hair out) but in real mode I repeatedly get an
> invalid pointer
>
> > error with the passed pointer when trying to free its memory (it gets
> corrupted
> > somehow) - by using the offset only this problem was avoided ...
>
> Then something somewhere else is wrong because you should definately be
> loading the complete pointer with "les".
>
> Ah, I've just noticed that you pass Buff as a "var" parameter, but Buff
is=
> itself a pointer, so what you have in Buff is a pointer to a pointer,
> because "var" parameters are passed as pointers. So what you need to do
is=
> redefine your function as:
>
> procedure gline8(x1,x2,y: Word; Buff : Pointer); assembler;
>
> OR
>
> procedure gline8(x1,x2,y: Word; var Buff : TScanLine); assembler;
>
> Where TScanLine is an array of bytes or whatever.
>
> *Now* you can use "les" to obtain the *value* of Buff, rather than the
> address of where Buff is stored. As you wrote it, you need to do this:
>
> =A0 les =A0di,[Buff] ; ES:DI =3D address of Buff
> =A0 les =A0di,[es:di] ; ES:DI =3D value of Buff
>
> > in protected mode if I load the segment register es then I get error
216=
-
> > obviously since protected mode wants a selector not a segment -
>
> No, you don't understand. In protected mode, the upper 16-bits of a
16:16
> pointer *is* =A0a selector, or at least that's what it's supposed to be.
>
> > so I guess I have to convert the pointer segment to a selector in
pmode?=
>
> Only if it was supplied by DOS or the BIOS.
>
> > but I don't know how to do this - anyway pmode is happy with just
offset=
s.
>
> I can assure you that 16-bit pmode most certainly isn't "just happy with
> offsets". What the pmode version is probably doing is reading/writing to
> somwhere else in memory, or you're just "getting lucky" that
> Seg(AddressOfBuff) =3D Seg(Buff).
>
> Maybe I should stick to pmode only :)
>
> Hmm, I think you need to understand pointers a little more first. :-)
>
> --
> Jay
>
> Jason Burgon - author of Graphic
Visionhttp://homepage.ntlworld.com/gvisio=
n
Yes that was it Jason - now works perfectly. Yes I did need to
understand more about pointers. Lacking anything but the tersest
description I assumed that I would need to pass the input pointer as a
var like in high level language since I wanted to alter its contents -
Now that I better understand the mechanism I've added your explanation
to my coding notes.
Thanks to all once again.
Phil :)


|