Saturday, October 03, 2009 5:01 PM,



Another student writes:

	 I saw an earlier email when I student asked about how to submit the 
	 bit mask and I looked under the submission instructions and didn't 
	 find any directions about submitting it.
	 How would you like us to go about doing so?
 
	 <<name withheld to protect another student having trouble with this>>


I thought my email on this Thursday was clear.  Apparently not.  Simplest 
thing for me to do is try to explain it again, and more completely.

Bit masks are part of your program.  You don't want to execute a bit mask so 
you put it after the HALT instruction.

You don't put them in the Simulator separately.  They are not part of any 
separate file.

Bit masks are part of your program, so they are in your .bin file.

Example:  Suppose you wanted to know if the instruction stored in location 
x3050 is a branch.  If it is a branch, the opcode is 0000.  That is, if any 
opcode bit is 1, the instruction is not a branch.

Solution: If we AND the instruction with the mask xF000, the result will be 0 
only if the opcode is 0000.  So, we load the instruction (from x3050) into a 
register, load the mask into another register, and execute the AND.  If the 
opcode of the instruction at x3050 is 0000, the execution of the AND will set 
Z to 1.  If the opcode is anything other than 0000, the execution of the AND 
will set Z to 0.  DO YOU UNDERSTAND WHY?  Then a branch that tests the Z bit 
comes next. 

Where does the bit mask go?  Answer: After the halt instruction so it won't 
get executed.

Your .bin file (starting at x3000) could be:

0010 001 001001111           ; R1 <- contents of x3050 
0010 010 000100011	     ; R2 <- contents of x3025 (the bit mask)
0101 001 001 0 00 010
0000 010 xxxxxxxxx           ; Branch based on whether R1 contains all 0s
<<more instructions, let's say x20 of them for example>>
1111 0000 0010 0101          ; the halt instruction
1111 0000 0000 0000          ; the bit mask xF000

Let me say it one more time.  In constructing your program, you may need 
constants and/or bit masks to solve the problem.  They are part of the program 
and are placed after the halt instruction.  WHY AFTER THE HALT INSTRUCTION?  
Answer: Because execution stops with the execution of the Halt instruction.  
Since bit masks and constants are not intended to be instructions, putting 
them after the halt instruction ensures they will not be executed.

OK?

Good luck finishing this by tomorrow night.

Yale Patt