ALU, Negation and ZR

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ALU, Negation and ZR

throwaway
First is the clarification and a "best practices" for negation question.  Negation refers to switching the most significant bit, correct?  How few chips would be required for negation from the set of chips available?  My intended method is to add a negative 1 then Not the result.  That will take 6 chips for both x&y.

Second I am thinking too sequential for determining ZR because the only solution coming to mind is to Or each bit as was done for Or16.  Again, I know there is a better way but I'm not thinking like a binary-addict enough.  Any suggestion here?

My finished code doesn't parse all the flags correctly, for instance the flags for returning x do not in fact do so. I'd appreciate a code review for some more hints and an eye for typos/blind spots.
Reply | Threaded
Open this post in threaded view
|

Re: ALU, Negation and ZR

cadet1620
Administrator
Negation has several meanings depending on context. Arithmetic negation involves flipping the MSB and adding 1. Logical negation means flipping all the bits.

Read the description of the ALU carefully so that you use the correct negation.

There's also a worksheet from ybakos that will help you understand the ALU.

You're correctly thinking that ZR is true if all the output bits are zero. It might be helpful to think about the converse as well: ZR is false if...

Feel free to email me what you have if you want comments.

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: ALU, Negation and ZR

throwaway
Well I have the code down and thanks to the worksheet (thanks for that) I realized that I had the orders of some things wrong.  Now it runs correctly.  I would like your input though on my code.  I thought I saw you or someone else say they could get it down to 8 chips?