A student writes:

        Dr. Patt,

        I apologize if you have answered this in class 

No apologize necessary.  ...but yup, we did do this in class.

        or in your book, 

Yup, it is there also.  Look at the character counting example in Chapter 5.
Figure 5.16, for example.

        but I have
        gone through my notes and the book and cannot find my answer.  I was
        wondering(and maybe I am so far off base I don't need this) if it was
        possible to write a branch within a brach, and how that would work.

Recall in the example we went through in class we had a loop.  Before 
entering the loop, we set the counter to the number of data values we were 
going to examine.  If not zero, we went through ONE iteration and then tested 
again.  So, here is our branch: the BRz instruction is testing to see if n=0 
and we are done.

If not zero, we went through ONE iteration.  What did we do in that iteration?
First, we got the next value.  Then we tested to see if that value was negative.
Aha!  Our second branch, and this one is inside the first branch (using your
terminology).  Answer: Yup, we can have a branch inside a branch.

BUT, I would rather you not MEMORIZE that.  What is important here?  Answer:
to systematically decompose the program you are working on into smaller and
simpler blocks.  Three ways to decompose.  Sequential, Conditional, Iteration.
Figure 6.1.  Each of the blocks in the decomposition can be further decomposed
into one of the three blocks.  ...and on and on and on.

So, whether you end up with a branch within a branch depends on the application
you are programming, and whether a conditional is inside the body of an 
iteration, or an iteration is inside the body of one of the paths from the

Got it?  

        My second question is a very basic, silly, stupid one, that you will
        probably laugh at.  

No, I do not laugh at sincere questions.  They come from a lack of 
understanding, and we are here to change that, assuming you are doing 
your share: coming to class, not listening to music on your ipod in 
class, or in a chat room, and coming to discussion session and reading 
the book.  If I learn that my faith in your commitment to the course
is misplaced, then I will feel differently.  But, until then...

        So I am making fun of myself before you can.  

Then only one of us is making fun of you.

        In this
        program, are the numbers binary, or 2's compliment.  If they aren't 2's
        compliment, how do I distinguish what the 15th bit is?

We have discussed this in class also.  The number could be a 2's complement
(note the spelling), or it could be two ASCII codes, or it could simply be 
a bit vector.  There is no guarantee that it is 2's complement.

THEN, you ask, how does the condition code settings know what it is so it
can know how to set N,Z,P.  Answer: it doesn't.  The only thing the condition
code logic knows is that it is being presented with 16 bits that it is writing
to one of the registers.  It sets N,Z,P on the basis of those 16 bits, IF taken
as a 2's complement value is negative, zero, or positive.  The logic can't know
how you are using those 16 bits.  The logic only knows that it is being
presented with 16 bits, and it sets N,Z,P according to what we just said.
If it happens to be the two ASCII codes AB (x4142), then N,Z,P will be set
to 001 because the logic only knows that it is x4142 and that (if it were
a 2's complement integer) would be positive.

        I apologize for any unclear points in this email, 
        but somewhere along the
        line I got very confused with branches and their use.

        Thanks for your time as I know you probably get a lot of questions.

I do have a lot of questions.  Doing the best I can to respond to them.

Good luck finishing the program.

Yale Patt