12-13-2014, 07:24 PM
I think that if you have no opcode (00000) in the Instruction bus, that say that you have a huge error on the bus (it miss a redstone repeater, wires are too long, etc...). So I recommand to unuse the 00000 instruction (or use it to stop the computer and show a "stop" message).
And Addc and Subc is a good way to use the carry flag. By example :
I will add 2 numbers (unsigned) of 16 bits, with a 8 bit ALU. How can I proceed ?
And Addc and Subc is a good way to use the carry flag. By example :
I will add 2 numbers (unsigned) of 16 bits, with a 8 bit ALU. How can I proceed ?
Code:
Example :
0011'0001 ' 1001'1010 //MSB ' LSB
+ 0001'1000 ' 1110'0000
-----------------------
0100'1010 ' 0111'1010
- I add the 2 LSB bytes (1001'1010 + 1110'0000)
- The result of this is 1'0111'1010, so you have a Carry out (carry is set to 1)
- You store this 8 byte value at Registre x
- So, the next instruction will be ADDC (add with carry) the 2 MSB bytes. With this you include the carry out of the previous operation. And the result will be 0100'1010 (with the carry !).
- You store this value at Registre x+1 (or x-1 ... depend of big or little Indian)