Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

UNIT:4

Assembly Language Programming Basics


Outline:
Assembly Language Programming Basics,

Classification of Instructions,

Addressing Modes, 8085 Instruction Set,

Instruction And Data Formats,


Assembly Language Programming Basics

Hierarchy of Languages :
Compilers and Assemblers
Instructions and Machine Language
1. Each command of a program is called an instruction (it instructs the computer, what to do?).
2. Computers only deal with binary data, hence the instructions must be in binary format (0’s and
1’s).
3. Therefore, each Opcode is having unique bit pattern of (0’s and 1’s).

Instruction Fields
Assembly language instructions usually are made up of several fields. Each field specifies
different information.

The major two fields are:

Opcode: Operation code that specifies operation to be performed. Each operation has its unique
opcode.

Operands: Fields which specify, where to get the source and destination operands for the
operation specified by the opcode.
Instruction Fields
Translating Languages
Introduction to Assembly Language
Programming
An assembly language is a low-level programming language for a computer, or other
programmable device, in which there is a very strong (generally one-to-one) correspondence

between the language and the architecture’s machine code instructions .


Assembly language is converted into executable machine code by a utility program referred to
as an assembler; the conversion process is referred to as assembly, or assembling the code.

• Assembly language uses a mnemonic to represent each low-level machine operation or


opcode.

• Some opcodes require one or more operands as part of the instruction, and most assemblers
can take labels and symbols as operands to represent addresses and constants, instead of hard
coding them into the program.
Assembly Language Programming Tools :

1. Assembler : An assembler is a program that converts programs


written in assembly language into object files(machine language).
2. Linker : An assembler is a program that converts programs written
in assembly language into object files(machine language).
3. Debugger : Allows you to trace the execution of a program. Allows
you to view code, memory, registers etc.
4. Editor : Allows to create assembly language source files. Some
editors provide syntax highlighting features and can be customized
as per programming environment.
Addressing Modes
1. Immediate addressing: In immediate addressing mode, the operand is a constant value
that is part of the instruction. The immediate addressing mode is used for instructions that
require a fixed value, such as loading a constant value into a register.

2. Direct addressing: In direct addressing mode, the operand is a memory address specified
directly in the instruction. The direct addressing mode is used for instructions that access
data stored in memory.

3. Indirect addressing: In indirect addressing mode, the operand is a memory address


specified indirectly by a register or memory location. The indirect addressing mode is used
for instructions that access data stored in memory, where the memory address is not
known in advance.

4. Register addressing: In register addressing mode, the operand is stored in one of the
processor registers. The register addressing mode is used for instructions that manipulate
the contents of the registers.
1. Indexed addressing: In indexed addressing mode, the operand is obtained by
adding an offset value to a base address stored in a register. The indexed
addressing mode is used for instructions that access data stored in memory using
a computed address.

2. Relative addressing: In relative addressing mode, the operand is specified as an


offset relative to the current program counter value. The relative addressing
mode is used for instructions that perform conditional branching or looping.

3. Memory-mapped I/O addressing: In memory-mapped I/O addressing mode, the


processor accesses input/output devices using memory addresses instead of
specialized I/O instructions. Memory-mapped I/O addressing mode is used for
interfacing with peripherals such as displays, keyboards, and printers.
Classification of 8085
Instructions
Instruction Set

It is the set of instructions that the microprocessor can understand.

Opcode

Known as Operation Code.

This required field contains the mnemonic operation code for the
8085 instruction.

Operand

The operand field identifies the data to be operated on by the


specified opcode.

Some instructions require no operands, while others require one or


two operands.
General Terms :

One-byte Instruction
Two-byte Instruction :

Three-byte Instruction :
Data Transfer Instructions :
Instructions copy data from source to destination.
While copying, the contents of source is not modified.
Data Transfer Instructions do not affect the flags.

MOV: Move data from source to destination :


MVI: Load 8-bit to Register/Memory :

LDA Instruction
Arithmetic Instructions
ADD: Add register/memory to
accumulator
Branch Instructions
Logical & Bit Manipulation
Instructions
Control Instructions
Instruction And Data Formats
An instruction (instruction format) is a command to the microprocessor to perform a given
task on a particular data. Each instruction (instruction format) is of two parts. One is to be
performed, called the operation code or opcode and the second one is the data to be
operated on, called the operand. Operands or data can be specified in different ways. It may
include an 8-bit or 16-bit data, an internal register. a memory location, or it or 16-bit
address. In some instructions, the operand is implicit.

Instruction Word Size

The 8085 instruction set is of three groups according to word size:

One-word or one-byte instructions.

Two-word or two-byte instructions.

Three-word or three-byte instructions.

In the 8085 microprocessor, byte and words are synonymous because it is an 8-bit
microprocessor. But, instructions are commonly referred to in terms of bytes rather than
words.
Instruction And Data Formats
The size of 8085 instructions can be 1 byte, 2 bytes or 3 bytes. The 1-byte
instruction has an opcode alone. storing the 3 bytes instruction in memory, the
sequence of storage is, opcode first followed by low byte of address or data
and then high byte of address or data.
THANK YOU

You might also like