Assembly Language
Assembly Language
Microprocessors
To communicate with the µP, one must give instructions in binary language (or
Hexadecimal for convenience) - Machine Language
Machine language and assembly language are microprocessor-specific and are both
considered low-level languages.
2
Instruction Format
An instruction is a command to the microprocessor to perform a given task on
specified data.
Operand
The operand (or data) can be specified in various ways. It may consist of:
8-bit (or 16-bit) data
an internal register
a memory location
an 8-bit (or 16-bit) address.
In some instructions, the operand is implicit.
3
Instruction Format
However, instructions are commonly referred to in terms of bytes rather than
words. Hence, the 8085 µP has:
1-byte instructions
2-byte instructions
3-byte instructions
One-Byte Instructions
A 1-byte instruction includes the opcode and operand in the same byte.
Operand(s) are internal register and are coded into the instruction.
4
Instruction Format
One-byte Instructions
Add the 8-bit data to the contents of ADI data 1100 0110 C6
Accumulator
a register
an input port
an 8-bit number (00H to FFH)
a memory location
8
Addressing Modes
(a) Implied addressing mode
Such instructions are always 1-byte instructions because further data is not
required to complete the instruction.
Examples:
With these instructions, you must specify one of the registers B through E, H or L as
well as the opcode while the A is implied as a second operand.
Examples:
CMP E (Compare the contents of the E register with the contents of A)
SUB L (Subtract the contents of register L from contents of A)
Most of the instructions that use register addressing deal with 8-bit values. However,
a few of these instructions deal with 16-bit register pairs.
Example:
PCH L (exchange contents of PC with the contents of HL register pair)
Register instructions are always 1-byte instructions because further data or
addresses from outside the CPU are not required.
10
Addressing Modes
(c) Immediate Addressing
Instructions that use immediate addressing have data assembled as a part of the
instruction itself. The operand comes from the next byte (or sometimes the next
two bytes) in program memory.
Example:
CPI 08H (Compare the contents of the accumulator with 08H)
11
Addressing Modes
(c) Immediate Addressing
All but two of the immediate instructions use the accumulator as an implied
operand, as in the CPI instruction shown previously.
The MVI (move immediate) instruction can move immediate data to any of the
working registers including the accumulator or to memory.
The LXI instruction (load register pair immediate) has 16-bit immediate data. It is
commonly used to load addresses into a register pair.
12
Addressing Modes
(d) Direct Addressing
The first byte is for the instruction code, and next one or two bytes point to where
the operand is located (a port or a 16-bit address respectively).
Note: the 2nd and 3rd bytes are data in immediate addressing mode whereas they are
addresses in direct addressing mode.
Examples:
13
Addressing Modes
(e) Register Indirect Addressing
Examples:
MOV M,C
Moves contents of C register into the memory address pointed to by the contents of
HL register pair.
LDAX B
Loads accumulator with the byte of data specified by the address in BC register pair.
14
Addressing Modes
Combined Addressing Modes
Example:
CALL address
Direct addressing mode is used when the CALL instruction specifies the address of
the desired subroutine
Register indirect addressing mode is used when the CALL instruction pushes the
current contents of the program counter into the memory location specified by the
stack pointer.
15