danwinslow Posted April 25, 2006 Share Posted April 25, 2006 In the following lines of Forth : 0500 VARIABLE SET-ADDRESS 01 C, 0000 , 0000 , 00 C, I'm not really sure whats going on. Is the 0500 that precedes the VARIABLE some kind of address specification, or an initial value perhaps? Also, what are the commas doing...I am guessing that this lays out a block of memory named SET-ADDRESS, whose first word is initialized to 0500, is followed by an ( un-named ) byte (c=character?), followed by a word, followed by another word, followed by a byte, for a total length of 8. Am I close? Quote Link to comment Share on other sites More sharing options...
cas Posted April 25, 2006 Share Posted April 25, 2006 In the following lines of Forth : 0500 VARIABLE SET-ADDRESS 01 C, 0000 , 0000 , 00 C, I'm not really sure whats going on. Is the 0500 that precedes the VARIABLE some kind of address specification, or an initial value perhaps? Also, what are the commas doing...I am guessing that this lays out a block of memory named SET-ADDRESS, whose first word is initialized to 0500, is followed by an ( un-named ) byte (c=character?), followed by a word, followed by another word, followed by a byte, for a total length of 8. Am I close? Yes you are close. The (Fig-)Forth Word VARIABLE takes a 16bit value from the stack (the $0500, as we are in Base 16), creates a new WORD called "SET-ADDRESS", reserves 2 Byte (16 bit) in the Forth Dictionary and stores the 16bit value in the two byte. The new Word "SET-ADDRESS" will put the Address of the reserved 2 bytes on the stack when executed. So we can retrieve the value of the variable with SET-ADDRESS @ where "@" is the forth word to read 16bit value at an address suplied on the stack. The "," and "C," words store a 16bit or 8bit value in the dictionary, in this case just behind the 2 bytes named with the word SET-ADDRESS. This is an easy was to build up any kind of data structure. Print the Address if SET-ADDRESS and examine the memory there SET-ADDRESS . will give you the memory location of the variable "SET-ADDRESS", which is the starting point for the datastructure containing the USB Packet to set the USB Address to an USB Device. In F83 or ANSI Forth (like VolksForth) the same would be CREATE SET-ADDRESS 0500 , 01 C, 0000 , 0000 , 00 C, Carsten Quote Link to comment Share on other sites More sharing options...
cas Posted April 25, 2006 Share Posted April 25, 2006 The Jupiter ACE Resource Site has PDF User Manuals for the Jupter ACE Forth and a book on converting BASIC Programs to Forth. http://jupiter-ace.co.uk/usermanual.html Carsten Quote Link to comment Share on other sites More sharing options...
danwinslow Posted April 25, 2006 Author Share Posted April 25, 2006 Thanks Cas Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.