ld b,$0c ld c,$13it's the same as doing this:
ld bc,$0c13Pretty cool, huh? You may wonder why a isn't included in any of the 16-bit registers. It is included, actually, in the register af, which is comprised of a and f, the flag register, which stores various flags, such as the zero flag we worked with in the last column.
variable1 = TEXT_MEM variable2 = TEXT_MEM+1With this stuff, we're defining locations in the TI-82's ROM to store the values for our variable. TEXT_MEM is located at $808f. It consists of 128 bytes which are used to store the home screen on your calculator. So this is a very standard spot to store information. Other popular places are the TEXT_MEM2 (also 128 bytes), GRAPH_MEM, and APD_BUF (both 768 bytes). Try and stick to the TEXT_MEM and GRAPH_MEM, the other two can be tricky to work with. So, let's say we want to see if variable1 is equal to 1. First, at the top of the program, we'd have this:
variable1 = TEXT_MEMThen, later:
ld a,(variable1) cp 1Okay, so why is variable1 in parantheses? You may remember from the first column when dealing with CURSOR_ROW that we put () around the memory address to access the information stored at the address, rather than accessing the memory address itself. Defining variables at the top of the program is exactly what ti82.h and crash82.inc do to define things like CURSOR_ROW and TEXT_MEM.
ld a,%11000101 ld b,%10101011 and bThe result in a would be %10000001. As you can see, only the first and last bits in a and b are both 1. When the bits are either both set to 0 or when they are different, the new bit in a will be 0. Now let's see what or does:
ld a,%11000101 ld b,%10101011 or bThe result would be %11101111. That's because or returns 1 just as long as one of the bits was equal to 1. Since bit 4 (counting backwards from 7 down to 0, not right to left from 1 to 8 like you might suspect) is 0 in both bytes, it is the only bit in the new a that is not 1. And finally for xor, which returns 1 only if the two bits are not equal:
ld a,%11000101 ld b,%10101011 xor bThis would return %01101110 because bits 7, 4, and 0 are the only ones where the bits were equal, so they were set to 0, and the others to 1.
Okay, that's all for this lesson. Next lesson, expect some simple math. Inc, dec, add, sub, and some byte rotating.