Simple subleq

Programming, for all ages and all languages.
Post Reply
User avatar
MichaelFarthing
Member
Member
Posts: 167
Joined: Thu Mar 10, 2016 7:35 am
Location: Lancaster, England, Disunited Kingdom

Simple subleq

Post by MichaelFarthing »

I've been quite intrigued by some of the discussion in this area. Perhaps geri (or someone else) might post some examples of how other basic operations - shifts or xor for example - can be carried out on a machine word using subleq. Just curious.
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: Simple subleq

Post by Geri »

1. the best method of left shifting is multiplication, so:
-a+a (shift left by one byte)
-a+a+a (shift left by two byte)
etc

shifting 8, 16, 24, 32, 40 to left/rifht, etc is trivial, becouse you just read a byte forward-backward
2. right shift has to do with algorythm (i divide with pow(2, i)).
3. and/or/xor has to do with algorithm (i shift with one and check where the values will be negative and create the new bitfield as result and shifting that too).

the solution for 2 and 3 is my invention, but maybe alreday invented by someone else too, and maybe more optimal methods also invented previously.

also, more optimal methods should be exist (like having precalculated byte-tables) but i used algorithmic solutions to keep binary size smaller. i wrote the algorithmical solutions in C so i have no idea what subleq binary codes they compile to.

besides the very basic operations, i made everything with C algorithms
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
Post Reply