6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 5:09 pm

All times are UTC




Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Thu Feb 14, 2019 1:09 am 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
chitselb wrote:
on the OLPC wiki, there's NIP ( a b -- b ) and TUCK ( a b -- b a b ) and -ROT ( a b c -- c a b ) which I call LROT, but what is the word which has the stack diagram ( a b c -- b a c ) ? Is it UNDER?

I hope the name UNDER does not get confused with UNDER+ which has the stack effect ( a b c -- a+c b ). I don't remember where I saw UNDER+ , but I've found it useful and included it in Fleet Forth's kernel since day one.

Cheers,
Jim


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 14, 2019 4:47 am 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
barrym95838 wrote:
I would be tempted to name them bca, bac, cab, and cba, but I have a perverse affinity for three-letter mnemonics. :wink:

I was thinking the same thing.

Lisp actually does exactly this with CAR and CDR combinations.

Such that you have several things like:
Quote:
(CAAR x) == (CAR (CAR x))
(CADR x) == (CAR (CDR x))
(CDDR x) == (CDR (CDR x))
(CDAR x) == (CDR (CAR x))


I think many have all the combinations out to 5 letters (CAAAR).


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 14, 2019 6:49 am 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 277
whartung wrote:
barrym95838 wrote:
I would be tempted to name them bca, bac, cab, and cba, but I have a perverse affinity for three-letter mnemonics. :wink:

I was thinking the same thing.

Lisp actually does exactly this with CAR and CDR combinations.

Such that you have several things like:
Quote:
(CAAR x) == (CAR (CAR x))
(CADR x) == (CAR (CDR x))
(CDDR x) == (CDR (CDR x))
(CDAR x) == (CDR (CAR x))


I think many have all the combinations out to 5 letters (CAAAR).



Almost right - Common Lisp has up to 6 letters (i.e, sequences of A's and D's up to length 4). That makes up 2^1+2^2+2^3+2^4 = 30 of Common Lisp's set of 978 symbols.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 22, 2019 8:38 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
chitselb wrote:
FLIP ( a b c -- b a c )
FLOP ( a b c -- c b a )

I'm going to call them FLIP and FLOP for now, until I find out what the names are supposed to be.

The word you are calling FLOP is called NUTATE in Leo Brodie's book "Thinking Forth". I think it was just in the context of an example though.


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 22, 2019 8:50 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
theGSman wrote:
programandala.net wrote:
I don't think it would be practical, even feasible. There are many different stack operations you can do, and most of them can be defined using others. The standard operations have names related to their functions, because the functions are simple.

I think that what chitselb means is that every stack manipulation should have a name, not that every conceivable stack manipulation (no matter how rarely used) should be implemented in a Forth system. It is a simple matter to write a CODE word for any manipulation that isn't in your Forth system but is likely to be used a lot in a program. I have often found 2PICK to be such a word.

Yes and your favorites could be kept available in source form.
Quote:
programandala.net wrote:
That's the problem I just mentioned. It would be hard to remember not only which one is `flop` and which one is `flip`, but also what they actually do!
for "flop" I would probably use ROTSWAP if I needed the word or SWAPUNDER if the former name was not descriptive enough.
"flip" would probably sound better as 3REVERSE. (I hope I didn't get "flip" and "flop" mixed up. :mrgreen: )

I believe FLIP is ROT SWAP , and I agree, ROTSWAP is a better name. It has the virtue of telling what it does just like DUP>R takes the place of DUP >R .


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 01, 2020 10:34 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
theGSman wrote:
I have often found 2PICK to be such a word.


Is that equivalent to the phrase 2 PICK or is it a double number version of PICK ?


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 01, 2020 10:53 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
JimBoyd wrote:
theGSman wrote:
I have often found 2PICK to be such a word.

Is that equivalent to the phrase 2 PICK or is it a double number version of PICK ?

I have 2_PICK and DPICK.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 01, 2020 11:04 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
Dr Jefyll wrote:
Mike, the TLM's you propose are valid hex numbers. Could get (a little too) interesting... :)

It should be fine in Forth since the dictionary is searched first, and #INT is only called if something wasn't found in the dictionary, to see if it's a valid number in the current base. So for example FACE, BAD, FEED, DEAD, ADD, and other such names, if defined, would never be confused for a hex number either.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 01, 2020 11:05 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851
Sadly, the Commodore 64 lacks the underscore character.


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 01, 2020 11:11 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851

I realize I could go with something like 2.PICK but a name with a dot in it ( if it's not used for numeric output ) seems more appropriate for SamCoVT's idea of organizing constant names around what they go to.


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 01, 2020 11:13 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
JimBoyd wrote:
Sadly, the Commodore 64 lacks the underscore character.

Early Forths used the hyphen for that function, and it has carried into modern Forths too. I think the underscore character works better though. For characters that aren't on the keyboard, many systems offer easy ways to type them in. When I'm in my MultiEdit editor, I hold <Alt> while typing the three-digit decimal DOS/ANSI [Edit: that should say IBM437] character number, like 248 for the ° symbol or 241 for the ± symbol. The ones I use most often I remember; but <Alt>A (for "ASCII," even though real ASCII ends at 127) brings up the chart for when I don't remember the number.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2020 8:35 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851

Not only is the underscore character not on the C64 keyboard, it is not even in the PETSCII character set.
I like the idea of 2PICK being syntactically equivalent to 2 PICK while DPICK is the double number version of PICK .


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2020 9:13 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 851

I just checked the documentation for Mosaic Forth versions 4.0 and 4.2 .
The stack effect for DPICK is this.
DPICK ( d wn-1 . . . w1 w0 +n -- d wn-1 . . . w1 w0 d )
The documentation states that it copies the double number whose most significant cell is nth item on the data stack ( 0-based not including n) to the top of the stack.
0 DPICK is equivalent to 2DUP
2 DPICK is equivalent to 2OVER
1 DPICK will copy a double number that is just below a single number
( d w -- d w d )


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2020 9:23 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
JimBoyd wrote:
Not only is the underscore character not on the C64 keyboard, it is not even in the PETSCII character set.

Does the ROM get copied to RAM, such that you can alter the character set? My HP-71 lets you load in different character sets, telling it what dots to turn on for each; so although it comes with the ROMAN-8 set as standard, I did the DOS/ANSI [Edit: that should say IBM437] set since I now always use Epson dot-matrix printers with it.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 06, 2020 10:04 am 
Offline
User avatar

Joined: Tue Aug 14, 2012 12:47 pm
Posts: 18
Location: Austria - Vienna
GARTHWILSON wrote:
JimBoyd wrote:
Not only is the underscore character not on the C64 keyboard, it is not even in the PETSCII character set.

Does the ROM get copied to RAM, such that you can alter the character set? My HP-71 lets you load in different character sets, telling it what dots to turn on for each; so although it comes with the ROMAN-8 set as standard, I did the DOS/ANSI set since I now always use Epson dot-matrix printers with it.

Code 95 of "_" is the left arrow character on a C64 (PETSCII-Code). It doesn't look nice, but the character is displayed and can be typed in.
Someone might redefine this character to a "_" to get the "real" feeling.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: