marc@noe.UUCP (Marc de Groot) (08/03/89)
I would like to propose the inclusion of the word CELLSIZE in new Forth interpreters. CELLSIZE ( --- n ) Leaves the number of 8-bit bytes per cell. Returns 2 for a 16-bit Forth and 4 for a 32-bit Forth. How can I get this idea to the ANSI committee? P. S. Why do I keep typing "Froth"? Is it because I am rabid? ;-) -- Marc de Groot (KG6KF) These ARE my employer's opinions! Noe Systems, San Francisco UUCP: uunet!hoptoad!noe!marc Internet: marc@kg6kf.AMPR.ORG
olorin@walt.cc.utexas.edu (Dave Weinstein) (08/06/89)
In article <664@noe.UUCP> marc@noe.UUCP (Marc de Groot) writes: >I would like to propose the inclusion of the word CELLSIZE in new >Forth interpreters. > >CELLSIZE ( --- n ) >Leaves the number of 8-bit bytes per cell. Returns 2 for a 16-bit >Forth and 4 for a 32-bit Forth. The words UNIT ( -- n ), which leaves the size in bits of the smallest object the processor can directly address, and CELL ( -- n) which leaves the size in units of the stack cell, were proposed on GEnie, and I believe they have been forwarded to the ANSI standardization team. --Dave -- Dave Weinstein olorin@walt.cc.utexas.edu (512) 339-4407 Home GEnie: DHWEINSTEIN I am not responsible for the opinions of my employers.
andrew@idacom.UUCP (Andrew Scott) (08/09/89)
In article <664@noe.UUCP>, marc@noe.UUCP (Marc de Groot) writes: > CELLSIZE ( --- n ) > Leaves the number of 8-bit bytes per cell. Returns 2 for a 16-bit > Forth and 4 for a 32-bit Forth. > > How can I get this idea to the ANSI committee? They already know about it. The latest proposed word set I've seen has the following as part of the required word set: CELLS ( n1 -- n2 ) Return the size, in address units, of n1 cells. CELL+ ( a1 -- a2 ) Add the size of a cell, specified in address units, to a1 giving a2. With this, CELLSIZE becomes 1 CELLS. I assume that an "address unit" is a byte. -- Andrew Scott andrew@idacom - or - {att, watmath, ubc-cs}!alberta!idacom!andrew
ZMLEB@SCFVM.BITNET (Lee Brotzman) (08/09/89)
> >CELLS ( n1 -- n2 ) > Return the size, in address units, of n1 cells. > >CELL+ ( a1 -- a2 ) > Add the size of a cell, specified in address units, to a1 giving a2. > >With this, CELLSIZE becomes 1 CELLS. > >I assume that an "address unit" is a byte. >-- >Andrew Scott andrew@idacom > - or - {att, watmath, ubc-cs}!alberta!idacom!andrew An "address unit" is the smallest addressable piece of information on the given computer. For a VAX or a PC, it is 8 bits. For the Novix chips, which are word-addressable, it is 16-bits. Therefore, on a PC running a 16-bit Forth (i.e. the width of a single stack element, aka CELL, is 16-bits), CELLS returns 2. On a VAX running 32-bit Forth, CELLS returns 4. On a NOVIX, CELLS returns 1, meaning that one cell occupies 1 address unit. CELLS and CELL+ are an attempt to give Forth the "address arithmetic" found in C. Something quite like them is found in just about any flavor or Forth that runs on several different machines. For instance, Uniforth has the words ES (for "element size") and ES+ which are exactly like CELLS and CELL+ . Having written code for both 16-bit and 32-bit systems, I have found that the only source of portability problems caused by the differing stack widths is trying to step my way through an array in a loop. On a 16-bit system I would want to add 2 to the base address each iteration; on a 32-bit system I would add 4. Using CELL+ makes the problem go away. Now I wonder, is there an equivalent set of words for floating point? Floating point numbers on BOTH 16-bit and 32-bit systems are 32-bits wide. The standard extension for floating point should include FCELLS and FCELL+ in order to maintain compatibility between systems. -- Lee Brotzman (FIGI-L Moderator) -- BITNET: ZMLEB@SCFVM -- Internet: zmleb@scfvm.gsfc.nasa.gov -- The government and my company don't know what I'm saying. -- Let's keep it that way.
rvp@cbnewsh.ATT.COM (rob.v.phillips) (08/10/89)
The CELLSIZE word seems somewhat useful, in that we get a solid number, but it introduces a new dimension (address units). Isn't it safe to say most programmers know or can easily find out what a "bit" is? So, should the FORTH standard have a word that tells the size of an address unit, in "bits"? It seems to make sense to me. Rob Phillips homxc!rvp