User avatar
rpdom
Posts: 11865
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Sat Sep 30, 2017 9:41 am

RichardRussell wrote:
Sat Sep 30, 2017 9:22 am
DougieLawson wrote:
Sat Sep 30, 2017 8:49 am
Closest I got to that was the forerunner from the same stable - Acorn Atom BASIC.
That had indirection operators too, didn't it? I thought they were one of the features that got into BBC BASIC via Atom BASIC, certainly the BBC wouldn't have asked for them.
I believe you are right. The use of the BASIC indirection operators was expanded in the full BBC BASIC. I think that v2 had the string indirection which wasn't available in v1.

Memory indirection operators coupled with inline assembler made for some really handy features.

User avatar
DougieLawson
Posts: 30505
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Sat Sep 30, 2017 10:11 am

I never did much with the Atoms in BASIC, it wasn't my computer and we had a limited number of TVs in the house to use with our hardware (everything was using an RF modulator on Ch. 35 (no composite, no SCART, no HDMI back then)).

I spent a lot of time doing 6502 assembler on my M65. I did some assembler stuff on the Atom, because BASIC wasn't interesting enough.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

RichardRussell
Posts: 140
Joined: Thu Jun 21, 2012 10:48 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Sat Sep 30, 2017 10:19 am

rpdom wrote:
Sat Sep 30, 2017 9:41 am
I think that v2 had the string indirection which wasn't available in v1.
No, I'm pretty sure that string indirection ($var) was there from the beginning, using a CR terminator. I added the option to use NUL-terminated strings ($$var) which is very useful for interworking with C/C++ and Operating System APIs.

Richard.

User avatar
rpdom
Posts: 11865
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Sat Sep 30, 2017 10:27 am

RichardRussell wrote:
Sat Sep 30, 2017 10:19 am
rpdom wrote:
Sat Sep 30, 2017 9:41 am
I think that v2 had the string indirection which wasn't available in v1.
No, I'm pretty sure that string indirection ($var) was there from the beginning, using a CR terminator. I added the option to use NUL-terminated strings ($$var) which is very useful for interworking with C/C++ and Operating System APIs.
I'm probably misremembering.

There was definitely something that was different between the first BASIC version for the Beeb and the second version. I remember having to make allowances for it.

I did a lot of BASIC and assembler on the BBC and Archimedes in the 1980s.

I also used the X86 version on PCs and the RM Nimbus version for a while. Nice port :-)

RichardRussell
Posts: 140
Joined: Thu Jun 21, 2012 10:48 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Sat Sep 30, 2017 11:16 am

rpdom wrote:
Sat Sep 30, 2017 10:27 am
There was definitely something that was different between the first BASIC version for the Beeb and the second version. I remember having to make allowances for it.
My memory is also very vague. I know that the OPENUP and OSCLI keywords were introduced at that point, using tokens that had previously been spare, and there were some bug fixes.
I did a lot of BASIC and assembler on the BBC and Archimedes in the 1980s.
I wonder if anybody else still uses BBC BASIC as extensively as I do! When I set out to develop the Free-D² camera tracking system (which takes in a high-definition video signal from a tracking camera and analyses it in real time to calculate the poise) it never occurred to me to use anything else. It's true that there is some embedded assembler code for the first stage of the image analysis but most of it is interpreted BASIC, including all the calculations, on-screen annotation, GUI and communications to the Virtual Set rendering system.

There's a list of some of the more interesting applications of BBC BASIC, that I know about, here; I'm always interested to learn of others.
I also used the X86 version on PCs and the RM Nimbus version for a while. Nice port :-)
The Nimbus version was a joint effort between myself and RM. They wrote the MODE 7 code because their hardware was capable of a more accurate emulation than standard PC displays of the day.

Richard.

User avatar
rpdom
Posts: 11865
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Sat Sep 30, 2017 11:43 am

RichardRussell wrote:
Sat Sep 30, 2017 11:16 am
The Nimbus version was a joint effort between myself and RM. They wrote the MODE 7 code because their hardware was capable of a more accurate emulation than standard PC displays of the day.
Yes, it was the MODE 7 emulation that we needed in particular, as I was working on a Viewdata system. I visited RM in Oxford to test out the initial code until we got our own Nimbus to work on.

ebjoew
Posts: 13
Joined: Wed Jun 21, 2017 2:11 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Mon Oct 02, 2017 2:31 am

DougieLawson wrote:
Sat Sep 30, 2017 7:59 am
None of the the BASIC (it's an acronym for Beginners All-purpose Symbolic Instruction Code - so gets capitalised) versions I've ever used in the last 40 years have ever had any logical, bit manipulation instructions, you always had to do that stuff by hand. Closest we got back in the day was PEEK and POKE. On the ZX80 we used that to poke Z80 machine code into memory then call it with a USR command. To get the results you had to use PEEK. We were twiddling the bits in Z80 assembler.
I started writing my first computer programs in February of 1964 which was before BASIC had ever been successfully run on any machine anywhere. I never had a chance to play with BASIC until more than a decade after it existed. Doing most of my work on DEC PDP-8 minicomputers, we did have a similar language called FOCAL, but it lacked a character string data type. I knew of BASIC's existence on time share systems but I just did not have access to it myself.

My first real exposure to BASIC came when I helped my friend assemble his Altair 8800 kit in 1975. He bought the 4K Micro-Soft BASIC and later the 8K version. We spent plenty an evening writing BASIC programs for that machine. I was impressed right at the start that Gates, Allen, and Davidoff had cleverly arranged the AND, OR, XOR, and NOT operators such that they could serve both as bit-oriented operators as well as logical operators. I have often wondered if they stole that idea from someone else or it was their original design.

I programmed professionally for a little more than 43 years from October of 1967 to the end of 2010. As often as that Beginners All-purpose Symbolic Instruction Code acronym is referenced nowadays, I seem to remember a brief time when BASIC first appeared when people were still trying to think of such a phrase. I would suggest that the name BASIC came first and then the famous words came later so it did not really begin as an acronym. This was the first time that I have ever had anybody get upset enough about my use of mixed case to make a point of "correcting" me about it. Still, when posting on this forum, I shall try to remember to use all caps when writing the word BASIC.

By the way, what I meant about RTB and FUZE BASIC not being able to input data from an image file because it contains binary data is that RTB and FUZE BASIC both lack any kind of file input command that can pull a character at a time from the input file regardless of its character code. Binary data files can contain any character code from 0 to 255 (decimal) so any processing normally associated with handling text files can interfere with that. Things like terminating on or ignoring a NUL, ignoring Line Feed, terminating on Carriage Return, terminating on comma, and other special responses to other control characters must be avoided when trying to read a binary file.

I was pleased to find that BBC BASIC provides its BGET# function which performs the appropriate needed file reading action suitable for reading data files containing binary data.

ebjoew
Posts: 13
Joined: Wed Jun 21, 2017 2:11 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Mon Oct 02, 2017 2:39 am

RichardRussell wrote:
Sat Sep 30, 2017 8:23 am
Just one word of caution. BBC BASIC for Raspbian is based on SDL 2.0 (the Simple Directmedia Layer) which uses OpenGL for rendering. By default OpenGL is software-emulated on the Raspberry Pi and there is a serious bug in this emulation in Raspbian Stretch which, amongst other things, results in it running so slowly that BBC BASIC is unusable. Fortunately this can easily be addressed by enabling the 'experimental GL Driver' in raspi-config, but I understand that currently this driver is incompatible with the camera module.

So if you want to use BBC BASIC in conjunction with the camera module you may be unable to upgrade to Stretch until this issue is resolved.
Thank you very much for the heads up, Richard. :)

Heater
Posts: 8157
Joined: Tue Jul 17, 2012 3:02 pm

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Mon Oct 02, 2017 3:26 am

ebjoew,
...had cleverly arranged the AND, OR, XOR, and NOT operators such that they could serve both as bit-oriented operators as well as logical operators. I have often wondered if they stole that idea from someone else or it was their original design.
Surely that is not a clever idea to be invented or stolen from elsewhere. It's just the simplest thing to do.

When you do AND, OR, XOR, NOT, etc in machine code you may get a result of zero. Or perhaps not. The machine does not care if you are thinking of that as bit wise or other logical operation.

I was first introduced to programming in BASIC in 1974. I was over the moon to get the chance to learn some programming. Using a teletype connected to some mainframe far away that I never saw.

Luckily we were also taught assembler level programming in that technical school. Within weeks realized how limited and useless BASIC is.

ebjoew
Posts: 13
Joined: Wed Jun 21, 2017 2:11 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Mon Oct 02, 2017 7:14 am

Heater wrote:
Mon Oct 02, 2017 3:26 am
...had cleverly arranged the AND, OR, XOR, and NOT operators such that they could serve both as bit-oriented operators as well as logical operators. I have often wondered if they stole that idea from someone else or it was their original design.
Surely that is not a clever idea to be invented or stolen from elsewhere. It's just the simplest thing to do.
I am sure in your lengthy experience that you have seen languages where the bit-oriented operations and the logical operations are performed by separate operators. A system that permits the same operators to serve both needs is not so obvious to many.

Of course, any idea seems simple when understood. And while the concept may seem quite obvious to you, not everybody would think so.

I remember clearly over the years how many people would argue that a statement such as the following one should print 1 for TRUE instead of -1:

Code: Select all

PRINT 3 > 2
But having -1 be the result is required if the AND, OR, XOR, and NOT operators are to serve both purposes. I am sure that you easily see the reason why.
Heater wrote:
Mon Oct 02, 2017 3:26 am
I was first introduced to programming in BASIC in 1974. I was over the moon to get the chance to learn some programming. Using a teletype connected to some mainframe far away that I never saw.

Luckily we were also taught assembler level programming in that technical school. Within weeks realized how limited and useless BASIC is.

I first learned assembly language for a strange little computer with 10-bit words in a military technical school when I was 18 and another assembly language for an IBM 1620 computer which had 5-bit memory cells (plus 1 bit parity) in a college course the following year. I learned both of those before I ever saw any high level language on any machine. To this day, I still enjoy and use assembly language on occasion and while BASIC is not as fast as assembly language I find it to be far from useless.

By the way, the IBM 1620 instruction set was organized unlike anything running today. It was carefully designed to get the most capability from the least amount of hardware. It was all built with discrete components and did not use any integrated circuits. Still, it could easily add two numbers together of, for example, 1000 decimal digits each and produce the result with a single assembly language instruction. Likewise, it could multiply those same two numbers together with a single assembly language instruction producing the 2000 digit result. Amazingly, the machine did not even contain an adder circuit. For a chuckle sometime, check out the phrase that its engineers assigned to its development code name, CADET.

User avatar
gordon@drogon.net
Posts: 1975
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Mon Oct 02, 2017 8:58 am

DougieLawson wrote:
Sat Sep 30, 2017 7:59 am
ebjoew wrote:
Sat Sep 30, 2017 6:00 am
Having checked out the data file input capabilities of both RTB and FUZE Basic [sic], I found that it seems they are not really capable of reading binary data which would appear in an image file. Just as I was determining that RTB and FUZE Basic [sic] would not likely be able to serve my needs, I discovered an entirely different Basic [sic] language implementation that has been made available on the RPi, namely BBC Basic [sic]. For a short time, I was looking at using BBC Basic [sic] under RISC OS but there seems to be no support for the Pi Camera under RISC OS. Then I learned that BBC Basic [sic] has fairly recently been ported to Raspbian Jessie. Of course, Raspbian Jessie does include support for the Pi Camera.
There are no surprises there. None of the the BASIC (it's an acronym for Beginners All-purpose Symbolic Instruction Code - so gets capitalised) versions I've ever used in the last 40 years have ever had any logical, bit manipulation instructions, you always had to do that stuff by hand. Closest we got back in the day was PEEK and POKE. On the ZX80 we used that to poke Z80 machine code into memory then call it with a USR command. To get the results you had to use PEEK. We were twiddling the bits in Z80 assembler.
RTB supports bit-wise logical operations:

Code: Select all

  print 1 | 2
  3
  print 1 << 5
  32
  print 2^64 >> 63
  1
however it's really nothing more than "just because it can". Internally, all numbers in RTB are 64-bit double precision floating point numbers. There is no separate integer support. similarly there is no peek and poke (or any equivalents) simply because it's designed to run under a modern OS and not the old 8-bit systems of times gone by. (And no call/usr nor inline assembler as it runs under x86 system as well as ARM)

Reading a file byte at a time - nope. Mostly because no-one ever asked me for it and I have no use for it in my early systems where I was doing line at a time type processing in it. Could I add in a get# command? Sure - it's 2 minutes work. Shall I? Similarly for the Pi camera - you can use RTB to take pictures via the system() command - but what can you then do with the image files? You can display them in RTB look at the loadImage commands. Manipulation of a JPG file at the byte level is virtually impossible though as there are no byte-access commands. It would also be terribly slow (but that's not stopped people in the past!) And you can always system() out to mogrify, (imagemagic), etc.

-Gordon
--
Gordons projects: https://projects.drogon.net/

RichardRussell
Posts: 140
Joined: Thu Jun 21, 2012 10:48 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Mon Oct 02, 2017 11:44 am

gordon@drogon.net wrote:
Mon Oct 02, 2017 8:58 am
Reading a file byte at a time - nope.
BBC BASIC has always had the reputation for being a 'bit twiddlers' language, right back to the original version in 1981. Support for reading and writing files one byte at a time, indirection operators and the integral assembler are all designed to make it possible to do 'anything', even low-level operations that BASICs aren't traditionally good at.

The BBC can't take the credit for that: their requirements specification for the language didn't include such low-level operations. Rather, BBC BASIC inherited them from the earlier Atom BASIC (and it was very much part of the Acorn 'culture' at the time). Acorn should also be thanked for having the foresight to make BBC BASIC's integers 32-bits, at a time when almost all home-computer BASICs used 16-bit integers (and only 8-bit microprocessors were in use). It's primarily for that reason that the language today (for example in the form of BBC BASIC for Windows or BBC BASIC for SDL 2.0) retains such a remarkable degree of compatibility with the original when running on 32-bit or 64-bit OSes.

The current editions of the language have been extended to support 64-bit integers and 64-bit floats (80-bit floats in the case of the x86 versions), and have gained many other 'modern' features like structures, but this has been achieved in a way that retains compatibility.

Richard.

ebjoew
Posts: 13
Joined: Wed Jun 21, 2017 2:11 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Tue Oct 03, 2017 7:33 am

In my application, the only real need for any binary processing is with regard to reading the bytes of the input file which is a binary file. It is a YUV format file derived from the PiCamera.

The values of interest in the file are luminance Y values only. I am not interested in the color (U & V) values in this application.

The application will search for the brightest pixel and the relatively bright pixels that surround it. Once it has been located, the brightness, location, and size of this bright spot will be saved away. Then the search will be repeated for the entire image but ignoring the bright spot already identified. Again, the data for the next identified spot will be stored away. This will be repeated until the brightest remaining pixel found is lower in luminance that some specified limit.

The results that are reduced from the image will be a list of bright spots in the image, their locations in the image, and their approximate areas.

By the nature of the source of these images, although possible, there will normally not likely be more than about 6 bright spots to be found, usually fewer than 5. In general, the images will be quite dark with a few bright spots in them.

Later in the project, the image processing may include a preprocessing step involving the subtraction of one image from another.

RichardRussell
Posts: 140
Joined: Thu Jun 21, 2012 10:48 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Tue Oct 03, 2017 8:14 am

ebjoew wrote:
Tue Oct 03, 2017 7:33 am
The application will search for the brightest pixel and the relatively bright pixels that surround it...
Is interpreted BASIC going to be fast enough for this? In my similar application (I run multiple 2-dimensional running-average-filters over the image to identify markers) that's the one thing that is done in assembler code.

Richard.

ebjoew
Posts: 13
Joined: Wed Jun 21, 2017 2:11 am

Re: Porting ARM BASIC to the Raspberry Pi via SDL 2.0

Tue Oct 03, 2017 3:47 pm

RichardRussell wrote:
Tue Oct 03, 2017 8:14 am
ebjoew wrote:
Tue Oct 03, 2017 7:33 am
The application will search for the brightest pixel and the relatively bright pixels that surround it...
Is interpreted BASIC going to be fast enough for this? In my similar application (I run multiple 2-dimensional running-average-filters over the image to identify markers) that's the one thing that is done in assembler code.

Richard.
Yes, it will be fast enough. At this point, my project is in its proof-of-concept phase. Speed is not important. What matters most now is the ease with which algorithms can be explored and changed. When things have settled down, there will likely be a time in the future when speed becomes important. That is when assembly language or some compiled language make play a part.

By the way, an interpreted language that I worked on many years ago had an EVAL() function similar to the one in BBC BASIC which parsed and evaluated a string argument as an expression. It also had an EXEC() function that parsed and executed a string argument as a statement. They were fun to use sometimes.

Joe

Return to “Other languages”

Who is online

Users browsing this forum: No registered users and 5 guests