Marco van de Voort
marcov at stack.nl
Sun Feb 23 19:28:36 CET 2003
[ Charset ISO-8859-1 unsupported, converting... ]
> Hi, James!
> On Sunday 23 February 2003 18:44, you wrote:
> > This is from an old Turbo Pascal source of the Pascal S compiler source:
> > getmem(spnt,((sleng+3) div 16 +1)*16);
> > k := seg(spnt^);
> > memw[k:0] := sleng;
> > memw[k:2] := 0;
> > move(sbuff,mem[k:4],sleng);
> > How would you convert that into FPC syntax for linux ?
> just a first approach by heart - i neither tested it, nor did i check the
> syntax. if you need explanation or testing, i can do that. but maybe it works
> at once:
> p_words = ^ t_words;
> t_words = array [0 .. maxint] of word;
> spnt: p_words;
> getmem(spnt,((sleng+3) div 16 +1)*16);
> ? spnt ^  := sleng;
> ? spnt ^  := 0;
> ? move(sbuff, @(spnt ^ ),sleng);
This is correct. I think, but probably the size passed to getmem is also
special. All the calculation is only to make sure that memory is allocated in
pieces of 16 bytes. (a segment), but that doesn't matter much anymore.
So that probably can change to simple
if that is the size needed.
Better, the entire stuff could simply change to use a pointer to an array of
record (with two fields in it). It might be a workaround to TP's 64k limit
that FPC doesn't have. (or do you heapalloc for that?)
Also be careful with this kind of code if it stores pointers, because
pointers are 32-bit now!
More information about the fpc-pascal