Difference between revisions of "Z80:Answers 2"
KermMartian (talk | contribs) |
(mostly fixing apostrophes, but also made label names consistently "label1") |
||
(2 intermediate revisions by the same user not shown) | |||
Line 8: | Line 8: | ||
'''D''' is not normally used in its 8-bit form. Instead, it is used in conjuncture with E.<br /> | '''D''' is not normally used in its 8-bit form. Instead, it is used in conjuncture with E.<br /> | ||
'''E''' is again, not used in its 8-bit form.<br /> | '''E''' is again, not used in its 8-bit form.<br /> | ||
− | '''F''' is known as the flags. It is the one register you cannot mess with on the byte level. | + | '''F''' is known as the flags. It is the one register you cannot mess with on the byte level. Its uses will be discussed later in the [[Z80:Flags and Bit-Level Instructions|Flags and Bit Level Instructions]] Section.<br /> |
'''H''' is another register not normally used in 8-bit form.<br /> | '''H''' is another register not normally used in 8-bit form.<br /> | ||
'''L''' is yet another register not normally used in 8-bit form. | '''L''' is yet another register not normally used in 8-bit form. | ||
Line 16: | Line 16: | ||
'''BC''' is used by instructions and code sections that operate on streams of bytes as a byte counter. Is also used as a 16 bit counter.<br /> | '''BC''' is used by instructions and code sections that operate on streams of bytes as a byte counter. Is also used as a 16 bit counter.<br /> | ||
'''DE''' holds the address of a memory location that is a destination.<br /> | '''DE''' holds the address of a memory location that is a destination.<br /> | ||
− | '''HL''' The general 16 bit register, it's used pretty much everywhere you use 16 bit registers. | + | '''HL''' The general 16 bit register, it's used pretty much everywhere you use 16 bit registers. Its most common uses are for 16 bit arithmetic and storing the addresses of stuff (strings, pictures, labels, etc.). Note that HL usually holds the original address while DE holds the destination address.<br /> |
− | '''IX''' is called an index register. | + | '''IX''' is called an index register. Its use is similar to HL, but its use should be limited as it has other purposes, and also runs slower than HL.<br /> |
'''IY''' is another index register. It holds the location of the system flags and is used when you want to change a certain flag. For now, we won't do anything to it.<br /> | '''IY''' is another index register. It holds the location of the system flags and is used when you want to change a certain flag. For now, we won't do anything to it.<br /> | ||
4. '''Allocation in program''' | 4. '''Allocation in program''' | ||
− | + | calendar: | |
.db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||
.db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||
Line 55: | Line 55: | ||
ld HL,(label1) | ld HL,(label1) | ||
;HL should now contain $00A1 | ;HL should now contain $00A1 | ||
− | + | label1: | |
.dw $00A1 | .dw $00A1 | ||
Line 62: | Line 62: | ||
ld HL,(label1) | ld HL,(label1) | ||
;HL should now contain $00A1 | ;HL should now contain $00A1 | ||
− | + | label1: | |
.db $A1,0 | .db $A1,0 | ||
Latest revision as of 05:49, 10 March 2017
1. It tells the compiler to start the program counter at 1.
2. It would automatically start with 0.
3.
8 bit registers
A is also called the "accumulator". It is the primary register for arithmetic operations and accessing memory.
B is commonly used as an 8-bit counter.
C is used when you want to interface with hardware ports.
D is not normally used in its 8-bit form. Instead, it is used in conjuncture with E.
E is again, not used in its 8-bit form.
F is known as the flags. It is the one register you cannot mess with on the byte level. Its uses will be discussed later in the Flags and Bit Level Instructions Section.
H is another register not normally used in 8-bit form.
L is yet another register not normally used in 8-bit form.
16 Bit Registers
AF is not normally used because of the F, which is used to store flags.
BC is used by instructions and code sections that operate on streams of bytes as a byte counter. Is also used as a 16 bit counter.
DE holds the address of a memory location that is a destination.
HL The general 16 bit register, it's used pretty much everywhere you use 16 bit registers. Its most common uses are for 16 bit arithmetic and storing the addresses of stuff (strings, pictures, labels, etc.). Note that HL usually holds the original address while DE holds the destination address.
IX is called an index register. Its use is similar to HL, but its use should be limited as it has other purposes, and also runs slower than HL.
IY is another index register. It holds the location of the system flags and is used when you want to change a certain flag. For now, we won't do anything to it.
4. Allocation in program
calendar: .db 0,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Saferam areas
calendar equ AppBackupScrn
5. Instead of containing $00A1, HL instead now contains $A100 because of the little-endian processor. Here's a possible sample code:
ld HL,(label1) ;HL should now contain $00A1 label1: .dw $00A1
This is also acceptable:
ld HL,(label1) ;HL should now contain $00A1 label1: .db $A1,0