GOOD COMPUTER: BASIC
I am making a GOOD COMPUTER, my take on a 70/80s-style approach to building a computer!
Current focus: the BASIC interpreter
Here’s the code and more info: https://gitlab.com/good-computer/basic
I made a function! it turns out that functions can be parsed as just a special kind of parens. I’m really happy with how cleanly it came out
meanwhile, some 128K SPI SRAMs arrived today, a month ahead of of the ETA, so soon I’ll be able to stop juggling housekeeping memory and be able to have actual decently long programs
board tidied a lot, RAM added, and a simple test read/write program written to confirm the wiring is good and I understand how to drive it. next up, rewriting the memory manager to store the program in there!
ok, all program storage is now in the external memory so now I can have enormous programs. nothing to show because it all looks exactly the same, but I’ve got room to move now. oh and I added a light so I can indicate things separately from a program that legit blinks a light
just for fun I started fiddling with XMODEM. pleasantly straightforward!
back to real life. jump targets for flow control instructions are now referenced by line pointer and offset into line, which allows RETURN (and soon NEXT) to jump to a point within a line
finally got FOR/NEXT working. NEXT is kinda ridiculous, its sort of a shortcut for LET, IF and GOTO all one. its also showing up some real structural problems in my code, which I need to think hard about. but its there at leeast!
this is a struggle. the “type” of an expression is set from its first operand. if later operands don’t have the same type, the whole expression is rejected. this works great until you have functions that take one (or both) types and emit the other. hmm.
many hours work in the last few days to get to this point. obviously, implementing functions like LEN and MID$, but there’s also full string/number type checking and specs all the way through
all functions now have a return type, and qualify as an operand of that type. they also have a signature, the number and type of arguments they expect
with only two types you can store them in a single bit, which allows some pretty tight code for tracking and checking types!
debugging in action. dumping the operator stack after each character is consumed by the expression parser. something is dropping a comma, messing up the arg count
it’s low-tech, but still a luxury compared to what the early microcomputer programmers had
big day of bugfixing, and here’s another fun little program
a couple of small changes necessary: a different way to test for even-length strings, because I don’t have floating point, and an extra increment because I don’t have variable loop steps
where even is the hollow tree?
I got sick of typing in test programs over and over again. I’ve ordered a MicroSD module to store programs, but until then, I’ve added a program loader that receives program text over the serial line via XMODEM and parses it. its silly but I’m pretty chuffed about it 😎️
originally posted on twitter at: https://twitter.com/robn/status/1267645875855060993