Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: What is the minimum Word set you could live with to have a (limping) Beginner's ANS Forth Date: Wed, 18 Mar 2015 22:21:43 -0400 Organization: Aioe.org NNTP Server Lines: 71 Message-ID: References: <09b0d52b-de4f-4805-9cc1-fc1cc0499ac3@googlegroups.com> <85lhiuioif.fsf@junk.nocrew.org> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:37421 On Wed, 18 Mar 2015 19:56:06 -0400, Alex McDonald wrote: > on 18/03/2015 22:42:31, "Rod Pemberton" wrote: >> On Wed, 18 Mar 2015 06:33:12 -0400, Lars Brinkhoff >> wrote: >>> JUERGEN wrote: >>>>> But for a project we would like to have a list of words that >>>>> fit into 4 bits - so 16 words max to be used. >>>>> Any good suggestions? >>> >>> My suggestion might be: >>> >>> Definitions: dodoes exit >>> Control flow: 0branch >>> Literals: (literal) >>> Memory access: ! @ c! c@ >>> Aritmetic/logic: + nand >>> Return stack: >r r> >>> >>> Of course, c! and c@ may be optional if you're content with cell-sized >>> characters. I experimented with removing 0branch, (literal), >r, and >>> r>, but the resulting system became orders of magnitude slower. >>> >>> Add to this some of DUP, SWAP, OVER, DROP, 0<, etc. Or maybe you need >>> access to the stack pointers: SP@, SP!, RP@, RP!. >> >> As my other post indicates, it's going to be hard to live with only >> 16 primitive (or low-level) words maximum. >> >> So, he might be interested in a shift-state. E.g., perhaps an >> instruction could be used to shift between two sets of 16 words. That >> would provide a total of 30 words, not including the shift word in >> both states/sets. >> > > Shifting state has its own problems. A word expects a certain state > for the tokens it will execute. Only when the primitives (low-level words) are executed does the state need to be correct or correctly switched. E.g., for a word in the first set you do nothing. For a word in the second set, you could switch to the second state, execute a primitive from the second set, switch back to the first. Each instruction in the second set would be wrapped with the switch words. Let's say the zero'th instruction is the switch word. To execute one instruction from the first set (3rd) and one instruction from the second set (4th): set1_3rd set1_0th(switch) set2_4th set2_0th(switch) In pure Forth it would look something like the following if SWAP is in set1 and >R is in set2: SWAP SWITCH >R SWITCH Since these are primitives, the SWITCH wrapper can be part of the low-level code for each set2 instruction. Obviously, you'd attempt to put less frequently used words in the second set due to the overhead. The advantage here is there is no need to decode instructions based on bits as your (snipped) example would need. Zero is also easy to detect. Philip Koopman's or Anton Ertl's instruction frequencies could be used to help decide which set is which. Rod Pemberton -- Cars kill more people than guns in the U.S. Yet, no one is trying to take away your car.