Newsgroups: comp.lang.forth
Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!geac!maccs!innovus!rob
From: rob@innovus.uucp (Rob Sciuk)
Subject: Re: Align
Message-ID: <1991Jun19.144735.24720@innovus.uucp>
Organization: Innovus Inc.
References: <9106190432.AA02430@ucbvax.Berkeley.EDU>
Date: Wed, 19 Jun 91 14:47:35 GMT

In article <9106190432.AA02430@ucbvax.Berkeley.EDU> UNBCIC%BRFAPESP.BITNET@SCFVM.GSFC.NASA.GOV writes:
>Sorry for the garbage... Anyway,
>
>=> Date: Mon, 17 Jun 91 19:37:47 GMT
>=> From: Rob Sciuk
>=>  <news-server.csri.toronto.edu!torsqnt!geac!maccs!innovus!rob@UUNET.UU.NET>
>=> Subject: RE: Memory Management/PIC
>=> Elizabeth points out that any standard defining word should take care
>=> to align words, (bodies, headers, and fields contained therein) on
>=> appropriate boundaries.  Further, `ALLOT' and `,' should align on
>=> CELL boundaries, and `C,' should ensure that the next invocation of
>=> `HERE', `ALLOT', `,' etc. will utilize a CELL boundary appropriate
>=> to the processor [mine].
>
>C, should ensure that the next invocation of HERE, ALLOT... will utilize a CELL
>boundary?!?!?!?!??!?!?!? It's better live with a slow @ and ! than with this!
>We have only two options: 1) Throw an overhead upon HERE, ALLOT...; 2) Make C,
>ALLOT a CELL, thus actings a comma.

I think you misunderstood my point ... C, in my example works entirely as
advertised, and allots in 1 byte increments HOWEVER, if a C, leaves HERE at an
unaligned address, the HERE pointer is advanced to the next aligned address.
The next invocation of ALLOT, HERE etc, will return the padded and aligned 
address, but the next C, will assign BEHIND HERE giving a CHERE :-)if you will.
I feel no need to actually provide CHERE, and entirely hide the semantic detail
in the implementation of C,.

	---> Direction of Growth
	{[*][*][ ][ ]}{[ ][ ][ ][ ]}{[ ][ ][ ][ ]}{[ ][ ][ ][ ]}
		^       ^
		CHERE   HERE

>
>Another thing, if ALLOT and HERE return always an aligned address, it's better
>make this very clear in the standard, or Structure Wordsets (wich are very

Agreed. This should occur!  I implore the standards committee to do so!
(in fact, I may make written application in the near term)

>commom) will be source of lots of errors. I wouldn't like an ALLOT that
>aligns, but, then, you can never satisfy everyone.

In my example, ALLOT doesn't align, `C,' does.

Alignment is not just a good idea on most RISC processors, it is the law!
The cost of alignment on byte oriented machines is, IMHO, negligible.
Further, inclusion of the alignment semantics within the standard would aid 
portability immeasurably.  Granted, this may be unacceptable in some embedded
systems(?), but this can be overcome with words such as CALLOT, and CHERE with 
the obvious implied semantics (remember this is Forth we are dealing with!).

By the way, this is something that I had to retrofit into my implementation
because I was dumping core on Unix systems with what I believed to be standard
(Forth-83) programs.  My implementations will continue to behave this way 
whether the standard includes this or not because I have been burned.
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Rob Sciuk	rob@innovus.com OR rob@innovus.on.ca
Innovus Inc.	204-200 James St S. Hamilton, Ont. 	Phone:	(416) 529-8117 
		{not a flame ... merely a glimmer ...}	Fax:	(416) 572-9586	
