Write a maximum of two instructions to clear, set and complement some bits in the AL register

assembly, masm, x86, xor

Solution

The trick here is to do the following:

use an OR instruction to set bits 0, 3, 4 and 7

use an XOR instruction to complement bits 0, 1, 5 and 7

Note that bits 0 and 7 first get set in (1) and then cleared in (2).

I'll leave the actual asm instructions to you, since this is your homework, after all.

Problem

You are required to write a maximum of two instructions in assembly to do the following: - Clear bits 0 and 7 of register AL, i.e. make them 0 - Set bits 3 and 4 of register AL, i.e. make them 1. - Complement bits 1 and 5 of register AL. - Keep all other bits in the register AL as is without changing their values.

Original source