I recently got my hands on a SMART Response XE, which is a defunct education device based on a ATMega128RFA1. It's basically a beefy arduino with a keyboard and screen.
The device that I bought came preloaded with a fork of Arduino BASIC. It took me an hour or two to get the basic control flow down, but its simpler than I expected.
The REPL flow is quite nice.
You can swap between 9 banks of memory using mload {slot}
and msave {slot}
where slot
is between 0 and 9.
You can immediately execute an expression by typing it and hitting enter.
You add code to your program by prefixing an expression with a line number.
To delete a line, type the line number without any extra characters.
Use list
to see your source and run
to run your program.
These take a line number as an argument so you can skip around.
In a modern language like Python, you're given more control over execution flow of the program.
In particular, IF
expressions are limited to a single expression.
If you want to run multiple lines in a branch of code, you must jump to a line to continue execution in that code block.
The result of this is that line numbering becomes something that you need to mindful of during development.
There are observations or minor improvements that I would make on the implementation of BASIC on this device.
- I would set
enter
to be the down or right key. I keep wanting to use thebackspace
key for it's intended purpose, and it's a little annoying to have to change it. A dynamic setting could be cool, built into the environment as a function. - When running
LIST
, hitting enter or down skips the last line in the entry, which means I can't see all the code I've written. This is a small off-by-one error. I think this is related to setting the position to the 7th row; if I do this and print a value, then we'll automatically scroll the buffer forward. - Hitting
q
when listing code should put me back into the the main interpreter. It would also be nice to see a pager of some kind at the bottom of the screen (like less), but it's by no mean necessary. - I would like a way to edit the current line using direction keys, without having to delete everything that I just wrote.
- I would also like a buffer for history. Pressing
up
should bring up the previous statement, like sh/bash. - Hitting any of the buttons for math (=,+,-,x,/) is awkward. I need to have both fingers on the left-hand side of the keyboard. The bottom two keys of the display would be useful as extra modifier keys, since they're currently not doing anything.
meta+shift+v
makes for a very unintuitive underscore. This should probably be under-
. Actuallyshift+space
is probably supposed to be the combo.- A
HELP
function might to start programming without having to dive into various docs. Alternatively, having a canonical reference with some examples would be cool. I'll try to include some useful examples in this doc, but it would be nice to have it built into the system. - The
POSITION
function takes column, then row. Which in retrospect make sense, given that origin is the top left and the arguments arex, y
- There aren't any trigonomic functions to play with e.g.
sin
,cos
, ortan
, nor functions likesqrt
. Implementing these from scratch seem little tedious when they can be wrapped from the c standard library. But I suppose implementing cosine from scratch might not be the worst thing to do.
- https://www.tindie.com/products/subsystems/smart-response-xe-with-arduino-basic/
- https://www.tindie.com/products/bradanlane/smart-response-xe-developer-kit/
- https://hackaday.com/tag/smart-response-xe/
- https://github.com/robinhedwards/ArduinoBASIC
- https://github.com/Subsystems-us/SMART-Response-XE-Tiny-Basic-Port
- https://gitlab.com/bradanlane/srxecore
- https://simba-os.readthedocs.io/en/latest/
- http://www.ulisp.com/
- https://www.bigmessowires.com/2016/05/06/fc8-faster-68k-decompression/
Read through this blog post on cosine from scratch. I had ChatGPT write me a cosine implementation; it looks like the taylor expansion implementation is simpler to implement that I originally thought. https://chat.openai.com/share/c6b2a3a7-08c2-4ed2-a453-70a3f8b99f78
Taylor approximation:
Code (which needs to be simplified for entry):
Finally a sample program: