v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Editing User:Vasiln/Goblin Logic 2

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.


The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 720: Line 720:
 
Maybe you noticed that I had to go to 5 addressing bits to make this one work.  Couldn't just start over at 0000, because I needed specific jump addresses.
 
Maybe you noticed that I had to go to 5 addressing bits to make this one work.  Couldn't just start over at 0000, because I needed specific jump addresses.
  
Continued at [[User:Vasiln/Goblin Logic 3]]
+
Right now, we have seven operations codes to spare: 0000, 1010, 1011, 1100, 1101, 1110, and 1111; and 15 arguments for XOR; and 8 arguments for bit shift or bit rotate.  Way more than we need.  At the same time, we don't have nearly enough memory.  We could do a couple of things: we could add instructions, so that for instance it wouldn't take two instructions to add two numbers.  We could also switch it up to a 3-bit instruction and a 5-bit address.
 +
 
 +
Or, we could do both.  Let's redefine our operations:
 +
 
 +
* 000xxxxx Write from xxxxx to register a
 +
* 001xxxxx Write from xxxxx to register b
 +
* 010xxxxx Write from register a to xxxxx
 +
* 011xxxxx Write from register b to xxxxx
 +
* 100xxxxx Register operations, receives xxxxx as specifying argument
 +
* 101xxyyy Bit shifting register operations, receives xx as specifying argument, yyy as bit value to shift
 +
* 110xxxxx Jump if not b to address xxxxx
 +
* 111xxxxx Reserved (Halt?)
 +
 
 +
Two of these need specifying.
 +
 
 +
100xxxxx Register operations
 +
 
 +
*10000000 XOR a and b -> a
 +
*10000001 Add: XOR a and b -> a, write 9-bit carry word to buffer, XOR a and carry word->a, write 8-bit carry word to buffer, with carry(8)=output of first XOR(8) OR output of second XOR(8)
 +
*10000010 Add with carry: Add a and 0000000x where x is equal to carry(8), add a and b, output carry(8)
 +
*10000011 XOR a with 11111111
 +
*10000100 Add 1 to a (XOR a and 1, XOR a and carry word)
 +
*10000101 Compare a to b, output to b
 +
*10000110-10011111 Reserved (26 choices!)
 +
 
 +
101xxyyy Bit shifting register operations
 +
 
 +
*10100yyy Arithmetic right shift 0-7 units (y units)
 +
*10101yyy Arithmetic left shift 0-7 units (y units)
 +
*10110yyy Right rotate 0-7 units (y units)
 +
*10111yyy Reserved
 +
 
 +
Note that there's no reason to send a y of 000.  I suppose 1010000, 10101000, and 10110000 are also reserved values.  We'll try and save 10111yyy for an operation that requires a 3-bit argument.  Maybe like "write true" or "write false" or "bitwise XOR."
 +
 
 +
So I just bit the bullet.  We made a carry byte; we established a carry bit.  We also built two constants into our system: 1 and -1.  We've succumbed to 5 bit addressing, but we still have plenty of reserved instructions.  We can add, subtract, multiply or divide, with a smaller instruction count.  Finally, we're ready to design the kind of memory to be used by our registers:
 +
 
 +
########
 +
<h^hh^h<
 +
########
 +
 
 +
Lol.  All of our functionality is built into our operations circuits or our buffer.  Our register memory doesn't need to do anything special.

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)