Section 03 Part 01 – The NOT Instruction

 

I see the player piano as the grandfather of the computer, the ancestor of the entire nightmare we live in, the birth of the binary world where there is no option other than yes or no and where there is no refuge.” ~William Gaddis

 

 

 

Introduction

 

NOT – logical complement

 

This instruction will reverse all bits of a destination operand.  Bits that are 0 become 1, and bits that are 1 become 0 (clear to set, set to clear).

 

 

 

Examples

 

The first thing that was explained in Section 01 Part 01 was binary and data sizes.  As you should know, bits are in one of two states, 0 or 1, the purpose of this instruction is to change the bits to the opposite setting, effectively reversing the result.

 

Here is an example:

 

          not.b     d0

 

The destination operand is d0; now let’s say d0 contains FE800174, since the instruction has .b for byte, only the end byte is altered (you should know this by now).  The end byte is 74, to understand how it works; we need to look at that value in binary.

 

74 is 0111 0100 in binary:

 

          0111 0100

 

          |||| ||||

          VVVV VVVV

 

          1000 1011

 

As you can see above, the bits that were 0 have been changed to 1, and the bits that were 1 have been change to 0.  0111 0100 has changed to 1000 1011.

 

1000 1011 is 8B in hex, that final result is saved into d0, and d0 now contains FE80018B.

 

This instruction can be used on memory as well:

 

          not.w     $000048C0

 

This will reverse the bits held in memory at offset 000048C0 and 000048C1:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

000048B0

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

11

000048C0

22

35

78

88

90

00

00

00

00

00

00

00

00

00

00

00

000048D0

00

00

00

00

00

00

00

00

00

43

F8

8F

EE

CC

C0

00

000048E0

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

So the word loaded is 2235, in binary that’s 0010 0010 0011 0101, the NOT instruction will reverse the bits, resulting in:

 

 

          0010 0010 0011 0101

 

          |||| |||| |||| ||||

          VVVV VVVV VVVV VVVV

 

          1101 1101 1100 1010

 

1101 1101 1100 1010 in hex is DDCA, and is saved back into memory:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

000048B0

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

11

000048C0

DD

CA

78

88

90

00

00

00

00

00

00

00

00

00

00

00

000048D0

00

00

00

00

00

00

00

00

00

43

F8

8F

EE

CC

C0

00

000048E0

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

etc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This can be used on memory via address registers too:

 

          not.w     (a0)

          not.b     $0B(a0)

          not.l     (a0)+

 

It cannot be used on address registers directly though:

 

          not.w     a0

 

 

 

Previous Part

Main Page

Next Part