PDA

View Full Version : mistake in IsoPod manual


danny
04-19-03, 03:45 PM
In the IsoPod manual, the example for describing how to use &ltBUILD DOES&gt to re-create the word VARIABLE is incorrect.
This has caused me quite a bit of hair loss.


: VARIABLE
&ltBUILDS Defines a new Forth word, header and empty body;
HERE gets the address in Data space (HERE) and appends that to Program space;
0 , appends a zero cell to Data space.<br>
DOES&gt The "run-time" action will start with the Program address on the stack;
P@ fetch the cell stored at that address (a pointer to Data) and return that.
;


: VARIABLE &ltBUILDS HERE 0 , DOES&gt P@ ; / This is incorrect
: VARIABLE &ltBUILDS HERE P, 0 , DOES&gt P@ ; / I believe this is how it should be

nmitech
04-20-03, 06:52 PM
Danny,

It must be a typo in the IsoPod manual. You are correct. Sorry for the confusion. We will fix this error soon.

CIM
04-21-03, 08:47 AM
I believe it should be
: VARIABLE <BUILDS HERE 0 P, DOES> P@ ;

nmitech
04-21-03, 02:29 PM
Danny is correct! It should be

: VARIABLE &#60BUILDS HERE P, 0 , DOES&#62 P@ ;

CIM
04-22-03, 08:44 AM
Sorry, the Cut and Paste didn't work on my last post.
My question was why it's not the same format than RAM access? like:
Create Buftest 0 , FFFF , 9ABC , etc..
In Program Ram it's not
Create Buftest 0 P, FFFF P, 9ABC P, ... ??

I was thinking that a word creating variables in Program Ram looks like
: VARIABLE /BUILDS PHERE 0 P, DOES\ P@ ;

Is the IsoMax's words definition ready?

nmitech
04-22-03, 11:19 AM
Is the IsoMax's words definition ready?
You can find them on the download page, http://www.newmicros.com/store/product_details/download.html
Look under IsoMax & Max-FORTH section for I/O glossary, I/O methods, IsoMax Timing, Loop Index, etc...
These files are documented the IsoMax words with explanations.


My question was why it's not the same format than RAM access? like:
Create Buftest 0 , FFFF , 9ABC , etc..
In Program Ram it's not
Create Buftest 0 P, FFFF P, 9ABC P, ... ??

I was thinking that a word creating variables in Program Ram looks like
: VARIABLE /BUILDS PHERE 0 P, DOES\ P@ ;



Here's the deal. CREATE builds a data structure in Program ROM. The word defined by CREATE will return an address in Program ROM. P, appends a cell to Program ROM. So actually,

CREATE BUFTEST 0 P, FFFF P, 9ABC P,

will work correctly. You can try this and do BUFTEST 3 PDUMP to see the result.

But CREATE doesn't give you a Data RAM address, so if you want to build a structure in RAM you have to *explicitly* remember the Data RAM address. Usually this is done by store the Data RAM address in Program
ROM, as follows:

CREATE BUFTEST HERE P,

You can then proceed to append values to Data RAM with , as follows:

CREATE BUFTEST HERE P, 0 , FFFF , 9ABC ,

Now you have to use BUFTEST P@ to get the RAM address. You can see the result in RAM with BUFTEST P@ 3 DUMP

You can in theory create variables in Program RAM, but you must remember that none of the usual Forth memory operators (@ ! +! etc.) can read and
write those variables. Only P@ and P! can access Program RAM. Program RAM is tight, and Data RAM is much more plentiful, so why not put the variables in Data RAM?

CIM
04-22-03, 12:01 PM
Thanks for the info!

Why not using only data ram?
Because program ram not used when program running and i think it's the best place for communication buffers. Have suggestions?