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

Day 4


RetroSonicHero

556 views

This one is a bit more laid-back compared to the last entries. I had some irl stuff going on with my little sister...

 

So anyway, today I dipped my toes into some basic bit-specific instructions. Those being, and and not.

 

 

In order to understand how these instructions work, you need to first understand what the data equals in binary. Starting off with the not instruction, what it does is reverse the "bits" in binary for the amount of data specified. (e.g, if a bit is set, it'll change it to clear, and vise-versa.) Let's keep it simple and use a byte as an example:

not.b     $0000002C

Let's pretend that a byte "5F" is located at address 0000002C:

5F = 0101 1111

The "NOT" instruction reverses the bits, which gives you:

1010 0000 = A0

Because "5F" has been reversed to "A0", the byte A0 is now located at offset 0000002C.

 

Meanwhile, the and instruction is a bit more complicated. What it does is perform AND logical between the source operand and destination operand, with the result being saved to the destination operand.

So what is AND logical?

 

Let's take two bits, one from the source operand, and one from the destination operand to perform AND logical:

source operand          destination operand        Result
	0           AND               0           =      0
	0           AND               1           =      0
	1           AND               0           =      0
	1           AND               1           =      1

Basically, both have to be 1 in order for the result to equal 1. The best way to look at it is that 0 = False and 1 = True. If the source operand AND the destination operand are true, then the result is "true". Which is where the instruction gets its name from.

 

Let's use an example, pretend that "d0" contains 01234567.

andi.b    #$D1,d0

What this line of code does is perform AND logical between byte D1, and byte 67 (located in data register 0).

D1 = 1101 0001
AND
67 = 0110 0111

40 = 0100 0000 (result)

d0 now has 01234540 in memory.

 

 

Anyhoo, that's all for today. I apologize for this entry not having as much content. Hopefully that won't be the case tomorrow.

  • 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...