BASAL, an Italian structured BASIC for the VIC

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
orion70
VICtalian
Posts: 4337
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

BASAL, an Italian structured BASIC for the VIC

Post by orion70 »

Hello everybody. Browsing the invaluable pages of an old glorious Italian magazine, I came across this article.

It's about a structured language for the Commodore VIC-20, which is possibly our own Waterloo (maybe we could name it Caporetto Structured BASIC 8)). It's in Italian, but the article was OCRed so you can translate it with Google. There are also scans of the original pages.. See if it can be of any interest!
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASAL, an Italian structured BASIC for the VIC

Post by Mike »

Hi, Alessandro!

I took a look into the article's pages. Unfortunately, the listing is reproduced with barely legible letters, IMO a reconstruction is not possible from those.

From what I could gather from the program structure and the REM statements, BASAL 2.1 only implements a small subset of BASIC-like instructions, with a focus on structured language elements, of course. There are INPUT and PRINT for simple I/O; numeric expressions must only contain a single operator. The implementation includes an editor, and it can save and load the programs.

There's a pre-compilation step which, I presume, works through the 'source code' (contained in a string array) to work out all jump targets corresponding to the relevant block, branch, loop, and subroutine-call structures.

Edit: at first, I thought the used techniques, and the implementation to be more similar to the CAL 'compiler' I once wrote in 1985 and unearthed two years ago. And unlike Waterloo BASIC, which is written in machine language, and adds itself as extension to the built-in CBM BASIC.

However, I now think it works more like a pre-compiler, which produces working BASIC programs from the BASAL source code, replacing the structured language elements with the standard constructs of BASIC. Which actually means, that the severe restrictions I hinted at above are non-existent (and were mostly motivated by the simple examples).

A similar pre-compiler had also been published in a German computer magazine (64'er). I'll take a look at that one tomorrow.

Edit 2: It's here, 'Precompiler' in 64'er Issue 12/86 (64'er online issues of 1986). For C64 only, though (main program is in BASIC, but there's also a support library in machine language, which would need to be ported). The *.pdf is ~80 MB in size.

Greetings,

Michael
User avatar
orion70
VICtalian
Posts: 4337
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: BASAL, an Italian structured BASIC for the VIC

Post by orion70 »

Thanks Mike.
Mike wrote:I took a look into the article's pages. Unfortunately, the listing is reproduced with barely legible letters, IMO a reconstruction is not possible from those.
Fully readable article in Issuu HERE :)
Mike wrote:However, I now think it works more like a pre-compiler, which produces working BASIC programs from the BASAL source code, replacing the structured language elements with the standard constructs of BASIC. Which actually means, that the severe restrictions I hinted at above are non-existent (and were mostly motivated by the simple examples).
Sounds nice. Impressive how deep you could go with 8-bits, if you really wanted to learn seriously from your micro.
Mike wrote:Edit 2: It's here, 'Precompiler' in 64'er Issue 12/86 (64'er online issues of 1986). For C64 only, though (main program is in BASIC, but there's also a support library in machine language, which would need to be ported). The *.pdf is ~80 MB in size.
Nice, thank you!
User avatar
highinfidelity
Vic 20 Nerd
Posts: 644
Joined: Thu Jul 28, 2011 2:34 am
Website: http://www.hirtel.it
Location: Torino, Italy.

Re: BASAL, an Italian structured BASIC for the VIC

Post by highinfidelity »

I completely misunderstood the point at first: I thought that a programming language in italian was discussed in the article. A sort of BASIC with statements like STAMPA instead of PRINT, CARICA instead of LOAD and so on. Washed-in-Arno basic... :mrgreen:

I never really got the point of structured/unstructured programming and the VIC. AFAIK the point of structured programming is avoiding unconditioned jumps, which seems always possible with the VIC as far as the GOTO instrucion is used in conjunction with a logical IF THEN. Can someone briefly expand the issue? :|
GOD is REAL. Unless declared DOUBLE PRECISION.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASAL, an Italian structured BASIC for the VIC

Post by Mike »

highinfidelity wrote:Can someone briefly expand the issue? :|
Well, Structured Programming claims that every algorithm known to mankind (and other species) can be expressed using only those three constructs: sequence, selection and loops.

BASIC V2 has no actual language element to delimit blocks, IF ... THEN and ON ... GOTO/GOSUB are the only two selection statements available and loops need to be made from FOR ... NEXT statements or (gosh!) GOTOs.

The main problem with GOTOs is not the (unconditional) jump itself, it's the labels. When you see a label inside a program - and with BASIC V2 each line number is a label - you can't know (by just a quick look) from where program flow could be directed to it! A similar problem is the scoping of variables. When all variables are global, they can be changed everywhere in a program, so you don't have any idea how the data 'flows'.

Structured Programming limits that confusion by providing clear pathways where program flow and data flow happens.
User avatar
highinfidelity
Vic 20 Nerd
Posts: 644
Joined: Thu Jul 28, 2011 2:34 am
Website: http://www.hirtel.it
Location: Torino, Italy.

Re: BASAL, an Italian structured BASIC for the VIC

Post by highinfidelity »

I didn't get exactly the point concerning the global variables, but thanks for expanding the problem.

It still seems to me, however, a question of abstract philosophy. A "my programming language is superior to yours" matter.

As deep as I can think about it, I see no difference between a DO loop (even worse a DO WHILE) and a FOR NEXT, or even a hand-written loop where a variable value is incremented each step and the loop is controlled by a IF THEN GOTO conditional jump that leads back to the beginning of the cycle. Actually, AFAIK it's exactly what DO and DO WHILE loops do: the END statament performs an implicit logical IF on the variable which is being incremented at each loop.

The fact that a "structured" programming language can be implemented using standard basic instructions (as done with BASAL) seems to confirm that there is no real, substantial difference between the two languages, as one is built using the statements set of the other. So, at best, structured languages allow a quicker, easier, more straightforward, more compact, more elegant programming, but don't really do things that can't be programmed in BASIC (even avoiding unconditional jumps).

Also, knowing by a quick look from where the program may flow to a specific label is mostly a matter of the programmer's ability IMHO. There are BASIC programs that would mostly need no line numbering at all, while I see every day programs written in structured languages that are so complex and involuted that require way much more than a quick look, only to barely understand their task.

So, in the end, is it just a question of elegance?
GOD is REAL. Unless declared DOUBLE PRECISION.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASAL, an Italian structured BASIC for the VIC

Post by Mike »

highinfidelity wrote:The fact that a "structured" programming language can be implemented using standard basic instructions (as done with BASAL) seems to confirm that there is no real, substantial difference between the two languages, [...]
Beyond a certain point of expressiveness, *all* usable programming languages are equivalent.

The people studying theoretical computer science (or mathematical logic) will tell you, that this is the case, as soon primitive-recursive functions can be written and the µ-operator can be applied to those functions. The languages differ though in their standard uses.

BASIC is a great language to get go learning what programming a computer is about. It's easy to write a simple program, test, run and debug it. It's not as good, when the program code size grows beyond a certain threshold. There's no good support for data types beyond those built-in - floats, integers, strings and (multidimensional) arrays of those -, missing are compound types like structs and unions, lists, trees. There are no common language elements (i.e. across the different dialects) to represent a reusable group of statements as a procedure or function - with the exception of GOSUB and DEF FN.

All those 'missing' language constructs can still be implemented by rather elaborate code. But then, it costs more thought, it could be done wrong. Then it might make more sense, to use a language where all those language constructs necessary to write really big programs are already there.

Like C. :mrgreen:
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: BASAL, an Italian structured BASIC for the VIC

Post by groepaz »

The fact that a "structured" programming language can be implemented using standard basic instructions (as done with BASAL) seems to confirm that there is no real, substantial difference between the two languages, as one is built using the statements set of the other.
by that logic there is no substantial difference between simons basic and assembler. *shrug*
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
highinfidelity
Vic 20 Nerd
Posts: 644
Joined: Thu Jul 28, 2011 2:34 am
Website: http://www.hirtel.it
Location: Torino, Italy.

Re: BASAL, an Italian structured BASIC for the VIC

Post by highinfidelity »

groepaz wrote:by that logic there is no substantial difference between simons basic and assembler. *shrug*
Well, to some extent. Your example was quite extreme, and it also compared a lower-level programming language to a higher-level one, but very roughly that was my point.

If science divides the Fungi Kingdom by (say) the Animal Kingdom, it is because in the world there are things which are fungi and things which are not fungi. Can you build up an amanita (fungus) by piling up many rabbits (non fungus)? No way. They're different things that belong to different Kingdoms.

Many informaticians talk about structured languages as they were another world compared to non-structured languages. But indeed, as we saw, structured languages can be build up with non-structured languages; and mostly those languages that are commonly referred to as "non-structured languages" allow structured programming nonetheless. So they're not "intrinsically different things", "one the negation of the other". Which was the point that I was trying to understand.

Perhaps the two cathegories should have been named, more properly, "highly structured" and "lightly or partly structured" languages, or anything similar.
GOD is REAL. Unless declared DOUBLE PRECISION.
musuruan
Vic 20 Newbie
Posts: 6
Joined: Sun Feb 09, 2020 5:22 am

Re: BASAL, an Italian structured BASIC for the VIC

Post by musuruan »

I scanned the listing from my own issue of MC22, OCR'ed and proofread it. It is available here:
https://github.com/musuruan/MCmicrocomp ... ster/mc022
DarwinNE
Vic 20 Devotee
Posts: 231
Joined: Tue Sep 04, 2018 2:40 am
Website: http://davbucci.chez-alice.fr
Location: Grenoble - France

Re: BASAL, an Italian structured BASIC for the VIC

Post by DarwinNE »

I remember that language, I wanted to try it, but I was scared about the typing and the inevitabile errors... :D

Andrea De Prisco is still online, from time to time. Orion70, did you try to contact him?
User avatar
orion70
VICtalian
Posts: 4337
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: BASAL, an Italian structured BASIC for the VIC

Post by orion70 »

I once wrote to him asking for the cassettes of MC games and programs. He was so kind to answer promptly, but unfortunately he no longer had any hard copy of those programs.

Musuruan is doing a great job retrieving all the published material, typing it in, debugging, and giving it for free to the community. Maybe Andrea de Prisco should consider the possibility to publish finished, polished programs in his website dedicated to MC Microcomputer - with Musuruan's permission of course.

Also, I did regret with him for my lack of time to help in this project.
DarwinNE
Vic 20 Devotee
Posts: 231
Joined: Tue Sep 04, 2018 2:40 am
Website: http://davbucci.chez-alice.fr
Location: Grenoble - France

Re: BASAL, an Italian structured BASIC for the VIC

Post by DarwinNE »

It was a sheer pleasure to play with BASAL for a while on the emulator, thanks to the work of musuruan!
I think I will try for a longer run on the real hardware, it will be fun.

I'm sure Andrea would be pleased to see that his work is still gathering interest.
Post Reply