Friday, 16 February 2018


CENG 222 – Computer Organization
Lab Work 4

Logical Operations

Some of bitwise logical operations are:
AND, OR, NOT, XOR

Bitwise logical instructions apply the operation between each corresponding bits.

Examples:
AND data, ax               ; data = data AND ax
OR dx, ax                    ; dx = dx OR ax
NOT cl                        ; cl = NOT cl
XOR ax, ax                   ; ax = ax XOR ax

Shift Operations
Shift operations basically shift the bits of the given target (given as first parameter) by a number (given by second parameter)

Some Shift Operations are:
SHL,SHR (logical/unsigned),SAL, SAR(arithmetic/signed)

See 8086 help for detailed explanation of instructions. 

Rotate Operations
Shift operations work like shift operations, they the bits of the given target (given as first parameter) by a number (given by second parameter), the shifted bits are attached to the other side of the target.

Some Rotate Operations Are:
ROL, ROR (without carry), RCL, RCR (with carry)

See 8086 help for detailed explanation of instructions.

 

EXPERIMENT 1

Given bit values
A = 10101010b
B = 11001100b
C = 11110000b

Compute the following logical operations:
  • A  AND  B
  • A OR (B   AND   C)
  • A OR B OR (NOT C)
  • (A  AND B) OR (A   AND (NOT  C))

EXPERIMENT 2

Perform the following operations without using a MUL/ IMUL or DIV/IDIV command.
Hint: When you apply a single shift operation for a number you can multiply it or divide it by 2. Shift left for multiplying, shift right for dividing.

  • 0FAAh *2
  • 0FAAh / 2
  • FFAAh  / 2
  • FFAAh * 2
  • 00AAh * 5 ( Hint: 5*x = 4*x + x)
  • 00FBh *  2 + 000Bh * 4
  • 00AAh * 18

EXPERIMENT 3

Consider using logical and shift operations for the following assignments.
Hint:
AND AL, 11111101b; command will change the second bit of AL to 0, without changing the other bits
similarly
 OR AL, 00000010b will change the second bit of AL to 1, without changing the other bits
  • Assign  AX any value. Get the 4th bit of AX to the first bit of BX. All the other bits of BX should be zero
  • Get the  3rd bit of AL to 5th bit of AH. Other bits of AH should be unchanged.
  • Get the 2nd and 3rd bits of AH to 1st and 2nd bits of AL

No comments:

Post a Comment