Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Which scripting for embedded automation? Date: Tue, 28 Jul 2015 23:47:48 -0400 Organization: Aioe.org NNTP Server Lines: 94 Message-ID: References: <0e930740-22d8-4e2b-833f-bb5843437d0d@googlegroups.com> <87y4i6rvyc.fsf@jester.gateway.sonic.net> <87lhe5sciz.fsf@jester.gateway.sonic.net> <8f8f8dd6-efca-4f3e-ac18-ed28bce7524c@googlegroups.com> <40eef114-1b88-4c29-8937-f0a708a8e805@googlegroups.com> 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:40884 On Tue, 28 Jul 2015 13:22:48 -0400, Bernd Linsel wrote: > Am 27.07.2015 um 20:02 schrieb hughaguilar96@gmail.com: >> On Sunday, July 26, 2015 at 10:29:59 PM UTC-7, Rod Pemberton wrote: >>> C captures the essence of all generic microprocessors. > You've replied to both Hugh and I in the same post. That's likely to incite Hugh. Well, everything incites Hugh ... It's easier to follow if you keep replies to the last person, and reply to the other person on their post. >>> C captures the essence of all generic microprocessors. > > Nope. C works fine on machines with huge register sets, a hardware > call stack, and a frame pointer. You're even better off if it supports > indexed register-indirect addressing modes. Yes. Everything an 8-bit microprocessor can do, and the general purpose instructions of 16-bit processors, can be done directly in C without needing to use assembly. The only thing missing is a carry flag and an overflow flag. While it's much easier to implement C on a machine with a hardware stack, C was implemented on mainframes without them. That's why the C standards don't require a stack. However, IIRC, it was Dennis Ritchie who showed in one of his papers that a stack is the easiest and cleanest way to implement recursion in C, which is required. Also, C works fine on machines with few registers. C works best on microprocessors with addressable 8-bit bytes, contiguous memory, two's complement arithmetic, a hardware stack, the largest integer a multiple of the 8-bit byte, and pointers the same size as the largest integers. Forth generally likes these too, but needs two stacks to implement instead of one since it separates the data and control flow stack. Integers a multiple of the size of a byte is needed because C maps every object onto an array of bytes. Pointers the same size as the largest integer is convenient because of C's lossless type conversions, i.e., pointer to integer to pointer. C is difficult to implement on machines with a 16-bit word size, machines where the smallest addressable unit is much larger than a character in size, machines where the address pointer is greater in size than the largest integer. All of these situations require constructing special code, e.g., to save extra bits for pointer conversions or to extract characters packed into larger integers. > I wouldn't call that a "generic microprocessor". Look at the (vain) > efforts to implement C on the 1980's common processors (8080/5, 8086, > ...). Motorolas 68K was the first part decently usable for C. While it seems you're familiar with some stuff from the 1980's, it seems you forgot about Ron Cain's SmallC. It was originally written for the Intel 8080 and also ported to PDP-11. If it can run on 8080, it can run on all other 8-bits. IIRC, the code emitted by the 8086 port needed only *two* registers. I'd suspect it needed a few more on the 8080. >>> Forth, instead, usually attempts to impose it's own virtual machine. > > Forth runs perfectly on stack machines, e.g. RTX 2000. The RTX 2000 was a dedicated Forth processor. Why would you need to implement a virtual machine for it? ... More commonly, when Forth is implemented on a generic processor, Forth is implemented as an interpreter which uses a virtual machine. Specifically, it uses a virtual processor, generally with registers W, IP, PSP, RSP, UP, and/or X, and/or TOS. If you're interested in this, you can read Bradford J. Rodriguez's Forth code for various 8-bit processors: Bradford J. Rodriguez, PHD http://www.bradrodriguez.com/papers/ However, I'd assume that if you're familiar with Koopman then you're likely familiar with Rodriguez. > You should read Philip J. Koopman, Jr's publications: > http://users.ece.cmu.edu/~koopman/stack_computers/ I'm quite familiar with some of his work, including portions of his book, since I consulted it for my Forth interpreter, e.g., instruction set frequencies and similar papers by Anton Ertl's too. Rod Pemberton -- Scientists now say we'll experience a mini-ice in 2030. So, I guess we need more global warming today ...