Author Topic: Command languaje for tiny microcontrollers  (Read 54795 times)

0 Members and 1 Guest are viewing this topic.

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3577
  • Country: ca
Re: Command languaje for tiny microcontrollers
« Reply #75 on: October 15, 2022, 11:07:02 pm »
The ability to have a fast interactive mechanism for "trying out" code is key to productivity.

Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?
 

Online PlainName

  • Super Contributor
  • ***
  • Posts: 8927
  • Country: 00
Re: Command languaje for tiny microcontrollers
« Reply #76 on: October 15, 2022, 11:26:54 pm »
Quote
It would be cool to fire up the web browser and type some script into an edit box and run it

I realise now that I am typing that, and looking at it, as an end user whereas most of you seem to be seeing it from the viewpoint of a developer.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #77 on: October 15, 2022, 11:43:25 pm »
We should decide what we mean by "tiny microcontrollers."

For me that certainly means 8051, PIC, AVR, maybe MSP430.

All but MSP430 are Harvard architecture so you don't even have the possibility to JIT new code into RAM. not even simple subroutine threading. So you're limited to token or address threading at best, both of which have quite high overheads on ... all but MSP430.

MSP430 is sufficiently PDP11-like that it can use any register (let's say R4) as pseudoPC and with a single 16 bit instruction fetch an address-threaded word from the address pointed to by that register, increment the register, and jump to or call native code at that address.

So native code functions called from threaded code end with MOV @pseudoPC+,PC, which calls another native code function. If the thing being called is actually threaded code then it starts with CALL threaded_entry which can be a single 16 bit word if the address of threaded_entry is always kept in a register e.g. CALL R5, followed by a list of addresses of functions to be called. The threadedEntry needs to save the old value of the pseudoPC on a stack, pop the return address (which is really the address of threaded code pointers) from the CALL into pseudo-PC, then call the function that address:

Code: [Select]
threadedEntry:
    MOV @SP+,tmp
    PUSH pseudoPC
    MOV tmp,pseudoPC
    MOV @pseudoPC+,PC

And, finally, threaded code has to end with a pointer to the RETURN function that pops a saved pseudoPC from the stack and calls the threaded-address function it points to.

Code: [Select]
RETURN:
    MOV @SP+,pseudoPC
    MOV @pseudoPC+,PC

I think I got that about right -- it's been nearly 40 years since I thought about this stuff.

So, a threaded subroutine that consists of a series of calls to native subroutines executes with just ONE INSTRUCTION overhead (and two memory reads, one for the opcode, one for the address to call) between each native code function. Space-wise it one 16 bit word for each function called (whether native or threaded), plus one word native code prolog and one word for the call to RETURN.

Calling a threaded subroutine has 5 instructions overhead on entry and 3 on return.

All of 8051, AVR, PIC will have much much worse speed penalty. Or 6502 and z80 for that matter.

Quote
No one has mentioned PCode, or the pre-tokenized BASICs.

Tended to need 8 or 16 KB ROM plus 32+ KB RAM to be useful. UCSD Pascal needed 64k RAM, and even then every time you moved between Filer / Editor / Compiler it swapped probably 30 KB of code out and in at 30 KB/sec on the floppy drive(s) ... on the Apple ][ in 1981 it literally went ka CHUNK dit dit dit dit dit dit dit CHUNK dit dit dit dit dit dit dit and took a couple of seconds. (it was 4 KB per track, 40 tracks per disk)

 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #78 on: October 15, 2022, 11:49:11 pm »
The ability to have a fast interactive mechanism for "trying out" code is key to productivity.

Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

The ability to instantly try something without noticeable time penalty (compilation or execution) is valuable. You have to have experienced it to realise that.
« Last Edit: October 15, 2022, 11:51:18 pm by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #79 on: October 16, 2022, 12:08:10 am »
No one has mentioned PCode, or the pre-tokenized BASICs.

Tended to need 8 or 16 KB ROM plus 32+ KB RAM to be useful. UCSD Pascal needed 64k RAM, and even then every time you moved between Filer / Editor / Compiler it swapped probably 30 KB of code out and in at 30 KB/sec on the floppy drive(s) ... on the Apple ][ in 1981 it literally went ka CHUNK dit dit dit dit dit dit dit CHUNK dit dit dit dit dit dit dit and took a couple of seconds. (it was 4 KB per track, 40 tracks per disk)

That was positively speedy compared with Apple's Smalltalk-80 running on a Fat Mac :) "Glacial" is the appropriate word. Nonetheless it was sufficient (in 1986) to make me realise the advantages of OOP.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #80 on: October 16, 2022, 12:15:07 am »
IMHO, interpreted languages is pure bloat with no benefits.

Many people seem to be obsessed with languages thinking that a particular choice of language makes them more productive or similar non-sense. This reminds me of people on the golf course who buy new modern drivers every year and swear they then can drive longer and play better because of their new driver, but if you look at their scores, they're still the same.

All languages are interpreted, but the level varies.

For example, Pascal pCode was interpreted very successfully on 8080 class machines.

You needed 64 KB RAM (or RAM+ROM if you put the P-Code interpreter into ROM) on 8080/z80/6502 to run a useful P-Code system.

That's a BIG MACHINE in today's microcontroller landscape. There are still many many things done on machines with 512 bytes, 2k, 8k, 16k of RAM.  Sure, they often have much more ROM (flash) than that, but that's usable by compiled and downloaded C, not by on-the-fly functions downloaded as text and interpreted as text, tokens, or addresses.

Quote
A current example: if you think assembler code (and hence C/C++/etc) isn't interpreted on moderm x86-64 processors, then you don't understand the implementation of the processors. Each generation of processor has a significantly different interpreted, the details of which are not released by intel. The ability to change the interpreter is how intel fixes bugs on installed x86-64 processors.

x86 is an abomination.

RISC-V code as seen in microcontrollers (e.g. RV32IC) is NOT interpreted. It is directly executed by the hardware. The 16 or 32 bit opcodes are combinatorially decoded into something like 60 bits of signals (including 15 bits for two source and one destination register, 32 bits for a constant/offset, 4 bits for ALU operation, and misc signals such as is_jmp, is_write etc) which then DIRECTLY CONTROL the hardware gates. 

Quote
The ability to have a fast interactive mechanism for "trying out" code is key to productivity. You cannot appreciate that until you have experienced it.

Absolutely true.

Quote
That can be a conventional interpreted language or some modern compiled languages (not C++, not Fortran, not C).

It absolutely can be.

I just checked with my HiFive1 board. After editing the program I was working on most recently, the times are:

0.7 seconds to compile 28 C/C++ files and link to an ELF file
0.5 seconds to flash the new code to the board via USB

Would 0.1 seconds total be better? Sure, but not much. I generally spend a LOT more than 1 second doing even something as simple as changing a constant or adding a printf() somewhere.

Quote
The lack of facilities in many languages lead to "Greenspun's Tenth Rule of Programming: any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp."

As someone who has written a LOT of code in Dylan (roughly: Scheme semantics, Common Lisp library including CLOS, and Wirthian syntax), quite a lot in Scheme, and a reasonable amount in Common Lisp I understand where you are coming from and have known this quote for several decades.

Python, Ruby, and JavaScript are effectively the same as "Common Lisp" as far as that quote goes. Modern compiled languages such as Scala and Julia too.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Command languaje for tiny microcontrollers
« Reply #81 on: October 16, 2022, 12:15:56 am »
I realise now that I am typing that, and looking at it, as an end user whereas most of you seem to be seeing it from the viewpoint of a developer.

Both user and developer may be interested in scripting language - in case of highly customizable product. User would want to avoid hidden costs which can come if customization will be done by developer, on the other hand developer would want to avoid developing complex customization system/GUI because it may add to cost, up-to rendering whole project non-feasible for user. Solution: add embedded scripting language.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #82 on: October 16, 2022, 12:31:37 am »
So native code functions called from threaded code end with MOV @pseudoPC+,PC, which calls another native code function.

IMPORTANT NOTE: the above threaded code mechanism has NOTHING to do with FORTH.

It is true that FORTH is often implemented in this way, but so have been many compilers for FORTRAN, COBOL, Pascal and probably even C or BCPL or Algol on machines with limited memory size and weak instruction sets leading to bulky native code.
 

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3577
  • Country: ca
Re: Command languaje for tiny microcontrollers
« Reply #83 on: October 16, 2022, 12:39:57 am »
Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

To create something that big you will need months of development. This is not something you can possibly try quickly,  and it will take really long time to duplicate with interactive interpreted language.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #84 on: October 16, 2022, 01:45:10 am »
Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

To create something that big you will need months of development. This is not something you can possibly try quickly,  and it will take really long time to duplicate with interactive interpreted language.

omg. "Even 1 minute".

Yes, I used to have those kinds of turn-around times, back in the 80s. Hell, I remember back when I first started using Apple's "MacApp" application framework clean build times were about an hour. It was an amazing day when I got a 60 MHz PowerPC Mac with the new Metroworks CodeWarrior and suddenly those clean build times were under five minutes.

I just tried modifying one of my HiFive1 programs to include a 1 MB static array of data, initialised with 2^20 entries like 0xb7, , but random.

2.5 sec compile time (up from 0.7 seconds for a small program)
7.5 sec upload/flash time (up from 0.5 seconds for a small program)

What would it take to get to a minute? SIX megabytes of program?

Yeah, that board has that much flash, and more. But only 16 KB RAM. What would you even DO with 6 MB of program?

Apart from this, back in February 2017:



I got a copyright claim on that video, lol.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #85 on: October 16, 2022, 02:34:30 am »
No one has mentioned PCode, or the pre-tokenized BASICs.

Tended to need 8 or 16 KB ROM plus 32+ KB RAM to be useful. UCSD Pascal needed 64k RAM, and even then every time you moved between Filer / Editor / Compiler it swapped probably 30 KB of code out and in at 30 KB/sec on the floppy drive(s) ... on the Apple ][ in 1981 it literally went ka CHUNK dit dit dit dit dit dit dit CHUNK dit dit dit dit dit dit dit and took a couple of seconds. (it was 4 KB per track, 40 tracks per disk)

That was positively speedy compared with Apple's Smalltalk-80 running on a Fat Mac :) "Glacial" is the appropriate word. Nonetheless it was sufficient (in 1986) to make me realise the advantages of OOP.

OMG! Someone made a video earlier this year of doing some programming on an Apple //e using Apple (USCD) Pascal.



Sooooooo slow. 1 MHz 6502 forever. The UCSD P-system was a port from other machines -- exactly the same bytecode programs ran on the PDP-11, 8080/z80, M68000, and 8086 -- and really wasn't designed or optimised around the 6502's strengths and weaknesses. I think quite a bit better could be done.

Basically the exact system you see here was one of the original three OSes offered for the IBM PC, along with CP/M and MS-DOS. Hopefully it was a bit faster.

I don't think the 128k made any real difference from 64k in this video. The compiler is getting down to 34 KB free, which obviously could not be 64 KB lower on a 64 KB machine. Maybe it is keeping more code overlays in RAM at the same time so repeated flipping between editor and compiler is faster.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 8349
  • Country: fi
    • My home page and email address
Re: Command languaje for tiny microcontrollers
« Reply #86 on: October 16, 2022, 03:21:28 am »
The machinery I use (with GCC or Clang, since these require the toolchain to use ELF format object files), means that if I want to expose say
    static int  beef = 1;
to my query-response interface, all I need to do is include a header file defining some structures and macros, and add
    EXPOSE_INT(&beef, 0xBEEF);
where 0xBEEF is the token identifier (perfect hash of the name) I use in the query-response interface for it.

That, and an input parser/tokeniser and dispatcher, is all that is needed, really.



The key parts of that included header file are
Code: [Select]
#include <stdint.h>

struct exposed {
    uint32_t  ident;
    union {
        void (*func)(void);
        int   *iptr;
        /* Other pointer types omitted for brevity */
    };
} __attribute__((packed));

#define  MERGE2_(a, b)  a ## b
#define  MERGE2(a, b)   MERGE2_(a, b)

#define  EXPOSE_(varname, vtype, vname, member, ptr)    \
    __attribute__((used, section ("exposed")))          \
    static const struct exposed  varname = {            \
        .ident = (((uint32_t)(vtype) & 0x1F) << 27)     \
               | ((uint32_t)(vname) & 0x07FFFFFF),      \
        .member = (ptr)                                 \
    }

#define  EXPOSE_FUNC(fn, hash) \
    EXPOSE_(MERGE2(expose_, __LINE__), 0, hash, func, fn)

#define  EXPOSE_INT(ptr, hash) \
    EXPOSE_(MERGE2(expose_, __LINE__), 1, hash, iptr, ptr)

/* Up to 30 other types omitted for brevity */
The union is only used for type checking, so that if you use e.g char step; and then EXPOSE_INT(&step, 0xDEAD), you get a warning about incompatible pointer types.

Above, the high 5 bits of ident specify the type, and low 27 bits the perfect hash or encoding of the name.  (For example, five base-40 characters.)

Each EXPOSE_INT() or EXPOSE_FUNC() declaration adds a struct exposed entry (in pseudo-random order) to the exposed section in the final binary, where they all can be accessed.  This means that I can expose even static variables, without global linkage, and it only needs a single declaration in that same compilation unit.  It also works very well if one uses preprocessor conditionals or Makefile magic to select what code gets included in the final binary.  Wherever the variable or function is defined, you just add an expose macro next to it: very low cognitive overhead.

In the linked binary, we can use the following to look up any exposed item:
Code: [Select]
extern const struct exposed  __start_exposed[];
extern const struct exposed  __stop_exposed[];

const struct exposed *find_exposed(uint32_t hash)
{
    const uint32_t  mask = 0x07FFFFFF;
    const struct exposed *curr = __start_exposed;

    /* Ensure hash has no type bits set. */
    hash &= mask;

    while (curr < __stop_exposed)
        if ((curr->ident & mask) == hash)
            return curr;
        else
            curr++;

    return NULL;
}
The two extern symbols are defined by the linker.  The section contains all expose declarations from all compilation units linked to the final object.
If find_exposed(hash) returns a non-NULL pointer p, then (p->ident>>27) identifies the type (the number in the EXPOSE_INT(), EXPOSE_FUNC() macros).

All of the above gets placed in ROM/Flash; no additional RAM is used.  (If you use your own linker script, this is the exposed section.  Do also define the __start_exposed and __stop_exposed symbols, as is done by default linker scripts.)

The find_exposed() operation can be made faster by adding a post-processing step in your build, where the order of the entries in the exposed section is sorted (by the 27 low bits of ident members, here).  That would allow you to use a binary search, as I mentioned before.  You could also store the strings, and in the post-processing step replace the strings with their corresponding hashes, even if it changes the size of the exposed section.  (The annoying thing is the relocation records, and editing them.  Raw binary data is trivial, but relocation records –– the pointers to the variables or functions –– are harder to manipulate using objcopy only.) (Also note that this latter struct exposed does not need to have the same format as earlier; it only needs to match the possibly post-processed exposed section contents.)

In addition to above, you need the input parser, of course.  But all it needs, really, is to parse (hash) the first name, look it up, and decide what to do with the rest of the input request/command –– but knowing the type and address of the thing being referred to.  In particular, an implementation that supports
    name '?'         (query)
    name '=' VALUE   (assignment)
    name             (function call without parameters)
    name VALUE       (function call with an integer parameter)
can parse the input character by character using a straightforward state machine, without any kind of string buffer at all.  VALUE can be an integer, fixed-point, or even a name, depending on what your exact needs are; but integer-only is the simplest.  Adding multiple-parameter function calls requires a slightly more complicated state machine, and RAM storage for the parameters, a stack of VALUEs.



This does come in useful, when you have an external device –– a sensor, or actuator of some kind, for example –– and you are not sure of the optimal parameters to use with that device.  Or you are playing with e.g. PWM capabilities of the MCU.
Instead of making everything externally programmable, you just declare the variables you want to get and set, and the functions you want to call, and your input parser stuff should handle the details.

(As I often use Teensies for this kind of experimentation, and they all have native USB interfaces, I can also use an "extra" USB Serial endpoint for this kind of communication between my computer and the microcontrooler.  The actual firmware can be a bulk USB device, a HID device, or whatever I happen to need.)

In a design sense, this is very close to attaching a debugger to your microcontroller, and using it to modify the RAM state or execute specific functions.

For playing with controlling external devices, I like this approach better than a debugger, because this way the microcontroller firmware runs normally and is always in full control, instead of being under the debugger control.  This minimizes the differences between "normal operation" and "exploring settings", and thus ensures the results found via such exploration are consistent even when used with this machinery later on.
« Last Edit: October 16, 2022, 03:22:01 pm by Nominal Animal »
 
The following users thanked this post: newbrain

Online PlainName

  • Super Contributor
  • ***
  • Posts: 8927
  • Country: 00
Re: Command languaje for tiny microcontrollers
« Reply #87 on: October 16, 2022, 08:28:17 am »
Quote
I just tried modifying one of my HiFive1 programs to include a 1 MB static array of data, initialised with 2^20 entries like 0xb7, , but random.

2.5 sec compile time (up from 0.7 seconds for a small program)
7.5 sec upload/flash time (up from 0.5 seconds for a small program)

What would it take to get to a minute? SIX megabytes of program?

That's not an appropriate test since you are set up to do that. What would be the times if you start with just your source files, no cached headers or compiler output, no cached libs or framework?
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #88 on: October 16, 2022, 09:01:05 am »
Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

To create something that big you will need months of development. This is not something you can possibly try quickly,  and it will take really long time to duplicate with interactive interpreted language.

omg. "Even 1 minute".

:) That comment has to be read in conjunction with the last sentence in that paragraph!

Slow turnaround times leads to a rather different style: you read, understand, think, and typing/compiling/running comes at the very end :)

Sometimes the old days were better  >:D

Quote
Yes, I used to have those kinds of turn-around times, back in the 80s. Hell, I remember back when I first started using Apple's "MacApp" application framework clean build times were about an hour. It was an amazing day when I got a 60 MHz PowerPC Mac with the new Metroworks CodeWarrior and suddenly those clean build times were under five minutes.

5 minutes? Luxury, but then I started with Algol-60 on 5-channel paper tape and a 2kIPS machine (one is still running at TNMoC, and the staff are happy to whip out and discuss the schematics!)

I always hated letter-shift figure-shift, only to find it has been trumphantly resurrected on the keyboards on fondle-slab computers and phones.

Quote
Apart from this, back in February 2017:



I got a copyright claim on that video, lol.

No closed-caption subtitles available :(
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #89 on: October 16, 2022, 09:05:29 am »
Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

To create something that big you will need months of development. This is not something you can possibly try quickly,  and it will take really long time to duplicate with interactive interpreted language.

Now consider trying to debug an application with an included library. Too often the library is poorly documented and/or understood, and interactive step-wise debugging is a good way to proceed.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #90 on: October 16, 2022, 09:21:10 am »
No one has mentioned PCode, or the pre-tokenized BASICs.

Tended to need 8 or 16 KB ROM plus 32+ KB RAM to be useful. UCSD Pascal needed 64k RAM, and even then every time you moved between Filer / Editor / Compiler it swapped probably 30 KB of code out and in at 30 KB/sec on the floppy drive(s) ... on the Apple ][ in 1981 it literally went ka CHUNK dit dit dit dit dit dit dit CHUNK dit dit dit dit dit dit dit and took a couple of seconds. (it was 4 KB per track, 40 tracks per disk)

That was positively speedy compared with Apple's Smalltalk-80 running on a Fat Mac :) "Glacial" is the appropriate word. Nonetheless it was sufficient (in 1986) to make me realise the advantages of OOP.

OMG! Someone made a video earlier this year of doing some programming on an Apple //e using Apple (USCD) Pascal.

Sooooooo slow. 1 MHz 6502 forever. The UCSD P-system was a port from other machines -- exactly the same bytecode programs ran on the PDP-11, 8080/z80, M68000, and 8086 -- and really wasn't designed or optimised around the 6502's strengths and weaknesses. I think quite a bit better could be done.

Don't forget the Western Digital https://en.wikipedia.org/wiki/Pascal_MicroEngine

But that p-code compilation is positively speedy compared with Apple Smalltalk on a FatMac. I'm tempted to make a video of it running; let's just say that even at 5fps, there could be a vast amount of inter-frame compression!
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #91 on: October 16, 2022, 09:55:01 am »
Quote
I just tried modifying one of my HiFive1 programs to include a 1 MB static array of data, initialised with 2^20 entries like 0xb7, , but random.

2.5 sec compile time (up from 0.7 seconds for a small program)
7.5 sec upload/flash time (up from 0.5 seconds for a small program)

What would it take to get to a minute? SIX megabytes of program?

That's not an appropriate test since you are set up to do that. What would be the times if you start with just your source files, no cached headers or compiler output, no cached libs or framework?

Those are the times.

Nothing is cached, there are no precompiled headers. All source files and headers are compiled from text every time.
 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 6464
  • Country: nz
Re: Command languaje for tiny microcontrollers
« Reply #92 on: October 16, 2022, 10:17:26 am »
But that p-code compilation is positively speedy compared with Apple Smalltalk on a FatMac. I'm tempted to make a video of it running; let's just say that even at 5fps, there could be a vast amount of inter-frame compression!

Please do!

It is hard to believe, given the Mac's CPU is approximately 10x faster.  (estimate based on RAM bandwidth, typical instruction execution times, 2-4 times wider registers etc, not just the clock speed)

THINK Pascal and Turbo Pascal both ran very well on 512k and 1 MB 8 MHz Macs, both the compile times and the executed code.

Ah .. look and you will find. Here's a video using early Turbo Pascal on a Mac. It's a 16 MHz 68020, but on a 16 bit bus like the 68000. So it's probably not much more than twice as fast as the FatMac.



Sadly the guy is a bit clueless. For example he says the SANE library imported is for the debugger. No. It's the Standard Apple Numeric Library (i.e. software IEEE FP).  He was probably thinking of the SADE debugger (for putting your app in bondage) that came later with MPW (Macintosh Programmer's Workshop).

He spends a long time going through the code. Actual compile and then run is at 33:00.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #93 on: October 16, 2022, 12:52:31 pm »
But that p-code compilation is positively speedy compared with Apple Smalltalk on a FatMac. I'm tempted to make a video of it running; let's just say that even at 5fps, there could be a vast amount of inter-frame compression!

Please do!

It is hard to believe, given the Mac's CPU is approximately 10x faster.  (estimate based on RAM bandwidth, typical instruction execution times, 2-4 times wider registers etc, not just the clock speed)

The Apple Smalltalk was a "naive" implementation of the first Xerox image + VM.

All accesses to all objects was indirect through the global object table. The bytecode was fully interpreted; there was no JITting (LP Deutsch's seminal JITter came later).

Running from two floppies inserted into the single drive wasn't a significant limitation, due to the good consequences of the VM + image + incremental change file concepts.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #94 on: October 16, 2022, 02:37:12 pm »
The ability to instantly try something without noticeable time penalty (compilation or execution) is valuable. You have to have experienced it to realise that.

Just to emphasise that, here's something from a 39 year old book, indicating what had already been achieved bfore 1983. It reminds me of the accurate old quip that "Algol-60 is an improvement on most of its successors".

There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17830
  • Country: fr
Re: Command languaje for tiny microcontrollers
« Reply #95 on: October 16, 2022, 06:35:53 pm »
Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

To create something that big you will need months of development. This is not something you can possibly try quickly,  and it will take really long time to duplicate with interactive interpreted language.

It's a decades-old question that will keep popping up for decades to come.

Some people seem to think that "interactive" development tools are more productive. My experience (and that of many others) is the exact opposite.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #96 on: October 16, 2022, 06:58:49 pm »
Sure. I do this all the time. Compiling a small snippet of C or Assembler code and programming it on the chip takes couple seconds. How much faster do you need?

After a while it will be more than a small snippet or couple of lines of C, and it will take more than a couple of seconds to compile and download. Even 1 minute is enough to break the flow of interactive debugging. Whether breaking the flow is a problem is a separate issue, of course.

To create something that big you will need months of development. This is not something you can possibly try quickly,  and it will take really long time to duplicate with interactive interpreted language.

It's a decades-old question that will keep popping up for decades to come.

Some people seem to think that "interactive" development tools are more productive. My experience (and that of many others) is the exact opposite.

It depends.on the for circumstances.

When I'm with people advocating interactive programming, I'll stress the benefits of planning and thinking before approaching a keyboard. OTOH when with people advocating compile-link-run then I'll stress the times when that is unnecessarily restrictive.

Having many tools and knowing when to use them is a key engineering skill. But you know that :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 
The following users thanked this post: elecdonia

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1981
  • Country: us
Re: Command languaje for tiny microcontrollers
« Reply #97 on: October 16, 2022, 06:59:22 pm »
Agreed. The best development environment / language / MCU / whatever is the one that gets the job done. Ask five Engineers for their preference and you'll get seven answers.  :-DD

WRT the cycle time discussion above, even with Microchip's MPLAB X and an ICD3 I can recompile and reflash in about five seconds. Takes me that long to spin in my chair from the firmware bench to the hardware bench and pick up the probe(s) to switch to physical debug mode. By the time the human is ready, the reflash is done and executing.

I don't get wrapped around the axle about shaving sub-seconds off such cycle times, there are far too many other things that consume vastly more time and increase inefficiency to a greater extent. Great example: This year I built a "new" main workstation but could not go farther than an i7-something CPU and motherboard because I insist on running Win7. Many would argue that I'm "running slow" because I'm not using the latest i9-Thz CPU but let's be honest:

* Most of the time the CPU is waiting on my next keystroke, so the human is already the limiting factor

* Win7 is much easier to optimize for development by shedding all the garbage you don't need (I'm under 50 processes when idle, how 'bout you?)

* Win7 never interrupts me demanding to perform an update, and never changes my settings to what Microsoft thinks is better

So who is more efficient... the guy who can brag about a bleeding edge clock rate, or the guy whose machine isn't running unnecessary things and never interrupts for updates and changes no one asked for?
« Last Edit: October 16, 2022, 07:01:56 pm by IDEngineer »
 

Offline IDEngineer

  • Super Contributor
  • ***
  • Posts: 1981
  • Country: us
Re: Command languaje for tiny microcontrollers
« Reply #98 on: October 16, 2022, 06:59:53 pm »
Having many tools and knowing when to use them is a key engineering skill.
Best summary of this entire thread.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 23122
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Command languaje for tiny microcontrollers
« Reply #99 on: October 16, 2022, 07:03:42 pm »
Agreed. The best development environment / language / MCU / whatever is the one that gets the job done. Ask five Engineers for their preference and you'll get seven answers.  :-DD
.

You should get at least seven answers :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->