Section 03 Part 06 – Homework Results 03

 

 “The awkward moment when wikipedia has copied your homework.” ~Unknown author

 

 

 

Introduction

 

OK So, the previous part contained a homework section (I really should consider changing the name a bit, homework is probably patronising, but eh).  Here are the results:

 

 

 

Results

 

          move.b    #$24,d0

          bclr.l    #$02,d0

          ori.b     #$03,d0

          move.b    #$F8,d1

          and.b     d0,d1

          not.w     d1

          eori.w    #$FF00,d1

          move.b    d1,$00002200

          bset.b    #$05,$00002200

          bchg.b    #$01,$00002200

 

All of the data registers will start with 00000000.

 

          move.b    #$24,d0

 

d0 now contains 00000024.

 

          bclr.l    #$02,d0

 

Bit 02 is cleared:

 

0000 0000 0000 0000 0000 0000 0010 0000

 

d0 now contains 00000020.

 

          ori.b     #$03,d0

 

03 OR 20:

 

03

0

0

0

0

0

0

1

1

 

 

 

 

 

 

 

 

 

OR

OR

OR

OR

OR

OR

OR

OR

OR

 

 

 

 

 

 

 

 

 

20

0

0

1

0

0

0

0

0

 

 

 

 

 

 

 

 

 

=

=

=

=

=

=

=

=

=

 

 

 

 

 

 

 

 

 

23

0

0

1

0

0

0

1

1

 

The result is 23, d0 now contains 00000023.

 

          move.b    #$F8,d1

 

d1 now contains 000000F8.

 

          and.b     d0,d1

 

23 AND F8:

 

23

0

0

1

0

0

0

1

1

 

 

 

 

 

 

 

 

 

AND

AND

AND

AND

AND

AND

AND

AND

AND

 

 

 

 

 

 

 

 

 

F8

1

1

1

1

1

0

0

0

 

 

 

 

 

 

 

 

 

=

=

=

=

=

=

=

=

=

 

 

 

 

 

 

 

 

 

20

0

0

1

0

0

0

0

0

 

The result is 20, d1 now contains 00000020.

 

          not.w     d1

 

The word 0020 in d1 has had its bits reversed:

 

          0000 0000 0010 0000

 

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

          VVVV VVVV VVVV VVVV

 

          1111 1111 1101 1111

 

The result is FFDF, d1 now contains 0000FFDF.

 

          eori.w    #$FF00,d1

 

FF00 XOR FFDF:

 

FF00

1

1

1

1

1

1

1

1

0

0

0

0

0

0

0

0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

XOR

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

FFDF

1

1

1

1

1

1

1

1

1

1

0

1

1

1

1

1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

=

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

00DF

0

0

0

0

0

0

0

0

1

1

0

1

1

1

1

1

 

The result is 00DF, d1 now contains 000000DF.

 

          move.b    d1,$00002200

 

DF from data register d1 is copied into memory at offset 00002200:

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00002200

DF

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

 

The byte in memory at offset 00002200 is now DF.

 

          bset.b    #$05,$00002200

 

Bit 05 of DF (in memory at offset 00002200) is set:

 

1111 1111

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00002200

FF

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

 

Now the byte in memory at offset 00002200 has changed from DF to FF.

 

          bchg.b    #$01,$00002200

 

Bit 01 of FF (in memory at offset 00002200) is reversed:

 

1111 1101

 

The bit was 1 (set), so it’s changed to 0 (clear):

 

Offset

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

00002200

FD

00

00

00

00

00

00

00

00

00

00

00

00

00

00

00

 

To sum it up, the byte in memory at offset 00002200 is FD.  Congratulations if you worked out that.

 

 

 

Previous Part

Main Page

Next Part