Jump to content
  • entries
    4
  • comments
    2
  • views
    530

Day 6


RetroSonicHero

581 views

I haven't been actively doing this as much recently, I've had the sudden urge to play some Sonic, and, well, you know how that goes..

 

But yeah, at this point I've learned the majority of the bit-specific instructions. The ones I've learned over the last few days are:

 

or
eor
bset
bclr
bchg

I'll briefly go over each of them.

 

The "or" instruction is similar to the "and" instruction I talked about last time. What it does is compare the bits of the source and destination operand. If the bits of each are either both 1, or one of them is 1, then the result will be "set" for that bit. "eor" (written as "xor" in most other assemblers) stands for "exclusive or". It works the same way as OR, except, the result will only be 1 if either the destination or source has a 1 for that bit. Unlike OR, it can't be both.

 

bset, blcr, and bchg all follow the same overall rules apart from the function they serve.

 

As you may know, there are two different states a bit can be in:

0 = clear
1 = set

As such, these three instructions are pretty self explanatory. What they do is modify the state of a bit that you've specified. They can be used on data registers, and directly into memory addresses. They however, CANNOT be used directly on address registers, but they can be used on the data contained in the offest of an address register.

 

Let's say you wanted to "clear" a bit in data register 0. Well, for starters, the 68000 has data and address registers which contain a long-word of space. Meaning, you have 32 bits to work with. Now that we know that, the next bit of code should be more clear:

bclr.l    #$1F,d0

This will clear the bit 1F (31 in decimal) in data register 0.

 

Lets say you wanted to clear a bit directly in memory. This is just as simple, except, you can only specify a byte of data. Meaning, you can only change the state of 1 out of 8 bits at once:

bclr.b    #$07,$0000002A

This will clear the 07th (8th) bit held at offset 0000002A. Let's pretend that address contains the byte "FF". In binary, that's 1111 1111. Because we've cleared bit 07, that gives us 0111 1111. Which equals 7F. Offset 0000002A now contains 7F.

 

To clarify, the "bchg" instruction works just like bclr and bset. What it does is reverse the bit specified. For example, if a bit is clear, bchg will make it set, and vice versa. All other rules apply.

 

That's all for today. I'll have more content soon.

  • Like 1

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...