Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #465935
| Subject | Re: Hardware scripting (a better Arduino) |
|---|---|
| Newsgroups | sci.electronics.design |
| References | <LEt4B.72469$9S6.22388@fx02.iad> |
| From | Clifford Heath <no.spam@please.net> |
| Organization | Tell him he's dreaming |
| Message-ID | <BdD4B.56201$bO5.20256@fx16.iad> (permalink) |
| Date | 2017-06-28 11:01 +1000 |
On 28/06/17 00:07, bitrex wrote:
> As someone
Me, I believe.
> pointed out a while back while the Arduino toolchain seems to
> be very popular for developing hobbyist embedded applications for
> AVR/ARM, but the API and IDE is kind of a mess. The API is a bastardized
> subset of C++ where a lot of things don't work and which most users only
> use to write kludgey, procedural C-like code; you have C-like global
> functions such as "digitalWrite" which under the hood use 40 or 50
> assembly instructions just to write a bit to a GPIO port.
>
> I think it's certainly possible to make something better that allows
> someone who doesn't want to fight with the tools get real work done.
>
> I was thinking that since little uPs are really more like programmable
> hardware rather than general purpose computers, if one's looking to make
> a microcontroller language for the everyman it doesn't really make sense
> to derive it directly from a general purpose systems programming
> language like C/C++.
>
> In modern computer games the graphics and physics engines are written in
> high-performance compiled languages like C/C++. But the whole product
> doesn't use those languages to define its behavior; usually all the
> plot, mechanics, and other stuff that make a video game a game is
> fleshed out in some kind of scripting language at a much higher level of
> abstraction. This allows people other than rockstar systems programmers
> to contribute to the design and avoids needing to recompile the whole
> codebase every time someone decides this enemy spaceship should fire
> purple lasers instead of green.
>
> I think even 8 bit processors with modern architectures are fast enough
> that one could adapt a similar paradigm to writing embedded apps.
Yes, I agree. I think a lot of systems would be better implemented
that way.
>The
> high-performance stuff, like interfacing with external hardware through
> GPIO can be written in C/C++, in something like the "policy-based
> design" paradigm where you have an abstract type of device, like
> "Display" or "TemperatureSensor" which defines an interface to the basic
> functions any device of that type should be able to do, and then
> "policies" or "plug-ins" which handle the logic requirements of some
> particular type of TemperatureSensor from some manufacturer. If you want
> to change the sensor you don't rewrite the entire codebase, you just
> rewrite the plug-in.
That's what the creators of Arduino should have done with their C++
library. C++ is still the right way to build the system you describe.
> And then the logic for how the external hardware interacts could be
> written in a very abstract stack machine language, similar to Forth or
> PostScript, or a programmable RPN calculator. An example stack machine
> implementation for Arduino I saw would blink an LED on and off like this:
>
> 13 output
> {
> 13 digitalToggle 1000 delay
> true
> } while
>
> These scripts aren't compiled, but actually stored as plaintext strings
> (in compressed mnemonic form) in Flash or EEPROM and then interpreted on
> the fly by the stack machine.
This is where I diverge. "Compressed mnemonic" means tokenised. It's
better to replace each opcode by a direct pointer to the function
that implements the opcode, aka a threaded interpreter. You use a
pointer register to replace the PC, so execution is just asm("jmp p++"),
and the function extracts its parameters using "*p++". Trivial to
implement, and very fast on a not-heavily pipelined CPU.
Want help writing the compiler? It's pretty straightforward. Propose
a sensible syntax (not Basic, and not RPN/Forth!) and I'll look at it.
It would probably even integrate easily into the Arduino toolchain,
emitting C++ data definitions to be compiled into flash.
Clifford Heath.
Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Hardware scripting (a better Arduino) bitrex <bitrex@de.lete.earthlink.net> - 2017-06-27 10:07 -0400
Re: Hardware scripting (a better Arduino) Rob <nomail@example.com> - 2017-06-27 16:25 +0000
Re: Hardware scripting (a better Arduino) Don Y <blockedofcourse@foo.invalid> - 2017-06-27 10:12 -0700
Re: Hardware scripting (a better Arduino) Clifford Heath <no.spam@please.net> - 2017-06-28 11:01 +1000
Re: Hardware scripting (a better Arduino) bitrex <bitrex@de.lete.earthlink.net> - 2017-06-28 11:08 -0400
Re: Hardware scripting (a better Arduino) Don Y <blockedofcourse@foo.invalid> - 2017-06-28 10:51 -0700
Re: Hardware scripting (a better Arduino) bitrex <bitrex@de.lete.earthlink.net> - 2017-06-28 15:56 -0400
Re: Hardware scripting (a better Arduino) Don Y <blockedofcourse@foo.invalid> - 2017-06-28 14:04 -0700
Re: Hardware scripting (a better Arduino) Don Y <blockedofcourse@foo.invalid> - 2017-06-28 22:15 -0700
Re: Hardware scripting (a better Arduino) Don Y <blockedofcourse@foo.invalid> - 2017-06-30 12:23 -0700
Re: Hardware scripting (a better Arduino) David Brown <david.brown@hesbynett.no> - 2017-06-30 10:43 +0200
Re: Hardware scripting (a better Arduino) Clifford Heath <no.spam@please.net> - 2017-06-29 09:52 +1000
Re: Hardware scripting (a better Arduino) Clifford Heath <no.spam@please.net> - 2017-06-30 16:49 +1000
Re: Hardware scripting (a better Arduino) Clifford Heath <no.spam@please.net> - 2017-06-29 09:42 +1000
Re: Hardware scripting (a better Arduino) Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-06-28 16:30 +0100
Re: Hardware scripting (a better Arduino) Clifford Heath <no.spam@please.net> - 2017-06-29 09:55 +1000
Re: Hardware scripting (a better Arduino) Les Cargill <lcargill99@comcast.com> - 2017-07-02 12:50 -0500
csiph-web