dimanche 9 juillet 2023

BASIC-52

It's been a few months now since I subscribed to the Facebook group 'minimalist computing'. Personally, I believe more in this theme than in free software.

Why that? Because in absolute terms, free labor cannot exist. Whoever spends time studying a solution rather than cultivating his garden can only meet his basic needs through the intermediary of a a currency of exchange that he will have acquired thanks to his study and with which he will be able to obtain what he needs with people who specialize in this type of service :food; clothing; health etc. .

For me, there are three types of services:

  • Paid services at very high cost.
  • So-called 'free' services.
  • The 'intermediate' services at an 'affordable' displayed cost.

What do i mean?

As everyone knows, 'when the service is free, then you are the product'.


This is understandable when it comes to the sale of finished goods, but what about when it comes to services?
In fact, it is very simple. This involves considering the product in terms of a service (the IT solution), but also the resources needed to set up this service. 

From here, the three possibilities mentioned at the beginning of the post emerge.
  • The services or solutions that you will pay a high price for, will allow you to really improve your productivity. Quite simply by interfacing with a complex system by offering you a simple method of accessing it. You can then imagine creating your 'own' business because this interface will take care of all the aspects that are not the responsibility of the business application you want to develop. So you can focus on YOUR real work.
  • The so-called free services. Well they don't exist. In this type of business, you will often find the resources in open access. But the other part will be a mountain of documentation, very often disparate, erroneous or even contradictory. As your project evolves, you will be forced to find human resources who can handle different aspects that you did not originally foresee, as well as many other problems.
  • And finally the "intermediate" services which bring together aspects of the two previous offers. Namely that you will be led to finance applications at a certain price, supposed to provide you with simplified access services to what you wish to develop, but which will be voluntarily so disparate, so poorly documented, so unmanageable that in the end, you will still have to create a team to study your project.
To image everything, the first type of service will provide you with CAD software, for example, which will allow you, after having studied it, to easily develop mechanical parts, for example. The entry parameters in the business are simple: the price of the solution and the time you need to understand it. If you are an experienced person, you will be able to assess the situation.

The second type of service, the free one, is also very simple: You are in front of the Himalayas, you are not a mountaineer at all and you want to go to the top. Basically you want to create something around Linux, because it's free: good joke! The Sherpa will know how to be paid dearly for his help. In this case, it's very simple, you are good for the asylum. But there are people who are motivated by the impossible, even in full consciousness, so...

And the third solution: the most cynical. Yes, because it will make you believe that by paying for an environment that is not very expensive, you will get the expected service. Of course, for me, excellence in this area is Microsoft. You will pay for a solution, which will quickly lead you to see that your project cannot be built and will require you to form a team of experts. 

Whereas in the two previous solutions you can 'play' in full consciousness, i.e. you pay dearly and possibly you even take credit for it, but there is a strong probability that you will reach the end, or else you will not pay nothing, but you're young, have a lot of time to waste and are ready to live 10 years with pizzas...

...as much in the third solution, the worst, you pay, with your savings, you are forced to surround yourself as your project evolves, and you realize that in fact you will never deliver the customer on time because everything is done so that you cannot assess the workload required to develop your solution. In fact, it's the best business tactic to nip any possibility of competition in the bud. microsoft is not the only one to work in this way. In general, all the companies at the top of the Nasdaq operate like that: smoking and 'easy' access to the offer, then, when the fish has bitten, we strike and there, it's dead. Either you pay if you can afford it, or you die. Usually you die. The American way actually...

So... Arrived here, what solution is offered to you if you want to develop something? I would say, a key word: simplicity.

Back to basics, ie using simple but effective technologies that you can easily master on your own and whose cost, in terms of learning time or money invested, remains within the realm of reasonableness. Reason why I appreciate the notion of minimalist computing. This is also the reason why working this way is for many, working the way of the 80s.

I wrote well to work "the way of"... Because with the systems accessible today, the performances have nothing to do with those of the 80s. For example I am currently working with a small RISC-V microcontroller 32 bit at 144MHz. How does that compare to a microcontroller from the 80s, like the 8031 ​​for example, delivering a painful 1Mips at 11MHz?

And I come to the 'profound' reason for this post. Namely the implementation of the basic 8052 on a fast microcontroller. In fact I already made this type of implementation in the early 90s on a Dallas DS80C320 processor. This processor is about three times faster than an 8031 ​​at the same frequency, and is able to run at 33MHz, which results in nearly 10 times faster than an original 8031 i.e. the equivalent of a basic 8031 ​​but at 100MHz

'What the fuck'? Today, an 80C320 at Mouser is $20.62 : oh my god!!!

STC, a Chinese company, manufactures 8031-type microcontrollers with 1T architecture, ie the majority of instructions are executed in 1 or 2 clock cycles. That is twice as fast as the DS80C320. It is capable of running at 33MHz, the equivalent of a basic 8031 ​​but here at 400MHz, and can be found for around $1.30. 

Okay, 400MHz is an impressive number, but that's just to give a clock comparison to the original 8031. If you divide 400 by 12, you get about 33MIPS. Inevitably, almost 1 MIPS per MHz, at 33MHz, that gives 33MIPS. To be realistic, it's probably less than that since some of the instructions are executed in 2 clock cycles.

It should be checked at runtime, but let's expect 20MIPS at 33MHz, this gives a basic interpreter 20 times faster. This is not nothing, knowing that the BASIC-52 interpreter already works well on a standard 8031. Hence the temptation to implement BASIC-52 on this STC processor, in this case an STC12C5A60S2.

Yes, because it's much more fun to go on this kind of adventure than to spend hours looking at uninteresting Facebook pages!

So why this particular STC12C5A60S2. 

  • Because it contains onboard flash.
  • Because it contains on-board RAM.
  • Because you can find cheap development boards.
  • Because it is programmed very easily by its serial port n°1, thanks to the software available from STC.

The dev board ordered.


The dev board received & the Dallas DS80C320


The programing software


All this to get to this:


The previous image would try to think it works. In a sense yes. In fact, I have a problem accessing the RAM memory. I cannot record Basic lines. The input goes well but the LIST statement does not list anything. I can no longer assign a value to a variable. I clearly have a memory access problem.

However the interpreter starts well, tests the available memory well and moreover displays it correctly. The interpreter requires 1KB to run, which it is. I haven't researched the problem yet.

Because the objective of this Sunday afternoon was simply to see if I could establish a connection with the interpreter on an 8031-type microcontroller, which therefore does not have all the resources of an 8052-type component.

But STC had the good idea to propose a baud rate generator instead of the timer n°2 only present in the 8052 type components. It was therefore enough to code the initialization of this generator in the source code of the version 1.3 of the Basic interpreter to successfully establish the connection and see that it works.

What else needs to be done to make it work well. And well find the reason why the RAM is inaccessible. I haven't looked in detail at the changes that were made to version 1.3 of the Basic-52. I know that there is a detection of the type of processor that I removed to have the place to put my initialization code of the Baud Rate generator. I suspect 'stuff' must be happening in this piece of code.

If I can determine the problem, I will also have to review the EPROM programming instructions. Because in fact I intend to make a small card equipped with a FRAM type memory. In this case, only the EPROM 'type' memory transfer instructions would have to be kept.

In short, it's a fun little subject for Sunday afternoons. Despite the 'fun' aspect of what I have just described, this system, which I could operate at 33MHz, could provide very good performance while offering disconcerting ease of access both in terms of financial cost and knowledge term. That's what I call the fourth way!

The fourth way : financially affordable, easy to use, very good performance, very good durability.