0% found this document useful (0 votes)
33 views15 pages

Assembly Language

This document discusses microprocessor assembly language programming and instruction sets. It describes how microprocessors use binary machine language and how assembly language was developed using mnemonics to provide a simpler way for humans to program microprocessors. It also discusses microprocessor instruction formats, including 1-byte, 2-byte, and 3-byte instructions, and how they specify operations and operands. Finally, it outlines the different addressing modes that microprocessors use to identify operands, such as register and immediate addressing.

Uploaded by

Luke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views15 pages

Assembly Language

This document discusses microprocessor assembly language programming and instruction sets. It describes how microprocessors use binary machine language and how assembly language was developed using mnemonics to provide a simpler way for humans to program microprocessors. It also discusses microprocessor instruction formats, including 1-byte, 2-byte, and 3-byte instructions, and how they specify operations and operands. Finally, it outlines the different addressing modes that microprocessors use to identify operands, such as register and immediate addressing.

Uploaded by

Luke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

ELEC 3001

Microprocessors

Assembly Language Programming


Microprocessor Instruction Set and Languages
 Each µP has its own set instruction set. 8085 has 74 different instructions in its
instruction set.
 µPs recognize and operate on binary numbers only.

 To communicate with the µP, one must give instructions in binary language (or
Hexadecimal for convenience) - Machine Language

For example, instruction 0011 11102 or 3EH meaning Load Accumulator.

 Difficult for most people to write programs in 0s and 1s.

 µP manufacturers have devised English-like words to represent the binary


instructions of a machine – (mnemonics); Eg. LDA is used for Load Accumulator.

 A program written in these mnemonics is called an assembly language program.

 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.

 Each instruction has two parts:


 the task to be performed, called the operation code (op-code)
 the data to be operated on, called the operand.

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

TASK OPCODE OPERAN BINARY HEX


D CODE CODE

Copy the contents of Accumulator to MOV B,A 0100 0111 47


register B

Add the contents of Register B to the ADD B 1000 0000 80


contents of Accumulator

Complement (1’s) each bit in the CMA 0010 1111 2F


Accumulator

Each instruction require only one memory location for storage.


5
Instruction Format
Two-byte Instructions
First byte specifies opcode
Second byte specifies operand (normally a data byte)
TASK OPCODE OPERAN BINARY HEX
D CODE CODE

Load an 8-bit data in the accumulator MVI A, data 0011 1110 3E

Add the 8-bit data to the contents of ADI data 1100 0110 C6
Accumulator

Mnemonics First Byte Second Byte


MVI A, 32H 3E 32
ADI 20H C6 20
6
Instruction Format
Three-byte Instructions

First byte specifies opcode


Next two bytes specify operand (16-bit address or 16-bit data)
TASK OPCOD OPERAND HEX CODE
E

Transfer the program sequence to memory JMP 2025 C3 1st Byte


address 2025H 25 2nd Byte
20 3rd Byte
Load Register Pair HL with data 0520H LXI H, 0520 21 1st Byte
20 2nd Byte
05 3rd Byte

Note: 2nd Byte is low-order byte of operand


7 3rd Byte is high-order byte of operand
Addressing Modes
An “addressing mode” refers to the way that the µP finds out the operand (data)
of an instruction.

The operand can come from:

 a register
 an input port
 an 8-bit number (00H to FFH)
 a memory location

Instructions can be categorized according to their addressing modes.

The addressing modes supported by different µPs vary.

The 8085 has five addressing modes.

8
Addressing Modes
(a) Implied addressing mode

In this type of addressing mode, no operand (register or data) is specified in the


instruction.

The operand is inherent to the instruction.

Such instructions are always 1-byte instructions because further data is not
required to complete the instruction.

Examples:

 CMA (Complement contents of Accumulator)


 RAL (Rotate contents of Accumulator Left through Carry)
 STC (Set Carry Flag)
9
Addressing Modes
(b) Register Addressing

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.

Hence, immediate instructions are specified by 2 or 3 bytes.

They are convenient for loading initial values into registers.

The I in the mnemonic indicates that an instruction uses immediate addressing


mode.

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.

 MVI D, FFH (Move FFH to register D)

The LXI instruction (load register pair immediate) has 16-bit immediate data. It is
commonly used to load addresses into a register pair.

 LXI SP 2000H (Load SP with 2000H )

This instruction will appear as 31H 00H 20H in memory.

12
Addressing Modes
(d) Direct Addressing

Instructions that use direct addressing mode require 2 or 3 bytes of storage.

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:

 IN 0AH (Input to accumulator data from port 0AH)


 JMP 1000H (Jump to location 1000H)

13
Addressing Modes
(e) Register Indirect Addressing

Register indirect instructions reference memory via a register pair.

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.

Register indirect instructions are specified by 1-byte instructions.

14
Addressing Modes
Combined Addressing Modes

Some instructions use a combination of 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

You might also like