ZR & NG

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

ZR & NG

Veiniuks
Hello all,  

I am pretty confident I have the ALU completed properly.  However, I don't understand where the ZR & NG come in nor do I understand their purpose. What is eq. comparison and neg. comparison and where were they explained? Any help would be greatly appreciated.  

Reply | Threaded
Open this post in threaded view
|

Re: ZR & NG

milythael
ZR and NG are single bits that provide information about the
characteristics of the out value.  ZR is 1 if and only if the output
(out) is zero.  NG is 1 if and only if out represents a negative
value.
Reply | Threaded
Open this post in threaded view
|

Re: ZR & NG

cadet1620
Administrator
In reply to this post by Veiniuks
The zr and ng outputs from the ALU are used when you implement your CPU in chapter 5. They are used for instructions with conditional jumps, for instance the instruction D;JEQ jumps only if the D register contains zero. You'll learn about these instructions in chapter 4.

For chapter 2 it suffices that the zr flag is TRUE when the output of the ALU is zero and that the ng flag if TRUE when the output of the ALU is a negative number.

--Mark