11/12/04

A student intuitively assumes incorrectly, and then writes:

     Dr. Patt,

     After browsing over the solutions to problem set 5,
     I was somewhat surprised
     when I saw the answer to problem 4 (stores a 1 if A is prime,
     0 if not). I took another look at the problem to see what I did
     wrong (I thought the correct answer was it stored the result
     of A mod 2), and saw the statement:

     BR REMOD

     I thought this would be the same as:
     0000 000 ...

     But obviously after looking through the book it's actually translated as
     BRnzp REMOD or 0000 111 ...

     << grimaces in fear >>

Grimaces in fear? I assume everyone will know that you have come up with that one, and not I. Looks like no one is allowing me to come up with names anymore.

Anyhow, your intuition would suggest that. ...so I should explain. You are correct, the subscripts of BR tell you which condition codes to check: like BRz checks Z, BRnz checks N and Z, BRnzp checks all. Then why not, you ask, have BR check nothing. After all, it does follow the same pattern.

I could have done that. However, most "real" assembly languages use BR to mean unconditional branch (i.e., branch always) that I decided to NOT have it mean branch never in 306. I felt it was better to err on the side of inelegance for the meaning of BR, rather than have you unlearn BR as soon as 306 is over.

So, BR and BRnzp assemble to the same instruction: 0000 111 pcoffset.

Yale Patt