Tuesday, April 26, 2022

Subleq Plus

I got the Subleq+ compiler and interpreter working.  They're posted on GitHub.  This is a huge advance over hand jamming the physical addresses.  Many thanks to Chris Lloyd for the basis of the system.  The parser is still mostly his code.

Subleq is a single instruction computer.  That instruction consists of three words, A B C.  The function is [B] = [B] - [A]; if [B] <= 0, jump to C.  "[x]" means the contents of memory at location x.  As limited as it seems, you can theoretically do anything with a computer like this.  It just takes longer.

Why am I interested in this?

  1. I'm a geek.  If that wasn't obvious by now, you haven't been paying attention.
  2. Subleq reminds me of a programming project I found in a magazine for the Commodore-64 back when I was a kid.  There was some toy language that only had two instructions:  Increment an address by one, and decrement an address by one and jump if it was zero.  I played around with that for weeks.  Good times.  Happy memories.
  3. This has gotten me back into programming for the first time in almost 30 years.  I actually went to college for programming back in the early 90's.  I dropped out (the second time) when I noticed that I, as a Junior, was helping the grad students with their projects.  I also saw that my friends were having trouble finding local jobs in the field, as the industry was leaving Ohio and moving to California at the time.  I just lost interest and motivation.
  4. Being partially disabled and mostly stuck at home, I have a lot of time on my hands and I get bored.  This is a nice challenge.
So, where to go from here?  I could adapt the system for OISC:2.  But I would want to update the design to accommodate some of the new ideas I've had for OISC:3.  Negative memory references actually to go negative memory, where they are automagically redirected.  OISC:3 will use a stack, and the program counters, etc, won't be in addressable memory.  Input and output will also be stack commands.  This, of course, won't work well for OISC:2, because of the constraints of the language.  So I think I'll just leave it alone, and maybe adapt the parser to it.  Oh, and I'm renumbering the mode commands to use negative numbers, because I like the symmetry of having things like addition/subtraction, multiplication/division, power/log, sin/asin and or/xor having opposite signs.

Is a stack too much power for an esolang like this?  If course it is!  Could it take some of the challenge of using a language like this away?  Of course it can!  But that's not really the point, is it?  It's not to use the language so much as to create a usable language.  And it still doesn't have an explicit instruction.  It's all just data and memory locations.  But then, that's all computers really are.

No comments:

Post a Comment

I reserve the right to remove egregiously profane or abusive comments, spam, and anything else that really annoys me. Feel free to agree or disagree, but let's keep this reasonably civil.