"HubbleBubble" <phil_simmons@[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
variations
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:
les di,[Buff] ; ES:DI = address of Buff
les di,[es:di] ; ES:DI = 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* a 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
offsets.
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) = 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 Vision
http://homepage.ntlworld.com/gvision


|