Miscellaneous Instructions

z80 » Intermediate

There are four small instructions that are very handy but I can't really categorize.

ccf
		
Compliment Carry Flag - Inverts the carry flag.
cpl
		
ComPLiment accumulator - Inverts all bits in a. If a was %11001111 then it would now be %00110000.
neg
NEGate accumulator - If a was 2 then it's now -2. See the Two's Compliment Section.
scf
Set Carry Flag - No real reason but just thought I'd tell you. Maybe use it for return conditions on routines, like if there was an error during the routine, it would set the accumulator, then the user could see if there was an error by checking the carry flag.
ldir
LoaD (de) with (hl), Decrement bc, Increment de and hl, and Repeat until bc is zero. It's basically a block copy. It copies bc size to copy (amount of bytes from hl to de).
	ld hl,source_code
	ld de,destination_code
	ld bc,source_code_end-source_code
	ldir


More from z80 » Intermediate
All the Flags // Debugging // Down-Left Bug // _GetKey Codes // Logical Operators // Memory, ROM, RAM, and Safe Areas // Miscellaneous Instructions // PC and SP // Random Numbers // TI's ROM Calls // Restart Commands // Simulated 16-bit Addition // The Stack // Tables and Arrays // Text Display // Variables