Talk About Network



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: Some miscel...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 1030 of 1102
Post > Topic >>

Re: Some miscellaneous pascal esoterica

by "winston19842005@[EMAIL PROTECTED] " <winston19842005@[EMAIL PROTECTED] > May 23, 2007 at 05:48 AM

On May 23, 6:42 am, HubbleBubble <phil_simm...@[EMAIL PROTECTED]
> wrote:
> Hi All,
>
> 1.
>  For my sins I sometimes convert C progs into pascal. Most of the time
> I manage OK but once in awhile I tangled up in knots. Here is one such
> instance. This is part of some memory management code to store images
> in ems blocks.
>
> Sometimes I'm envious of the apparent fluidity with which C treats
> memory but this is tempered by the fact its not always abundantly
> clear what it's up to. This is part of an emsAlloc function. In this
> snippet 'emsLinestart' was previously declared as a pointer (unsigned
> int *emsLinestart). Offset,page,size,lines and bytes are words.
> dosalloc returns a far pointer (that's normalised to you and me). So
> emslinestart appears to be a pointer to the block of memory just
> allocated by dosalloc but then it morphs into an array of words?
> pointers? which hold the page frames. Considering this is a dynamic
> structure allocated on call to the emsalloc how does this translate
> into pascal code?
>
>  if((emslinestart=(unsigned int *)dosalloc(4*lines) == NULL)return 0;
>
>  // Ok so above = quit value  if not allocated else a pointer to mem
>
>  for (i=0;i<lines;++i) {
>
>       emsLinestart[i<<l] = offset;  // huh? this is an array now ? are
> these pointers?
>       emsLinestart[(i<<l)+1] = page;
>       offset +=bytes;               // clear enough from here on
>       if((offset+bytes) > 0x4000 {
>             ++page;
>             offset := 0;
>        }
>

emsLinestart is just a pointer to integer - and C allows you to offset
from that address.  So, say a=i<<1, then the line above is the ADDRESS
of emsLinestart + a, an offset - this is perfectly legal in C, which
allows a lot of dangerous things.

How to do it in Pascal? Sorry, always been a little rusty in Pascal
when it came to pointers. I would've thought it would be trival...

What flavor of pascal are you using? I'd guess "Borland" because of
the newsgroup, but one shouldn't assume (Turbo/Borland). What version,
as well?

I'm still a UCSD fan...

Ben




 7 Posts in Topic:
Re: Some miscellaneous pascal esoterica
"winston19842005@[EM  2007-05-23 05:48:38 
Re: Some miscellaneous pascal esoterica
Marco van de Voort <ma  2007-05-24 21:20:06 
Re: Some miscellaneous pascal esoterica
"winston19842005@[EM  2007-05-24 15:37:18 
Re: Some miscellaneous pascal esoterica
Marco van de Voort <ma  2007-05-25 07:09:27 
Re: Some miscellaneous pascal esoterica
HubbleBubble <phil_sim  2007-05-25 04:37:09 
Re: Some miscellaneous pascal esoterica
Marco van de Voort <ma  2007-05-25 12:08:25 
Re: Some miscellaneous pascal esoterica
"winston19842005@[EM  2007-05-25 05:15:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Wed May 14 6:01:49 CDT 2008.