Hi,
On 03/02/2013 06:22 AM, Enoch wrote:
> Hello Matthias& all,
>
> Regarding .S
>
> Indeed, says Forth 2012 RC1, "the format of the display is
> implementation-dependent".
>
> However, doesn't GFORTH display order make a better sense:
>
> 1 2 3 .s<3> 1 2 3 ok
>
> While ours:
>
>> 1 2 3 .s
> 3 2 1 ok
>
One of the great things on Forth imho is that you can make
the system do, what your eyes please. So a few variations
on " .s " :
\ variations on dot-s
\ dot-s, one way, signed output:
: ds sp@ sp0 1 cells - do i @ . -2 +loop ;
\ dot-s, one way, unsigned output:
: uds sp@ sp0 1 cells - do i @ u. -2 +loop ;
\ dot-s, the other way (reverse?), signed output:
: rs sp@ sp0 swap do i @ . 2 +loop ;
\ dot-s, the other way, unsigned output:
: urs sp@ sp0 swap do i @ u. 2 +loop ;
\ dot-s, verbose, as it used to be in earlier versions of amforth:
: dsv depth dup 0 do i u. dup i - cells sp0 swap - dup u. @ . cr loop ;
: udsv depth dup 0 do i u. dup i - cells sp0 swap - dup u. @ u. cr loop ;
And watch the show:
|> .s
|65530 5 4 3 2 1 ok
|> ds
|1 2 3 4 5 -6 ok
|> uds
|1 2 3 4 5 65530 ok
|> hex uds
|1 2 3 4 5 FFFA ok
|> rs
|-6 5 4 3 2 1 ok
|> urs
|65530 5 4 3 2 1 ok
|> dsv
|0 1539 -6
|1 1541 5
|2 1543 4
|3 1545 3
|4 1547 2
|5 1549 1
| ok
|>
Just never assume that your preferred solution solves the same
problem for everyone else. I read words/depth.asm for enlightenment,
and I chose the above without using pick, because pick needs to be
added to the dictionary. Obviously there is more than one way to
do this. You may *want* error checking. I don't. If I do a mistake,
well I excuse the system for crashing.
Cheers,
Erich
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel