Wed, 9th Dec 2015, 02:50 Re: Masks

A student writes:

> Hi Dr. Patt.
> I was studying for the EE306 exam and I am very confused on what a mask is
> and what its purpose is. I consulted the textbook but I am still confused.
> Could you please explain this to me? Thank you.
> With regards,
> <<name withheld to protect the student who wants to know what a mask is>>

I am always happy to answer your questions, but you know that I am out of the
country right now, and you may get quicker answers by seeing a TA during office

A mask is a bit vector that is used in conjunction with an element.  The most
common element is a register or memory location and the corresponding mask is
16 bits, one bit for each bit in the corresponding element.  If an element
consisted of five bits, the corresponding mask would contain five bits.

The purpose of a mask is to isolate specific bits in the corresponding element.
The most common usage is to set mask bit i = 1 if we are interested in
element bit i, and the rest of the bits 0, and then ANDing the mask and element.

For example, if we are only interested in the opcode of an LC-3 instruction,
we could set the mask to 1111000000000000, and AND it with the instruction.
The result would be a 16 bit value consisting of the opcode in bits [15:12]
and 0 everywhere else.  If we are interested in only the trapvector of a TRAP
instruction, for example we would use a mask 0000000011111111.

See the example in chapter 2 that uses bitvectors to determine which
resources are busy and which are free.

The term probably originated from "Masking tape" where you, for example, can
use masking tape to cover that part of a wall where you don't want paint, before
you sloppily apply paint to the wall.


Good luck on the exam.

Yale Patt