10
1 Sec (2.4) Arithmetic / logic instruction:

Sec (2.4)

  • Upload
    tamas

  • View
    37

  • Download
    4

Embed Size (px)

DESCRIPTION

Sec (2.4). Arithmetic / logic instruction:. Logical operations:. Ex:. Mask:. Suppose we have this byte 00110011 we need to find a mask that being given the inverse for all digits? Sol.: 00110011 XOR 11111111 11001100. Mask:. So, note that: - PowerPoint PPT Presentation

Citation preview

Page 1: Sec (2.4)

1

Sec (2.4)

Arithmetic / logic instruction:

Page 2: Sec (2.4)

2

Logical operations:

Ex:

10011010

AND 11001001

10001000

10011010

OR 11001001

11011011

10011010

XOR 11001001

01010011

Page 3: Sec (2.4)

3

Mask:

Suppose we have this byte 00110011 we need to find a mask that being given the inverse for all digits?

Sol.: 00110011 XOR 11111111 11001100

Page 4: Sec (2.4)

4

Mask:So, note that:1. X AND 0 02. X AND 1 X3. X OR 0 X4. X OR 1 15. X XOR 0 X

6. X XOR 1 X

Page 5: Sec (2.4)

5

Rotation and shift operations:

The operation in the class of rotation and shift operations provide a means for moving bits within a register and are often used in solving alignment problems. These operation are classified by the direction of motion (right or left) and whether the process is circular. Within these classification guidelines are numerous variations with mixed terminology.

1. circular shift (rotation)2. logical shift3. arithmetic shift

Page 6: Sec (2.4)

6

circular shift (rotation)

Ex:

Rotating the bit pattern A3 one bit to the right

Page 7: Sec (2.4)

7

logical shift:

another technique is to discard the bit that falls of the edge and always fill the hole with a 0.

Ex:

+437 / 8 = 437 / 23 it means that shift 3 bits to right

Page 8: Sec (2.4)

8

logical shift:

000110110101

000000110110

Page 9: Sec (2.4)

9

arithmetic shift:

in either shift, care must be taken to preserve the sign bit when using certain notational system

we often find right shifts that always fill the hole with its original value

shifts that leave the sign bit unchanged

Ex:

+50 * 16 = 50 * 24 it means that shift 4 bits to left

Page 10: Sec (2.4)

10

arithmetic shift:

00110011

00110110