Subject: Re: Slightly off-topic: Anyone know OpenBoot cmds for PCI access
To: Steven Grunza <steven_grunza@ieee.org>
From: Thomas Pornin <pornin@bolet.org>
List: port-sparc
Date: 05/19/2004 09:07:08
On Tue, May 18, 2004 at 11:54:47AM -0400, Steven Grunza wrote:
> How do I read from a "pointer" in Forth?  In C I would simply do the 
> following:
> 
> volatile long unsigned int              *ptr;
> volatile long unsigned int              value;
> 
> ptr = (long unsigned int *) 0x114024;
> value = *ptr;
> 
> printf(" The value is %#x\n", value);

The Forth word for dereferencing is "@". Therefore, the following may
work:

hex 114024 @ u.

"hex" means: numeric constants shall henceforth be parsed in hexadecimal.
"114024" pushes the address on the stack.
"@" pops the address and pushes the value which lies at that address.
"u." pops a value, and prints it as an unsigned integer (in hexadecimal,
thanks to the previous "hex" word).

Forth operates on "cell" values: these are integer values whose size is
"natural" with regards to the host architecture. Usual sizes are 16, 32
and 64 bits. Most probably, this Forth works with 32-bit values. Try
the following:

hex 0 invert u.

it should print out FFFFFFFF or FFFFFFFFFFFFFFFF, if the cell size is,
respectively, 32 or 64 bits.


> How would I do something similar in Forth / OpenBoot prom? Thanks for
> any help. I'm working through some Forth primer's and tutorials but
> they don't seem to cover this situation.

The best Forth documentation I have seen so far is the one from Gforth:
http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/


	--Thomas Pornin