Diff for /gforth/doc/gforth.ds between versions 1.49 and 1.50

version 1.49, 2000/05/15 14:04:11 version 1.50, 2000/05/20 08:40:48
Line 2436  there (thus its name).  Programmers can Line 2436  there (thus its name).  Programmers can
 : foo ( n1 n2 -- )  : foo ( n1 n2 -- )
  .s   .s
  >r .s   >r .s
  r@ .   r@@ .
  >r .s   >r .s
  r@ .   r@@ .
  r> .   r> .
  r@ .   r@@ .
  r> . ;   r> . ;
 1 2 foo  1 2 foo
 @end example  @end example
Line 2501  stack into memory: Line 2501  stack into memory:
 @example  @example
 v .  v .
 5 v ! .s  5 v ! .s
 v @ .  v @@ .
 @end example  @end example
   
 You can also reserve more memory:  You can also reserve more memory:
Line 2523  You can reserve and initialize memory wi Line 2523  You can reserve and initialize memory wi
 @example  @example
 create v3  create v3
   5 , 4 , 3 , 2 , 1 ,    5 , 4 , 3 , 2 , 1 ,
 v3 @ .  v3 @@ .
 v3 cell+ @ .  v3 cell+ @@ .
 v3 2 cells + @ .  v3 2 cells + @@ .
 @end example  @end example
   
 @assignment  @assignment
Line 2585  require their own words for memory acces Line 2585  require their own words for memory acces
 @example  @example
 create v4   create v4 
   104 c, 97 c, 108 c, 108 c, 111 c,    104 c, 97 c, 108 c, 108 c, 111 c,
 v4 4 chars + c@ .  v4 4 chars + c@@ .
 @end example  @end example
   
 The preferred representation of strings on the stack is @code{addr  The preferred representation of strings on the stack is @code{addr
Line 2651  create an address that is not cell-align Line 2651  create an address that is not cell-align
 a-addr )} produces the next aligned address:  a-addr )} produces the next aligned address:
   
 @example  @example
 v3 char+ aligned .s @ .  v3 char+ aligned .s @@ .
 v3 char+ .s @ .  v3 char+ .s @@ .
 @end example  @end example
   
 Similarly, @code{align} advances @code{here} to the next aligned  Similarly, @code{align} advances @code{here} to the next aligned
Line 2763  passing through the stack makes it a lit Line 2763  passing through the stack makes it a lit
   
 @example  @example
 : map-array ( ... addr u xt -- ... )  : map-array ( ... addr u xt -- ... )
 \ führt xt ( ... x -- ... ) für jedes Element des Arrays aus,  \ executes xt ( ... x -- ... ) for every element of the array starting
 \ das bei addr beginnt und u Elemente enthält  \ at addr and containing u elements
   @{ xt @}    @{ xt @}
   cells over + swap ?do    cells over + swap ?do
     i @ xt execute      i @@ xt execute
   1 cells +loop ;    1 cells +loop ;
   
 create a 3 , 4 , 2 , -1 , 4 ,  create a 3 , 4 , 2 , -1 , 4 ,
Line 2950  other than just producing their address: Line 2950  other than just producing their address:
 : constant ( n "name" -- )  : constant ( n "name" -- )
   create ,    create ,
 does> ( -- n )  does> ( -- n )
   ( addr ) @ ;    ( addr ) @@ ;
   
 5 constant foo  5 constant foo
 foo .  foo .
Line 2992  you can define a definition word Line 2992  you can define a definition word
 : simple-field ( n "name" -- )  : simple-field ( n "name" -- )
   create ,    create ,
 does> ( n1 -- n1+n )  does> ( n1 -- n1+n )
   ( addr ) @ + ;    ( addr ) @@ + ;
 @end example  @end example
   
 Definition and use of field offsets now look like this:  Definition and use of field offsets now look like this:
Line 3010  with @code{>body ( xt -- addr )}: Line 3010  with @code{>body ( xt -- addr )}:
 : value ( n "name" -- )  : value ( n "name" -- )
   create ,    create ,
 does> ( -- n1 )  does> ( -- n1 )
   @ ;    @@ ;
 : to ( n "name" -- )  : to ( n "name" -- )
   ' >body ! ;    ' >body ! ;
   
Line 3171  and produce a word that contains the wor Line 3171  and produce a word that contains the wor
 \ array beginning at addr and containing u elements  \ array beginning at addr and containing u elements
   @{ xt @}    @{ xt @}
   POSTPONE cells POSTPONE over POSTPONE + POSTPONE swap POSTPONE ?do    POSTPONE cells POSTPONE over POSTPONE + POSTPONE swap POSTPONE ?do
     POSTPONE i POSTPONE @ xt compile,      POSTPONE i POSTPONE @@ xt compile,
   1 cells POSTPONE literal POSTPONE +loop ;    1 cells POSTPONE literal POSTPONE +loop ;
   
 : sum-array ( addr u -- n )  : sum-array ( addr u -- n )
Line 3186  example where the code is generated in a Line 3186  example where the code is generated in a
 @example  @example
 : compile-vmul-step ( compilation: n --; run-time: n1 addr1 -- n2 addr2 )  : compile-vmul-step ( compilation: n --; run-time: n1 addr1 -- n2 addr2 )
 \ n2=n1+(addr1)*n, addr2=addr1+cell  \ n2=n1+(addr1)*n, addr2=addr1+cell
   POSTPONE tuck POSTPONE @    POSTPONE tuck POSTPONE @@
   POSTPONE literal POSTPONE * POSTPONE +    POSTPONE literal POSTPONE * POSTPONE +
   POSTPONE swap POSTPONE cell+ ;    POSTPONE swap POSTPONE cell+ ;
   
Line 4891  variable jim abcd jim ! Line 4891  variable jim abcd jim !
 : foo + / - ;  : foo + / - ;
 ' fred 10 - 50 dump   ' fred 10 - 50 dump 
 ..80: 5C 46 0E 40  84 66 72 65 - 64 20 20 20  20 20 20 20  \F.@.fred         ..80: 5C 46 0E 40  84 66 72 65 - 64 20 20 20  20 20 20 20  \F.@.fred       
 ..90: D0 9B 04 08  00 00 00 00 - 56 34 12 00  80 46 0E 40  ........V4...F.@  ..90: D0 9B 04 08  00 00 00 00 - 56 34 12 00  80 46 0E 40  ........V4...F.@@
 ..A0: 83 6A 69 6D  20 20 20 20 - D0 9B 04 08  00 00 00 00  .jim    ........  ..A0: 83 6A 69 6D  20 20 20 20 - D0 9B 04 08  00 00 00 00  .jim    ........
 ..B0: CD AB 00 00  9C 46 0E 40 - 83 66 6F 6F  20 20 20 20  .....F.@.foo      ..B0: CD AB 00 00  9C 46 0E 40 - 83 66 6F 6F  20 20 20 20  .....F.@.foo    
 ..C0: 80 9B 04 08  00 00 00 00 - E4 2E 05 08  0C 2F 05 08  ............./..  ..C0: 80 9B 04 08  00 00 00 00 - E4 2E 05 08  0C 2F 05 08  ............./..

Removed from v.1.49  
changed lines
  Added in v.1.50


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>