Author Topic: The Imperium programming language - IPL  (Read 86908 times)

0 Members and 11 Guests are viewing this topic.

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: A microcontroller programming language
« Reply #475 on: December 18, 2022, 05:21:17 pm »
But the issue would be that if you included that statement in the language, and people start using it, even when it was not really needed.  Any architectures, that DON'T have a 64 bit, bit count instruction, may run that instruction very inefficiently.

it's always a compromise, hardware/profile can only mitigate this.

1: compatibility -> software emulated instructions when not hardware implemented. You know, it will be slower.
2: speed -> full use of the hardware, only if possible
3: nothing -> always refuse to compile if you are not willing to accept none of the above
4: deal -> always find a "sub solution" between the first two points

my-c encourages (actually forces) you to segregate critical parts into modules.
So you can easily think about what you have to do to support your specific hardware/profile

I mean, if you do that, say you have 10 .c files, 8 are OK, and will be compiled, 2 will be rejected.
You know you have to think about how to replace those 2 (even with modules written in assembly).

Talking about my job experience, segregated critical parts is also good practice for test-report.
(you save time, same result to pass the QA with less effort)
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 
The following users thanked this post: MK14

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11713
  • Country: my
  • reassessing directives...
Re: A microcontroller programming language
« Reply #476 on: December 18, 2022, 05:32:14 pm »
Although you are right, that some programmers, might have understood it.  It should have been written clearly enough so that all or nearly all, programmers, could understand it.
you cant win against nitpickers, and esp trolls (when they became apparent... since no better argument can be given)... requoted below..

C does support embedded assembly language though, can one go any lower?

it seems he is quite fixed, hence he doesnt need anymore "negative" advice. if you like something he post next, then you can talk ;) cheers.

ps: how could i've forgotten this button? (attached picture) :palm: thanks God!
and oh... this topic also in the list... could be a good bedtime reading...
https://www.eevblog.com/forum/programming/too-many-programming-languages/

cheers.
« Last Edit: December 18, 2022, 05:47:52 pm by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline Sherlock HolmesTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: A microcontroller programming language
« Reply #477 on: December 18, 2022, 06:13:25 pm »
You raise some good points. But your example using a = a - 2; is something done routinely, even in C. You'd need to show a better example of an abstract idea that's "low level" and that C doesn't support, that you consider would be too low level.

I didn't explain the a = a - 2 section very well.

Another (possibly better) example, would be a low level instruction, which counts how many bits in total, are set (1), in an unsigned, 64 bit integer.  Which is useful for some types of algorithms and program types.

So the high level language, could include a low level statement, which counts up the bits set count, works in only 1 CPU clock cycle (because the initial CPU architecture has such an assembly language instruction), for the current CPU architecture, and so runs very quickly.

But the issue would be that if you included that statement in the language, and people start using it, even when it was not really needed.  Any architectures, that DON'T have a 64 bit, bit count instruction, may run that instruction very inefficiently.
There are faster methods, but essentially the function would be performing something like:

// Code vaguely based on Pascal
// Count the total bits set in variable x
bit_count = 0;
for bit = 0 to 63 do
begin
if x and 1 == 1 then bit_count++;
x /= 2;
end

There are faster algorithms.

C does support embedded assembly language though, can one get any lower level than that?

That is an interesting question.  Computers are getting rather complicated these days, because as well as the CPU which processes conventional instructions.  There can be various other sections (System on a chip, SoC), such as AI/Machine learning accelerators (technical names can vary), hardware encryption, video encoders/decoders.  Even finite state machines (FSMs), FPGAs, the list these days, seems to go on and on.

So I suppose it depends on ones definition.  But anyway, technically speaking some of these SoC (names can vary), features, can be at a relatively simple/low level (lower than standard double floating point or 64 bit integers), but typically, it is done at incredibly high speeds.  Compared to the main/normal/standard CPU instruction set.

OK I see, that's a better example. Yes the bit count thing is something I was reading about recently, they refer to it as "popcount". The concern then is, that a person might write code using that or copy/paste code using that and have no inkling that there might be a much higher cost than they would have thought.

So this raises the question of intrinsic operations, how to deal with and implement these, its a good question, a very relevant issue, I agree.

Here's a Microsoft article on this very issue of popcount.

Note:

Quote
If you run code that uses these intrinsics on hardware that doesn't support the popcnt instruction, the results are unpredictable.

You've raised a pretty good issue here, the very kind of thing that must be carefully thought about in a new language. It's an interesting area, there are no reserved words too so naming and adding intrinsic over time can't break existing code, this is a good example of why having no reserved words is a help, I know I may have seemed to dwell on this a lot, but if one doesn't design the grammar to do that there's no going back, incorporating this gives a great deal of power.

Now PL/I (and this new language - potential new language...) has what are called "builtin" functions. These are functions inherent in the language and they way they did that is clever.

To use a builtin function you MUST declare the function, declaring is very easy too, whatever the function is, whatever it returns and whatever arguments it takes, it is always declared as:

Code: [Select]

dcl Substr builtin;
dcl Sqrt builtin;
dcl Offset builtin;


Of course a bunch of those could easily be inside some utility include file. The attribute 'builtin' is sufficient, since the compiler knows already about the function's signature. This is how PL/I represents the kind of things we see in C with "stdlib.h" but is much slicker I think.

Now because keywords are not reserved, a user might create a function named 'Sqrt' and that's fine and legal, because unless they've already declared it as builtin, there's no issue, if they later wanted to use the real builtin one, they realize the conflict and resolve it. This means that adding new builtins also cannot break existing code, unless a builtin is explicitly declared it does no harm and a user cannot declare a function as builtin if its not yet present in the version of the language they're using.

Anyway, I'm thinking a similar idea could well be applied to intrinsics, naturally we'd consider something like:

Code: [Select]

dcl Popcount intrinsic;
dcl Emit intrinsic;
dcl Prefetch intrinsic;


Then during compilation we'd issue a diagnostic if the intrinsic was not available for the target CPU or if it is available but might be costly...

« Last Edit: December 18, 2022, 06:30:59 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 
The following users thanked this post: MK14

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #478 on: December 18, 2022, 06:30:44 pm »
Long thread, so I have not read the entire thing.  I will say that anytime you are working close to the metal, or even just controlling things, Forth is an excellent choice.  Yet, I haven't seen it mentioned very much here. 

Forth is my go to language for any programming I do outside of a spreadsheet. 

Why are people not more interested in Forth?  Is it just a matter of it being so different from languages like C?
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Offline Sherlock HolmesTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: A microcontroller programming language
« Reply #479 on: December 18, 2022, 06:32:33 pm »
Long thread, so I have not read the entire thing.  I will say that anytime you are working close to the metal, or even just controlling things, Forth is an excellent choice.  Yet, I haven't seen it mentioned very much here. 

Forth is my go to language for any programming I do outside of a spreadsheet. 

Why are people not more interested in Forth?  Is it just a matter of it being so different from languages like C?

I'm interested in many languages, I admit to knowing very little about Forth, I read a lot about it years ago, it was used early on when MCU's came out in the 1970s.

So tell me about Forth, what do you like about it?

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 20768
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: A microcontroller programming language
« Reply #480 on: December 18, 2022, 07:13:41 pm »

C does support embedded assembly language though, can one get any lower level than that?

Yes, you can.

Current Intel processors like this: https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/secure-coding/loading-microcode-os.html

Current AMD processors similarly.

With previous Intel processors it was more interesting and explicit: see their 3000 series processors. For the superior AMD equivalent, see their 2900 series.
« Last Edit: December 18, 2022, 07:16:46 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
 
The following users thanked this post: MK14

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: A microcontroller programming language
« Reply #481 on: December 18, 2022, 07:33:04 pm »
It's why POWER10 is publicized as "safe".
IBM RISC, doesn't allow any microcode.
It has no microcode.

Assembly is the lowest level you can go.
And it mostly looks ~ppc64
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15439
  • Country: fr
Re: A microcontroller programming language
« Reply #482 on: December 18, 2022, 07:38:14 pm »
Microcode upload is one spectacularly great security hole. But it allows CPU vendors to rush new models into production.
 
The following users thanked this post: MK14, DiTBho

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #483 on: December 18, 2022, 08:11:45 pm »
Long thread, so I have not read the entire thing.  I will say that anytime you are working close to the metal, or even just controlling things, Forth is an excellent choice.  Yet, I haven't seen it mentioned very much here. 

Forth is my go to language for any programming I do outside of a spreadsheet. 

Why are people not more interested in Forth?  Is it just a matter of it being so different from languages like C?

I'm interested in many languages, I admit to knowing very little about Forth, I read a lot about it years ago, it was used early on when MCU's came out in the 1970s.

So tell me about Forth, what do you like about it?

Forth is interactive, you type on the command line and it provides immediate results.  Subroutines are called word definitions.  Words can be tested from the command line.  This lets you test your work coded from the bottom up. 

The Forth tool itself is very small.  You can implement it on an MCU using just 8 kB to 16 kB of program store and some small amount of RAM.  This means your development system is the target MCU itself!  Your computer is a terminal and the mass storage.  Compiling a program is just a matter of dumping it through the serial port, or Ethernet port, or USB port the target is connected to. 

The bottom line is, it's very flexible. 

I am going to be rewriting a test fixture control program written in Forth, to handle multiple test units simultaneously.  I'm looking forward to this.
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: A microcontroller programming language
« Reply #484 on: December 18, 2022, 08:17:57 pm »
Long thread, so I have not read the entire thing.  I will say that anytime you are working close to the metal, or even just controlling things, Forth is an excellent choice.  Yet, I haven't seen it mentioned very much here. 

Forth is my go to language for any programming I do outside of a spreadsheet. 

Why are people not more interested in Forth?  Is it just a matter of it being so different from languages like C?

Forth has weird conventions and mechanisms.

I prefer PostScript. It is much improved over Forth, clearer to read, better data structures, and more dynamic by default, though you can "bind" things for speed when needed.
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #485 on: December 18, 2022, 10:41:28 pm »
Why are people not more interested in Forth?  Is it just a matter of it being so different from languages like C?

Forth has weird conventions and mechanisms.

I prefer PostScript. It is much improved over Forth, clearer to read, better data structures, and more dynamic by default, though you can "bind" things for speed when needed.

What weird conventions and mechanisms?
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #486 on: December 18, 2022, 10:45:02 pm »
Forth has weird conventions and mechanisms.

I prefer PostScript. It is much improved over Forth, clearer to read, better data structures, and more dynamic by default, though you can "bind" things for speed when needed.

sectorforth, see here:
https://github.com/cesarblum/sectorforth

Fits the entire Forth system into a tiny, single 512 byte sector (of a floppy disk, I think).  Which shows the power of both assembly language it is mainly written in, Forth, and some peoples determination, to do things, just because they can.

That is so small, you could fit it into just 8 of the 16 or 32 registers of an AVX-512 equipped processor.  Call it just 25% of the AVX-512 accumulators/registers, or an even lower percentage, if you include the mask registers.

How long would it take, to create a Postscript system, complete with all its 400+ commands/instructions (an average of a byte or so, for each one), to fit into a single 512 byte sector?

I think for some new programming languages.  Forth's potential, high efficiency in some areas, and the fact that much of it, is actually written in Forth itself, makes it interesting.  Because it allows final end users (programmers), to freely extend its functionality, as if it was part of the original interpreter.

But as suggested in quote, PostScript, seems interesting to consider as well.  Thanks for mentioning it.  I seem to very strongly associate it with Laser Printers, rather than seriously considering it as a programming language, for various reasons.  Also, I consider GhostScript, a rather unreliable and buggy way of trying the language out.  At least it (GhostScript) was (rather/very buggy), a long time ago.

512 bytes is very small, even for a Forth.  Are there no additional word definitions that get loaded as source?  Source compilation is so fast, that systems often have just a core in binary, and load the remainder from source. 

I don't know of any PostScript tools that are generally available for embedded systems.  Would using PS on an ARM with 16 kB of Flash even be possible?
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Offline cfbsoftware

  • Regular Contributor
  • *
  • Posts: 124
  • Country: au
    • Astrobe: Oberon IDE for Cortex-M and FPGA Development
Re: A microcontroller programming language
« Reply #487 on: December 18, 2022, 11:04:45 pm »
C does support embedded assembly language though, can one get any lower level than that?
One of the features of softcore FPGA CPUs is that you can implement specialised operations using bit patterns which were previously undefined in the instruction set. These bit patterns can be emitted directly by the compiler without using an assembler.     
Chris Burrows
CFB Software
https://www.astrobe.com
 
The following users thanked this post: MK14, Sherlock Holmes

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: A microcontroller programming language
« Reply #488 on: December 19, 2022, 12:16:05 am »
Quote
These bit patterns can be emitted directly by the compiler without using an assembler.     

emitted how? By inline asm DC?
If the machine layer is not awere of them and they are emmited as "raw" data, then it's a trick

Sure it works, but it's an hack
Does not pass QA
Makes ICE confused
Makes the source dirty
Makes the compiler unable to understand what's going on
Makes the source not portable
Opens doors to undefined run time behaviors
« Last Edit: December 19, 2022, 12:26:26 am by DiTBho »
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #489 on: December 19, 2022, 12:34:35 am »
512 bytes is very small, even for a Forth.  Are there no additional word definitions that get loaded as source?  Source compilation is so fast, that systems often have just a core in binary, and load the remainder from source.

I've wanted to try it out for some time, but been put off, because you have to sort out some kind of 386 system (e.g. an emulator), to try it out.

Looking at the hello world, example program.  Here:
https://github.com/cesarblum/sectorforth/blob/master/examples/01-helloworld.f

This is what I expected.  If the application has to define words like branch and ?branch and lit, then this is a very primitive kernel.  Not many systems are this primitive, because it requires so much to be included in the application.  But if you only have 512 bytes!

Compiling in Forth is unusually fast, and only single pass.  The dictionary structure allows words to be compiled without spending lots of time resolving references, etc. 


Quote
It seems there are only 8 primitive words (see readme file for more information, sorry, I called them functions in my earlier post, I tend to call things functions or procedures, or even subroutines, even if the language prefers other names).  So the hello world example program, defines a very large number of relatively primitive functions words, in order to make the required program.

In fairness, 512 bytes is rather tight to fit a full (ALL) Forth word, system into.  But even so, to have enough of a Forth System, to make a usable entity, is still very impressive!

E.g. The hello world program has definitions, such as:

Quote
\ stack manipulation words
: drop ( x y -- x ) dup - + ;
: over ( x y -- x y x ) sp@ 2 + @ ;
: swap ( x y -- y x ) over over sp@ 6 + ! sp@ 2 + ! ;
: nip ( x y -- y ) swap drop ;
: 2dup ( x y -- x y x y ) over over ;
: 2drop ( x y -- ) drop drop ;

So it is sort of cheating.  But it also shows the expressive power of Forth, rather nicely.

It's not exactly cheating.  Some C implementations will only include parts of libraries that are actually invoked, to keep the executable small.  In this kernel, it's up to the user to figure out what to include and what to ignore.  Sometimes that lets you do things, you otherwise would not be able to pull off.  In the general case, it's a PITA. 

Of course, it's easy enough to work around.  I have some of my own libraries I simply include in their entirety, because I'm working on a PC where my programs could fit in the level 1 cache. 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #490 on: December 19, 2022, 12:39:53 am »
Quote
These bit patterns can be emitted directly by the compiler without using an assembler.     

emitted how? By inline asm DC?
If the machine layer is not awere of them and they are emmited as "raw" data, then it's a trick

Sure it works, but it's an hack

Calling it a trick or a hack is silly.  I designed a bit slice processor as a DMA controller for an array processor (the supercomputer of the 70s).  I wanted to use some instructions that I created, which were not part of the assembler by default.  I added them.  QA didn't complain.  I just had to document it.


Quote
Does not pass QA
Makes ICE confused
Makes the source dirty
Makes the compiler unable to understand what's going on
Makes the source not portable
Opens doors to undefined run time behaviors

ICE???  If you need an ICE, your program is far too complex. 

You use a lot of nasty sounding adjectives.  Where have you been working, porn web sites?

If Forth is your compiler, it is entirely extensible, so there's no problem with it not "understanding". 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: A microcontroller programming language
« Reply #491 on: December 19, 2022, 01:41:20 am »
How long would it take, to create a Postscript system, complete with all its 400+ commands/instructions (an average of a byte or so, for each one), to fit into a single 512 byte sector?

I'm not suggesting to implement the graphics library! Just the programming language.

abs add aload and astore array begin bind cleartomark copy count cvi cvlit cvn cvs cvx def dict idiv dup end eq exch exit false for forall ge get gt if ifelse index known le length load loop lt mark mod mul ne neg or pop put repeat restore roll save string store sub true where xor { } [ ]

That should be a pretty good start. Could even leave some stuff out. I count 61 operators there. I'm assuming PostScript Level 1 memory management here, with mark/release style dynamic memory allocation (called save/restore in PostScript).

Quote
Also, I consider GhostScript, a rather unreliable and buggy way of trying the language out.  At least it (GhostScript) was (rather/very buggy), a long time ago.

GhostScript is used EVERYWHERE in the last 20 years. Sure, maybe it was buggy in 1988, but these days it's in the workflow of everyone's dot matrix printer drivers, millions of web sites converting various document types to and from PDF, and on and on.

No, it's not buggy, any more than any other software.
 
The following users thanked this post: MK14

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: A microcontroller programming language
« Reply #492 on: December 19, 2022, 01:44:53 am »
I don't know of any PostScript tools that are generally available for embedded systems.  Would using PS on an ARM with 16 kB of Flash even be possible?

Of course. Why not?  It's very similar in complexity to Forth, and much simpler than, say, Python or JavaScript, both of which have small microcontroller implementations.
 
The following users thanked this post: MK14

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #493 on: December 19, 2022, 02:25:27 am »
I don't know of any PostScript tools that are generally available for embedded systems.  Would using PS on an ARM with 16 kB of Flash even be possible?

Of course. Why not?  It's very similar in complexity to Forth, and much simpler than, say, Python or JavaScript, both of which have small microcontroller implementations.

If it's like Forth, then how is it different, better?

LOL!  Don't even compare Python to Forth. 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #494 on: December 19, 2022, 02:28:48 am »
Quote
PostScript works best in a non-interactive batch processing mode.

This is the exact opposite of Forth... well, I shouldn't say opposite.  Forth handles batch mode just fine.  But the interactivity of Forth is a powerful debugging technique. 
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Offline Sherlock HolmesTopic starter

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: A microcontroller programming language
« Reply #495 on: December 19, 2022, 02:34:09 am »
Probably the most fundamental criteria for a systems programming language to meet, is, "Can I write an operating system with it?".

This separates the men from the boys so to speak, if we look at historical delivered/shipped operating systems, then its a relatively short list.

So the primary goal of a new language, well suited for MCU development, is it be capable of serving as the optimal high level language just above the native machine's assembler, the ideal language for writing an operating system even, since many scenarios won't need or desire an OS to support them and must be able to implement core services directly.

What features would we insist upon for such a lofty goal? What are the non-negotiable features we'd need, for a language we'd rely on for writing an operating system on any modern MPU/MCU?



“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 
The following users thanked this post: MK14

Offline gnuarm

  • Super Contributor
  • ***
  • Posts: 2247
  • Country: pr
Re: A microcontroller programming language
« Reply #496 on: December 19, 2022, 03:58:56 am »
There are several different domains for operating systems, each very different.  The sort of OS that runs on a PC type computer is a totally different OS from what runs on a small MCU, if any OS at all! 

The sort of work I do doesn't even use an MCU for the most part.  I like parallelism, and that's just too much work on an MCU, so I use an inherently parallel language to write code that runs on the many processors available in FPGAs.  I'm not talking about CPU designs, I mean, the fact that every piece of logic is inherently a process.  Since they work in parallel, they are parallel processes. 

In VHDL this code is multiple processes.

Code: [Select]
  MCLK_Enable <= ( MCLK_Divide = 0 );
  BCLK_Enable <= ( BCLK_Divide = 0 );
  LRCK_Enable <= ( LRCK_Divide = 0 );

No OS required. 

In Forth the above could be...

Code: [Select]
: test ( MCLK_Divide, BCLK_Divide, LRCK_Divide -- MCLK_Enable, BCLK_Enable, LRCK_Enable)
  0= rot 0= rot 0= rot ;

Or maybe...

Code: [Select]
MCLK_Divide 0= rot DoSomethingMCLKWithTheResult
BCLK_Divide 0= rot DoSomethingBCLKWithTheResult
LRCK_Divide 0= rot DoSomethingLRCKWithTheResult

Not parallel processes.  So if timing of these calculations is important, you need a mechanism to synchronize with the timing cue.  That's in DoSomething...WithTheResult, etc.  But still no OS. 

Isn't hardware just so much easier?
Rick C.  --  Puerto Rico is not a country... It's part of the USA
  - Get 1,000 miles of free Supercharging
  - Tesla referral code - https://ts.la/richard11209
 
The following users thanked this post: MK14

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: A microcontroller programming language
« Reply #497 on: December 19, 2022, 04:16:58 am »
Quote

ICE???  If you need an ICE, your program is far too complex. 

You use a lot of nasty sounding adjectives.  Where have you been working, porn web sites?

 :-DD
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 4247
  • Country: gb
Re: A microcontroller programming language
« Reply #498 on: December 19, 2022, 04:28:42 am »
Quote
Calling it a trick or a hack is silly.  I designed a bit slice processor as a DMA controller for an array processor (the supercomputer of the 70s).  I wanted to use some instructions that I created, which were not part of the assembler by default.  I added them.  QA didn't complain.  I just had to document it.

Whatever, emitted how, so?
If it's inline asm DC. Then it's an hack.

Quote
QA didn't complain.  I just had to document it.

Doc is good but doesn't pay money.
Code rejected means no money.
« Last Edit: December 19, 2022, 04:36:05 am by DiTBho »
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Online brucehoult

  • Super Contributor
  • ***
  • Posts: 4538
  • Country: nz
Re: A microcontroller programming language
« Reply #499 on: December 19, 2022, 04:38:37 am »
Quote
PostScript works best in a non-interactive batch processing mode.

This is the exact opposite of Forth... well, I shouldn't say opposite.  Forth handles batch mode just fine.  But the interactivity of Forth is a powerful debugging technique.

EVERY programming language works better in non-interactive mode for large and complex programs.
 
It's not the opposite of Forth, it's similar to Forth except BETTER for interactive programming and debugging, because Postscript is late-binding by default. This means that you can define your words in any order, whether the words they use have been defined already or not, and you can re-define a word while debugging and existing words will automatically use the new definition.

This is not possible (or at least is not usually done) in address-threaded or subroutine-threaded Forth. It is more easily done in token-threaded Forth (the slowest implementation).

When speed is needed, individual functions or even bodies of IFs or loops can be early-bound (address-threaded, essentially)
 
The following users thanked this post: MK14, DiTBho


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf