Thursday, October 01, 2009 11:24 PM,
A student writes: There was no salutation, but since it was in my email inbox, I assume the question was for me. I went to 3 office hours today and was very succesful learning how to do first programming. however, I am still not clear how to check the value using the bit mask. one of the TA showed me how to make bit mask using LC3Edit and loading it into LC3 simulator but I still do not know how to check the value of 7th bit if it is negative, zero, or positive and making the computer able to recognize if the value of 7th bit is negative, zero or positive. <<name withtheld to protect the student who can't tell the value of bit 7>> And, since there was no signature, I assume the email was sent by the student whose email address was in the header. You say you now know how to create a bit mask. Good! That will be useful. What you need is an instruction which will give you one result if bit 7 is a 0 and another result if bit 7 is a 1. The two operands to this instruction will be the value having bit 7 as one of its 16 bits, and a bit mask that you will have to construct. And the result created by that instruction will have to be able to be differentiated by the settings of the condition codes as a result of executing that instruction. So, can you come up with a bit mask and an instruction that will give you results that the condition codes can distinguish, depending on whether bit 7 is a 0 or a 1. There are only two operate instructions that have two sources (ADD and AND), so it has to be one of them. That is, ADD Rk, value, bitmask or, AND Rk, value, bitmask N,Z,P will be set depending on what result is written into Rk. Can you take it from here? Good luck finishing the program. Yale Patt