Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Borland > Re: Can Anyone ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 8 Topic 1086 of 1118
Post > Topic >>

Re: Can Anyone tell me why this doesn't work?

by "Jason Burgon" <jaynews@[EMAIL PROTECTED] > Feb 22, 2008 at 03:26 PM

"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
 




 8 Posts in Topic:
Can Anyone tell me why this doesn't work?
HubbleBubble <phil_sim  2008-02-21 03:32:51 
Re: Can Anyone tell me why this doesn't work?
Wolfgang.Ehrhardt.PLEASE.  2008-02-21 18:11:48 
Re: Can Anyone tell me why this doesn't work?
"Jason Burgon"   2008-02-22 01:24:25 
Re: Can Anyone tell me why this doesn't work?
HubbleBubble <phil_sim  2008-02-22 03:49:22 
Re: Can Anyone tell me why this doesn't work?
"Jason Burgon"   2008-02-22 15:26:06 
Re: Can Anyone tell me why this doesn't work?
Marco van de Voort <ma  2008-02-22 09:52:10 
Re: Can Anyone tell me why this doesn't work?
"Jason Burgon"   2008-02-23 06:12:47 
Re: Can Anyone tell me why this doesn't work?
HubbleBubble <phil_sim  2008-02-28 01:27:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 23:30:53 CDT 2008.