Wed, 2 Oct 2013, 22:06
My students, You recall my embarrassment very late in the lecture today, when I tried (and failed) to show you what the unconditional branch back to the test for "Done?" actually did. What did I do wrong???? And, since I wanted to get through the example before I let you go, I put off trying to find my error. It was the right thing to do to put off finding my error because if you understand this program, there is a lot in it that could help you write the program you are currently working on. The good news: we did finish the program, although I apologize for keeping you late. We are sending you the actual code (0s and 1s) tonight in case some of my writing on the board was not clearly legible. BUT now back to my error. Recall the unconditional branch back to the test for "Done?" was: 0000 111 111110010. 0000: branch 111: check all condition codes. One of them is a 1 -> unconditional branch. 111110010: the offset was xFFF2, a negative number we can put in 9 bits. All this is correct. So, I thought: Why not show the students that this negative offset is exactly the number of instructions I need to branch back. Step 1: What is the absolute value of 111110010? And THAT is where I screwed up! I said to take the hex xFFF2 and flip all the bits, giving you x000E. Wrong! Flipping all the bits gives you x000D. Then add 1, which would give you x000E, NOT x000F which was what I said. x000E is 14, and if you count back 14 instructions from where the PC is at that point, Bingo! You get to the instruction that is testing "Done?". Bottom line: My construction of the offset was correct, but when I tried to show you how it worked by constructing the absolute value of the negative number xFFF2, in my rushing I made a mistake. Hope this clears that up. Good luck getting the program done by tomorrow night. Yale Patt