From: Enoch <ix...@ho...> - 2013-03-02 05:23:15
|
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 Thanks, Enoch. |
From: Matthias T. <mt...@we...> - 2013-03-02 08:56:06
|
Hi Enoch, > 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: In which way: by adding the stack depth or the ordering? > > 1 2 3 .s <3> 1 2 3 ok > > While ours: > >> 1 2 3 .s > 3 2 1 ok I agree that amforth's display looks confusing at the first glance. Expecting a but? yes: I read from left to right (as probably many others do too) and I expect the TOS to read first. Gforth's display confuses me. I always have to scan the entire line to get the information I want. Basically the built-in .s is a debugging aid for the core development. I use it rather often when I dig in internals. A more user friendly .s is better implemented as forth code, DEPTH and PICK are available (I think they are useful for that task). Matthias |
From: Enoch <ix...@ho...> - 2013-03-02 15:03:37
|
Matthias Trute <mt...@we...> writes: > Hi Enoch, > >> 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: > > In which way: by adding the stack depth or the ordering? > >> >> 1 2 3 .s <3> 1 2 3 ok >> >> While ours: >> >>> 1 2 3 .s >> 3 2 1 ok > > I agree that amforth's display looks confusing at the > first glance. Expecting a but? yes: I read from left to right > (as probably many others do too) and I expect the TOS to read > first. > > Gforth's display confuses me. I always have to scan the entire > line to get the information I want. > > Basically the built-in .s is a debugging aid for the > core development. I use it rather often when I dig in > internals. A more user friendly .s is better implemented > as forth code, DEPTH and PICK are available (I think they > are useful for that task). Hello Matthias, IMHO .s should follow Leo Brodie's "Stack Picture" comment convention (Thinking Forth pg. 151) as we are so accustomed to it. As developers we can reverse .s order in our mind but it is an unnecessary burden on our slow brain (called "System 2" in Daniel Khaneman's book, Thinking, Fast and Slow) which is supposed to be focusing on bugs. And if I have your ear :-) I prefer (gforth): -1 -2 -3 .s <3> -1 -2 -3 ok over (amforth): -1 -2 -3 .s 65533 65534 65535 ok i.e., the regular numbers' format. Thanks, Enoch. > > Matthias > > ------------------------------------------------------------------------------ > 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 |
From: Matthias T. <mt...@we...> - 2013-03-02 18:12:35
|
Hi Enoch, > And if I have your ear :-) You'll (almost) always have it. ;) > I prefer (gforth): -1 -2 -3 .s <3> -1 -2 -3 ok > over (amforth): -1 -2 -3 .s 65533 65534 65535 ok > i.e., the regular numbers' format. Thats fine. Just remove the line in your application dict_appl.inc file and add your version of .S The reason why I use the u. instead of the "standard" . is simple: Just switch to HEX. There you have the same numbers that can be grepped in the LST and MAP files from the assembler and match the numbers in the DUMP output (mostly XT's and addresses). As I said: .s is a debugging aid for _my_ core development. I do not expect that it is unmodified useful for other purposes. Should I mention, that I collect good tools and ideas? ;) Matthias |
From: Enoch <ix...@ho...> - 2013-03-02 20:28:24
|
Matthias Trute <mt...@we...> writes: > Hi Enoch, > >> And if I have your ear :-) > > You'll (almost) always have it. ;) > >> I prefer (gforth): -1 -2 -3 .s <3> -1 -2 -3 ok >> over (amforth): -1 -2 -3 .s 65533 65534 65535 ok >> i.e., the regular numbers' format. > > Thats fine. Just remove the line in your application > dict_appl.inc file and add your version of .S > > The reason why I use the u. instead of the "standard" . > is simple: Just switch to HEX. There you have > the same numbers that can be grepped in the LST and > MAP files from the assembler and match the numbers > in the DUMP output (mostly XT's and addresses). > As I said: .s is a debugging aid for _my_ core > development. I do not expect that it is unmodified > useful for other purposes. > > Should I mention, that I collect good tools and ideas? ;) As recommended, removed words/dot-s.asm from dict_appl.inc and added: : .s ( -- ) \ stack picture listing order depth begin dup while dup pick . 1- repeat drop ; -1 -2 -3 .s -1 -2 -3 ok I hope that I'm not nagging -- got more challenges for you if you don't object ;-) Regards, Enoch. > > Matthias > > > ------------------------------------------------------------------------------ > 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 |
From: Michael K. <mi-...@t-...> - 2013-03-03 00:10:11
|
Hi. Am 02.03.2013 um 21:27 schrieb Enoch: > : .s ( -- ) \ stack picture listing order > depth > begin dup while dup pick . 1- repeat > drop > ; Maybe you want to have that in assembler. mk -------------- next part -------------- |
From: Matthias T. <mt...@we...> - 2013-03-03 12:37:49
|
Enoch, > I hope that I'm not nagging -- got more challenges for you if you don't > object ;-) You're welcome :) Matthias |
From: Michael K. <mi-...@t-...> - 2013-03-03 00:00:40
|
Hi. .. > Should I mention, that I collect good tools and ideas? ;) >> Here is the old form for your collection. It is "Stack UnderFlow" save, telling "SUF" if you do one. Maybe you have it already. Michael -------------- next part -------------- |
From: Enoch <ix...@ho...> - 2013-03-03 01:01:32
|
"Michael Kalus" <mi-...@t-...> writes: > Hi. > > Am 02.03.2013 um 21:27 schrieb Enoch: > >> : .s ( -- ) \ stack picture listing order >> depth >> begin dup while dup pick . 1- repeat >> drop >> ; > > Maybe you want to have that in assembler. mk Hello Michael, I believe that we should have things coded in asm only when there is a distinct advantage to it. During development I annotate my code with numerous "stack pictures" (aka program verification invariants) and some .s printouts (tracepoints) to confirm. I didn't understand why I have to read those printouts in reverse, but not any more :-) Regards, Enoch. > > > -------------- next part -------------- > > > ------------------------------------------------------------------------------ > 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 |
From: Erich W. <ew....@na...> - 2013-03-03 12:29:27
|
Michael, On 03/03/2013 01:00 AM, Michael Kalus wrote: > Here is the old form for your collection. It is "Stack UnderFlow" > save, telling "SUF" if you do one. > Maybe you have it already. Michael > > > -------------- next part -------------- If you, too, want me to look at your code, you better add it to the message text. At least I do not see an attachment. Erich |
From: Michael K. <mi-...@t-...> - 2013-03-03 16:32:52
|
Oh, sorry. Forgot that the list strips attachments. Michael ; Enochs .S VE_DOTS: .dw $FF02 .db ".s" .dw VE_HEAD .set VE_HEAD = VE_DOTS XT_DOTS: .dw DO_COLON PFA_DOTS: ; ( -- ) ; stack picture listing order .dw XT_DEPTH PFA_DOTS0: .dw XT_DUP .dw XT_DOCONDBRANCH .dw PFA_DOTS1 .dw XT_DUP .dw XT_PICK .dw XT_DOT .dw XT_1MINUS .dw XT_DOBRANCH .dw PFA_DOTS0 PFA_DOTS1: .dw XT_DROP .dw XT_EXIT ; old form giving index#, address and value of stack items. ; ( -- ) Tools ; R( -- ) ; stack dump VE_DOTSS: .dw $ff02 .db ".s" .dw VE_HEAD .set VE_HEAD = VE_DOTSS XT_DOTSS: .dw DO_COLON PFA_DOTSS: .dw XT_CR .dw XT_DEPTH, XT_1PLUS .dw XT_GREATERZERO .dw XT_DOCONDBRANCH .dw PFA_DOTSS0 ; <old.s> .dw XT_SP_FETCH .dw XT_DEPTH .dw XT_1MINUS .dw XT_ZERO .dw XT_DOQDO .dw PFA_DOTSS2 PFA_DOTSS1: .dw XT_SLITERAL .dw 2 .db "[]" .dw XT_ITYPE .dw XT_DUP .dw XT_I .dw XT_DUP .dw XT_UDOT ; index of cell .dw XT_2STAR .dw XT_PLUS .dw XT_DUP .dw XT_DOLITERAL .dw 4 .dw XT_UZERODOTR ; address of cell .dw XT_DOLITERAL .dw 0x3A .dw XT_EMIT, XT_SPACE .dw XT_FETCH .dw XT_UDOT ; content of cell .dw XT_CR .dw XT_DOLOOP .dw PFA_DOTSS1 PFA_DOTSS2: .dw XT_DROP .dw XT_EXIT ; </old.s> PFA_DOTSS0: .dw XT_SLITERAL .dw 3 .db "suf",0 .dw XT_ITYPE .dw XT_EXIT Am 03.03.2013 um 13:17 schrieb Erich Waelde: > Michael, > > On 03/03/2013 01:00 AM, Michael Kalus wrote: > >> Here is the old form for your collection. It is "Stack UnderFlow" >> save, telling "SUF" if you do one. >> Maybe you have it already. Michael >> >> >> -------------- next part -------------- > > If you, too, want me to look at your code, you better > add it to the message text. At least I do not see > an attachment. > > 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/ > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel |
From: Erich W. <ew....@na...> - 2013-03-03 21:26:49
|
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 |
From: Enoch <ix...@ho...> - 2013-03-04 01:53:47
|
Hello Erich & all, The focus of my .s comment was on Matthias non standard stack listing order, not on the implementation. This decision, in my opinion, slows down a Forth trained programmer who is accustomed to maintaining the standard "stack picture" in his mind. If you wonder what is "System 1" / "System 2" that I referred to in my communication see http://en.wikipedia.org/wiki/Thinking,_Fast_and_Slow for a brief description. Regards, Enoch. Erich Waelde <ew....@na...> writes: > 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 |
From: Matthias T. <mt...@we...> - 2013-03-04 17:52:44
|
Hi, > Hello Erich & all, > > The focus of my .s comment was on Matthias non standard stack listing > order, Since there is no standard format, my variant cannot be non-standard. Thats impossible by definition. I updated http://amforth.sourceforge.net/TG/recipes/Dumps.html with Erich's examples. There should everyone find a solution that suits him/her. Matthias |
From: Enoch <ix...@ho...> - 2013-03-04 19:04:53
|
Matthias Trute <mt...@we...> writes: > Hi, > >> Hello Erich & all, >> >> The focus of my .s comment was on Matthias non standard stack listing >> order, > > Since there is no standard format, my variant cannot be non-standard. > Thats impossible by definition. > > I updated http://amforth.sourceforge.net/TG/recipes/Dumps.html > with Erich's examples. There should everyone find a solution > that suits him/her. I like your approach, holding up to your convictions while respecting other people opinions. Regards, Enoch. > > Matthias > > ------------------------------------------------------------------------------ > 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 |
From: Michael K. <mi-...@t-...> - 2013-03-05 18:47:51
|
Hi. Lets take a look at some common Forths, Revision appended. They do it in the typed order left to right. Only VFX does it top down linewise, like amforth in its older days. Though not a "standard", typed order is "Normative Kraft des Faktischen". (google: "normative power of the factual") Brodies I like best. Unfortunately he does not tell us how the negative numbers are treated. Regards, Michael :-) - Revision of Examples gforth: 11 -22 33 .s <3> 11 -22 33 ok win32forth: 11 -22 33 .s [3] 11 -22 33 ok... (with a dot for each item, none if empty stack) VFX Forth for Windows IA32: 11 -22 33 .s DATA STACK top 33 0000:0021 -22 FFFF:FFEA 11 0000:000B ok-3 SwiftX MSP430 EVALUATION 3.5.9 12-Apr-2011: 11 -22 33 .s 11 -22 33 <-Top ok And last but not least, the Masters Voice: Starting Forth by Leo Brodie - Chapter 2 http://www.forth.com/starting-forth/sf2/sf2.html <snip> A Handy Hint A Non-destructive Stack Print Beginners who are just learning to manipulate numbers on the stack in useful ways very often find themselves typing a series of dots to see what's on the stack after their manipulations. The problem with dots, though, is that they don't leave the numbers on the stack for future manipulation. The Forth word .S prints out all the values that happen to be on the stack "non-destructively"; that is, without removing them. Let's test it, first with nothing on the stack: .S <0> ok As you can see, in this version of .S, we see at least one number. This is the number of items actually on the stack. Now let's try with numbers on the stack: 1 2 3 .S <3> 1 2 3 ok ROT .S <3> 2 3 1 ok </snip> |
From: Enoch <ix...@ho...> - 2013-03-05 19:16:55
|
Hello Michael, Let's add one important case to your fine collection. Here is .s implementation in openfirmware/forth/kernel/kernel.fth: : (.s (s -- ) depth 0 ?do depth i - 1- pick n. loop ; : .s (s -- ) depth 0< if ." Stack Underflow " sp0 @ sp! else depth if (.s else ." Empty " then then ; Using the usual "stack picture" (of-course). Since only Matthias has commit rights, it's his call. I don't suggest to fork over this issue though :-) Regards, Enoch. "Michael Kalus" <mi-...@t-...> writes: > Hi. > Lets take a look at some common Forths, Revision appended. > They do it in the typed order left to right. > Only VFX does it top down linewise, like amforth in its older days. > Though not a "standard", typed order is "Normative Kraft des > Faktischen". > (google: "normative power of the factual") > > Brodies I like best. Unfortunately he does not tell us how the > negative numbers are treated. > > Regards, Michael > :-) > > - > Revision of Examples > > gforth: > 11 -22 33 .s <3> 11 -22 33 ok > > > win32forth: > 11 -22 33 .s [3] 11 -22 33 ok... > (with a dot for each item, none if empty stack) > > > VFX Forth for Windows IA32: > 11 -22 33 .s > DATA STACK > top > 33 0000:0021 > -22 FFFF:FFEA > 11 0000:000B > ok-3 > > > SwiftX MSP430 EVALUATION 3.5.9 12-Apr-2011: > 11 -22 33 .s > 11 -22 33 <-Top ok > > > And last but not least, the Masters Voice: > Starting Forth by Leo Brodie - Chapter 2 > http://www.forth.com/starting-forth/sf2/sf2.html > > <snip> > A Handy Hint > A Non-destructive Stack Print > > Beginners who are just learning to manipulate numbers on the stack in > useful ways very often find themselves typing a series of dots to see > what's on the stack after their manipulations. The problem with dots, > though, is that they don't leave the numbers on the stack for future > manipulation. > > The Forth word .S prints out all the values that happen to be on the > stack "non-destructively"; that is, without removing them. Let's test > it, first with nothing on the stack: > > .S <0> ok > > As you can see, in this version of .S, we see at least one number. > This is the number of items actually on the stack. > > Now let's try with numbers on the stack: > > 1 2 3 .S <3> 1 2 3 ok > > ROT .S <3> 2 3 1 ok > </snip> > > > ------------------------------------------------------------------------------ > 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 |