From the previous tutorial, you learned you can load values into registers. What about loading registers to registers? How about CURCOL, CUROW, PENCOL, and PENROW? What is Cp?
You can't actually load a register into another register, but you can load the data value in another register to a register. Here's what it looks like:ld b,a
In this example, I loaded whatever was in register a into register b. You can do this with any single letter registers.
As I told you before, Curcol and Currow are the text coordinates on the home screen. Pencol and Penrow are text coordinates on the graph screen. These are the memory adresses for these coordinates:PENCOL =86D7h ;Notice the memory adress similarities... PENROW =86D8h CURCOL =800Dh ;Same here... CURROW =800Ch
If you noticed, Pencol and Penrow are right next to each other in memory. Same goes with Curcol and Currow. Notice how I loaded the coordinates into Pencol in tutorial 16. It looked like this:ld hl,0000h ld (PENCOL),hl
As you can see, I loaded 00 to Pencol. But what about Penrow? 0000h is a 16-bit value. And hl is a 16-bit register. Pencol and Penrow are both 8-bit. Thus if I loaded 0000h into hl, then loaded hl into Pencol, the other half of the value is automatically loaded into Penrow. So in the end, this is what each coordinate is:Pencol = 00 Penrow = 00
Note: this is not actual Asm code, so don't put it in your programs.
Pencol is earlier in memory than Penrow. So make sure you load the value into Pencol if you want it automatically loaded into Penrow. You can do the same thing as you did with Pencol and Penrow with Curcol and Currow. Try it out! If you wanted to load 00 to Pencol and 05 to Penrow, the code would look like this:ld hl,0005h ld (PENCOL),hl
Cp is a Z80 instruction that stands for Compare. This instruction compares a value to the value in the "a" register. In tutorial 14, we used Getkey to scan for for a keypress on the keyboard. Getkey then stored the key code into the "a" register. We then compared the key code with the defined keycodes from the beginning of the program. If they were equal, it moved the dot.Tutorial 19