Philippine College of Science and Technology: Assignment 2 Assembly Language Programming Building Microprocessor
Philippine College of Science and Technology: Assignment 2 Assembly Language Programming Building Microprocessor
Assignment 2
An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire
group of instructions, called the instruction set, determines what functions the microprocessor can perform.
These instructions can be classified into the following five functional categories: data transfer (copy) operations,
arithmetic operations, logical operations, branching operations, and machine-control operations.
2. Arithmetic Group
-The arithmetic instructions add, subtract, increment, or decrement data in registers or memory.
3.Logical Group
-This group performs logical (Boolean) operations on data in registers and memory and on condition flags. The
logical AND, OR, and Exclusive OR instructions enable you to set specific bits in
5. Find for the instruction set for 8085 and Z80 microprocessor. This is needed for you to hand
assemble a given program in the 8085 and Z80 instruction and be able to determine the
Machine code of each instruction.
The Z80 uses 252 out of the available 256 codes as single byte opcodes ("root instruction"); the four remaining
codes are used extensively as opcode prefixes:[30] CB and ED enable extra instructions and DD or FD selects
IX+d or IY+d respectively (in some cases without displacement d) in place of HL. This scheme gives the Z80 a
large number of permutations of instructions and registers; Zilog categorizes these into 158 different
"instruction types", 78 of which are the same as those of the Intel 8080[30] (allowing operation of most 8080
programs on a Z80). The Zilog documentation further groups instructions into the following categories:
8-bit arithmetic and logic operations
16-bit arithmetic
8-bit load
16-bit load
Bit set, reset, and test
Call, return, and restart
Exchange, block transfer, and search
General purpose arithmetic and CPU control
Input and output
Jump
Rotate and shift
The index registers, IX and IY, were intended as flexible 16 bit pointers, enhancing the ability to manipulate
memory, stack frames and data structures. Officially, they were treated as 16-bit only. In reality they were
implemented as a pair of 8-bit registers,[33] in the same fashion as the HL register, which is accessible either as
16 bits or separately as the High and Low registers. The binary opcodes (machine language) were identical, but
preceded by a new opcode prefix.[34] Zilog published the opcodes and related mnemonics for the intended
functions, but did not document the fact that every opcode that allowed manipulation of the H and L registers
was equally valid for the 8 bit portions of the IX and IY registers. For example, the opcode 26h followed by an
immediate byte value (LD H,n) will load that value into the H register. Preceding this two-byte instruction with
the IX register's opcode prefix, DD, would instead result in the most significant 8 bits of the IX register being
loaded with that same value. A notable exception to this would be instructions similar to LD H,(IX+d) which
make use of both the HL and IX or IY registers in the same instruction;[34] in this case the DD prefix is only
applied to the (IX+d) portion of the instruction. The halves of the XY registers could also hold operands for 8-bit
arithmetic, logical and compare instructions, sparing the regular 8-bit registers for other use. The
undocumented ability to increment and decrement the upper half of an index register made it easy to expand
the range of the normal indexed instructions, without having to resort to the legal ADD/SBC XY,DE or ADD/SBC
XY,BC.
There are several other undocumented instructions as well.[35] Undocumented or illegal opcodes are not
detected by the Z80 and have various effects, some of which are useful. However, as they are not part of the
formal definition of the instruction set, different implementations of the Z80 are not guaranteed to work the
same way for every undocumented opcode.