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 8 of 8 Topic 1086 of 1118
Post > Topic >>

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

by HubbleBubble <phil_simmons@[EMAIL PROTECTED] > Feb 28, 2008 at 01:27 AM

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 :)
 




 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 Fri Jul 25 0:01:37 CDT 2008.