OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:18 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Simple subleq
PostPosted: Tue May 09, 2017 9:48 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 10, 2016 7:35 am
Posts: 167
Location: Lancaster, England, Disunited Kingdom
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.


Top
 Profile  
 
 Post subject: Re: Simple subleq
PostPosted: Tue May 09, 2017 9:53 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 14, 2013 6:01 pm
Posts: 442
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group