BASIC

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: BASIC

Post by marcelk »

Halfway there after 1 day of hacking:

IMG_3823.jpg
IMG_3823.jpg (132.49 KiB) Viewed 6207 times

To be continued... It might fit well within 2K.
xopr
Posts: 21
Joined: 05 Jun 2018, 12:05

Re: BASIC

Post by xopr »

That is just plain awesome!
I can't believe the amount of progress on BASIC, especially since I'm trying to pick up the (native) assembly in an emulator (with a hacky debugger); All I got was a blinky LED using nested loops :D

I'm looking forward to try this. Great work, Marcel!
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: BASIC

Post by marcelk »

Thanks!! I just set out to study the various Tiny BASIC articles and sources yesterday morning, and this is what I had going by the end of that same day. The code started used WozMon as a stepping stone. It is all GCL/vCPU, not native Gigatron assembly. I'm loosely following Tom Pittman's implementation, but I'm not transcribing it literally. For example I don't add another VM for his IL language to the package. It is merely a rewrite of his IL code and interpreter as GCL/vCPU functions, reshaping as I see fit. It will be a limited BASIC but somewhat expandable. It will be slow, not tokenised. I estimate it could handle programs of up to 200-300 (short) lines on the 32K system. I see no reason why it wouldn't be usable within a week, or end of this month latest. Doing the second half always takes 80% of the time...
Marko
Posts: 8
Joined: 24 May 2018, 19:48

Re: BASIC

Post by Marko »

Happy 552-month birthday ;)

Seriously, that's awesome to see running!
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: BASIC

Post by marcelk »

90% done, we have these now:

LET A..Z = ( + - * / )
IF < > = <= >= <> THEN
PRINT
GOTO
GOSUB RETURN
RUN END
LIST NEW

Still missing: INPUT, PEEK/POKE etc.

Programs can be a bit over 300 lines of up to 24 characters each including line number (might become 25). Insert and delete of lines works as expected. Break with the [Delete] key. You might need to hit it a couple of times. Break works in programs and also in LIST.


IMG_3829.jpg
IMG_3829.jpg (126.4 KiB) Viewed 6152 times

Still under 2K bytes, but maybe not for long.
And oh, compared to Tiny BASIC, GCL/vCPU is a speed demon...

Now the remaining 90% needs to be done :D
Attachments
TinyBASIC.gt1
(1.89 KiB) Downloaded 257 times
TinyBASIC.gt1
Work in progress
(1.89 KiB) Downloaded 248 times
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: BASIC

Post by at67 »

I've had a play with this and it's pretty awesome, once Peek and Poke are in, you'll pretty much be able to fully control the Gigatron from Basic.

A couple of things:

1: The immediate commands, (list, run, etc), are usable in code; which is very cool. Using run to loop back to the start of your code for tight loop scenarios to avoid the goto search/calculation could become a thing.

2: Break doesn't work on the input command, so you are stuck and need to perform a reset, if you have a print in your loop and are quick you can break, but I think input needs to poll for the break.

P.S. You somehow need to get a load/save in there without Arduino or extra hardware; I contemplated using software and the audio out to emulate ye-ole audio cassette interface, (with either a real cassette recorder or audio in/out on a PC with some software pretending to be a cassette recorder); but I can't see a way of getting the audio back into the Gigatron without extra hardware :/
monsonite
Posts: 101
Joined: 17 May 2018, 07:17

Re: BASIC

Post by monsonite »

Marcel,

Firstly, congratulations in making so much progress with TinyBASIC in such a short time.

Secondly, in response to at67's suggestion of a cassette interface, I recently came across a technique where the PC (or tablet or phone) audio output is used to create a synchronous serial output, not dissimilar to the SCK and MOSI signals used to drive the ATtiny or even the 74HCT595 input shift register.

One channel creates the serial data and the other creates the clock. The audio could be passed into a simple high gain amplifier or schmidt buffer to provide a clan square wave output that is then use to load bytes into the 74HCT595 shift register.

The information is on this German site - called Cheepit Sparrow http://tiny.systems/article/soundProgrammer.html

They have an application called soundUART, and also a utility to convert a hex file into an audio output.

For the audio output from the Gigatron, perhaps a more familiar Kansas cassette format would be appropriate - and simpler. As it is unlikely that an actual cassette recorder is going to be used - with all processing done in a PC - there is no reason why the tape out and tape in signals need to be the same audio format.



Ken
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: BASIC

Post by marcelk »

Lots of functionality in 1/3rd the space of my 64x64 pixel avatar :lol:. The structure seems sound. There is tons of stuff on the to do list, but that's for a next coding streak.

INPUT uses the expression parser! I thought that is cool because you can type 1+2*34. You can also type the name of the input variable itself, displayed in the prompt, if you want to keep its old value. That in turn means you can break by entering an invalid expression. And.. an empty line is an invalid expression, so a bare ENTER will break out of the program. I just found that out, it is not on purpose... It doesn't even say what line number it was at, I can imagine that can be very annoying, but I see no easy way to fix that yet. Many such things need a bit of polishing. For example, INPUT also doesn't accept leading spaces.

PEEK/POKE are high on the list. One of the implementations provide these through USR calls. I think I prefer keywords. Being tiny is not a goal in itself.

[ About stand-alone loading/saving: we should start another forum topic on that. One idea long on our list is to look at battery backup. Somebody suggested to look at the DS1210 Nonvolatile Control Chip to keep RAM contents alive. In combination with 64KB we have a RAM disk? ]
Attachments
TinyBASIC.gt1
Feature complete
(1.96 KiB) Downloaded 280 times
WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: BASIC

Post by WattSekunde »

A big Wow! That looks so cute ;-).


But I couldn't upload the last TinyBASIC.gt1 file. Your older upload will load. I have the same trouble with frogstroll and sometimes also with my own gt1 compilations. Minor changes in the code size always get it work again. But I haven't investigated it deeper yet.
Maybe it has something todo with the arduino micro code. As you know :) the loader shows transfered memory segments as green colored blocks on a red line with a white pixel at the end.
But in the faulty case there are no white end. The loading goes on forever and the Terminal says Timeout error (no data). After this I have to manually reset the Arduino to get any new data transfer. Any quick Idea?
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

Re: BASIC

Post by marcelk »

It smells like an Arduino Micro-specific issue? "Timeout error (no data)" means the PC doesn't get a reply from the microcontroller within 5 secs. I don't have a Arduino Micro to test with. You can try lower transfer speeds (they are hardcoded on both ends)? You can try the PROGMEM[] method? I just pushed the TinyBASIC.h file for that in Utils/BabelFish/. That will certainly work, but is not a solution.

One thing I can *speculate* is that the different Arduino platforms do serial communication differently. If that is the case, the Arduino Micro the *might* get disturbed by certain data bytes? That is something that would correlate with larger files, and with small but specific files. Does the Micro happen to implement serial flow control (XON/XOFF, decimal 17/19)? The Arduino Uno certainly doesn't have that and it could receive FrogStroll from sendGt1.py flawlessly. Does Gigatris.gt1 work for you?

[Edit: a byte with value 19 (decimal) is present ONCE in the recent version in GitHub, but ZERO times in the last GT1 attached here in this thread... It is also present once in frogstroll.gt1... BINGO? Gigatris.gt1 has several XOFF bytes in it. I propose to continue the investigation and solution in GitHub issue I created: https://github.com/kervinck/gigatron-rom/issues/36 ]
Post Reply