home *** CD-ROM | disk | FTP | other *** search
- \ Lesson 6 Part 8 ( F-PC 3.5 Tutorial by Jack Brown )
-
- \ A re-definition of Forths Number Display Operators using
- \ our modified output formatting words which will allow us
- \ to watch their normally transparent operation by setting
- \ S&PAD ON .
-
- \ Convert an unsigned 16 bit number to a string.
- : (U.) ( un -- addr len )
- 0 <# #S #> ;
-
- \ Output as an unsigned single number with trailing space.
- : U. ( un -- )
- (U.) ( addr len ) TYPE SPACE ;
-
- \ Output as an unsigned single number right justified in a field
- \ w wide.
- : U.R ( un w -- )
- >R (U.) ( addr len ) \ save w and convert.
- R> OVER - ( addr len count ) \ count = # of leading spaces
- SPACES TYPE ;
-
- \ Convert a signed 16 bit number to a string.
- : (.) ( n -- addr len )
- DUP ABS 0
- <# #S ROT SIGN #> ;
-
- \ Output as a signed single number with a trailing space.
- : . ( n -- )
- (.) TYPE SPACE ;
-
- \ .R Output as a signed single number right justified.
- : .R ( n w -- )
- >R (.) ( addr len ) \ save w and convert
- R> OVER - ( addr len count ) \ count = # of leading spaces
- SPACES TYPE ;
-
- \ Convert an unsigned double number to a string.
- : (UD.) ( ud -- addr len )
- <# #S #> ;
-
- \ Output as unsigned double number with a trailing space
- : UD. ( ud -- )
- (UD.) ( addr len ) TYPE SPACE ;
-
- \ Output as an unsigned double number right justified in
- \ a field w wide.
- : UD.R ( ud w -- )
- >R (UD.) ( addr len )
- R> OVER - ( addr len count )
- SPACES TYPE ;
-
- \ Convert a signed double number to a string.
- : (D.) ( dn -- addr len )
- TUCK DABS ( sign |dn| )
- <# #S ROT SIGN #> ( addr len ) ;
-
- \ Output as a signed double number with a trailing space.
- : D. ( dn -- )
- (D.) ( addr len ) TYPE SPACE ;
-
- \ Output as a signed double number right justified
- \ in a field w wide.
- : D.R ( dn w -- )
- >R (D.) ( addr len )
- R> OVER - ( addr len count )
- SPACES TYPE ;
-
- ( Please Move to Lesson 6 Part 9 )
-
-