From: Randolph Wang <rywang@CS.Princeton.EDU>
Date: Tue, 23 Mar 2004 12:06:43 -0500 (EST)
To: mh@princeton.edu
Cc: randy_class@CS.Princeton.EDU
Subject: Re: practice midterm question
> Hi,
>
> =20
>
> For the fall '03 midterm 1, I was looking at question 10 b) and got a =
> little
> confused. 10 b) is referring to the program described above right? So =
> why
> would it output ACDC (as in the solutions guide) as opposed to just 0001
> since XOR outputs only 0's and 1's? =20
>
> =20
>
> Thanks,
>
> Michael =20
(1) 10b is referring to the program above.
(2) The instruction 9CFF writes the register contents to the screen in
hex, not in binary.
(3) I think you're still not understanding clearly the concepts of hex
and xor.
(a) Hex is just a notation, a representation, of any number; it
has nothing to do with xor or anything else. A number can be
represented in hex, binary, or decimal. The TOY instruction
9CFF happens to produce output in hex form. It has nothing to
do with where the register R[C] got its value from.
(b) Xor, as explained at the beginning of problem 10, performs a
bit-by-bit operation (or so called bit-wise operation). Since
any number can be represented by a string of 0s and 1s, you
can xor two numbers bit-by-bit to produce a third number.
This third number is just that, a number, which can be
represented by hex, binary, or decimal representations.
Again, 9CFF just happens to choose to represent it in hex.
Randy
Re: practice midterm question / Randolph Wang