OSDev.org
https://forum.osdev.org/

Simple subleq
https://forum.osdev.org/viewtopic.php?f=13&t=31893
Page 1 of 1

Author:  MichaelFarthing [ Tue May 09, 2017 9:48 am ]
Post subject:  Simple subleq

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.

Author:  Geri [ Tue May 09, 2017 9:53 am ]
Post subject:  Re: Simple subleq

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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/