Path: utzoo!utgpu!watmath!att!ucbvax!SCFVM.BITNET!ZMLEB From: ZMLEB@SCFVM.BITNET (Lee Brotzman) Newsgroups: comp.lang.forth Subject: Re: CELLSIZE Message-ID: <8908091433.AA17740@jade.berkeley.edu> Date: 9 Aug 89 14:06:41 GMT References:Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 42 > >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.