sd-8516_assembly_language
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| sd-8516_assembly_language [2026/01/29 11:56] – appledog | sd-8516_assembly_language [2026/01/29 12:09] (current) – appledog | ||
|---|---|---|---|
| Line 207: | Line 207: | ||
| The AND means " | The AND means " | ||
| + | === Binary | ||
| + | Now wrap your head around the power of binary! | ||
| + | LDA 0b01000111 | ||
| + | LDD 0b00010110 | ||
| + | AND A, D ; A is now what? 0b00000110 | ||
| + | The bits in A that were also set in D remain. The bits that weren' | ||
| + | LDA 0b01000111 | ||
| + | LDD 0b00000100 | ||
| + | AND A, D ; A is now 0b00000100 | ||
| + | JNZ @bit_3_is_set | ||
| + | JZ @bit_3_is_not_set | ||
| + | Since if bit 3 is not set, AND A, D produces a zero, you can branch flow control based on bits. So for example, if your CPU has a " | ||
| + | | ||
| + | Other commands that work in a similar way are OR, XOR, and NOT. | ||
| + | === OR | ||
| + | OR works by saying "Set the bit if either A or B is set." So it will be 1 unless both are zero. Thats useful for detecting thieves. If any one of the laser traps detect a thief, the alarm has to go off. Not all of them at once, but any one, anywhere, and the alarms go off! That's how OR works. | ||
| + | === XOR | ||
| + | XOR is " | ||
| + | * 0b00010001 | ||
| + | * 0b00010010 | ||
| + | * XOR | ||
| + | * 0b00000011 | ||
| - | | + | The bits that were the same are 0, the bits that are diffrent are 1. Please don't ask me why this is useful, i'm sure i'll remember why later. Ha. |
| + | |||
| + | === NOT | ||
| + | Finally, NOT. Not inverts a number. | ||
| + | * 0b00000001 ; This is a 1. | ||
| + | * NOT | ||
| + | * 0b11111110; This is 254 in decimal or FE in hex. Commonly written as #254 or $FE in assembler convention. Or 0xFE. Or FEh. | ||
| + | |||
| + | Why is NOT useful? NOT gives you the negative version minus one. So to make a number negative. NOT it and add one. In the case of 1, this is FF. This means you had a zero, subtracted one, and it //rolled over// to FF. So FF is negative one! We will explain negative numbers later. For now, FF is 255. Not -1. But, well, that's what NOT is for. | ||
| + | |||
| + | === The End of the Boring Lesson | ||
| + | If this lesson was confusing I'm sorry. The fact is you're not going to understand binary logic until later when you see it in action and see how it actually is used. For now, just try to remember the basic ideas. Or, failing that, just remember that there is an AND, and OR, an XOR, and a NOT. Everything else is based on those. | ||
| + | | ||
| == Appendix I: Registers | == Appendix I: Registers | ||
| There are sixteen general purpose registers available for use> Here they are, with a short comment on name and purpose. Of course, since they' | There are sixteen general purpose registers available for use> Here they are, with a short comment on name and purpose. Of course, since they' | ||
sd-8516_assembly_language.1769687798.txt.gz · Last modified: by appledog
