Unit II Assembly
Unit II Assembly
Assembly languages generally lack high-level conveniences such as variables and functions, and
they are not portable between various families of processors. They have the same structures and
set of commands as machine language, but allow a programmer to use names instead of
numbers. This language is still useful for programmers when speed is necessary or when they
need to carry out an operation that is not possible in high-level languages.
Assembly language is specific to a given processor. For e.g. assembly language of 8085 is different
than that of Motorola 6800 microprocessor.
1
Classification of Instructions
An instruction is a binary pattern designed inside a microprocessor to perform a specific function.
The entire group of instructions that a microprocessor supports is called Instruction Set. 8085
has 246 instructions. Each instruction is represented by an 8-bit binary value. These 8-bits of
binary value is called Op-Code or Instruction Byte.
Arithmetic Instructions
These instructions perform the operations like:
- Addition
- Subtract
- Increment
- Decrement
Any 8-bit number, or the contents of register, or the contents of memory location can be added
to the contents of accumulator. The result (sum) is stored in the accumulator. No two other 8-bit
registers can be added directly.
Any 8-bit number, or the contents of register, or the contents of memory location can be
subtracted from the contents of accumulator. The result is stored in the accumulator. No two
other 8-bit registers can be subtracted directly.
The 8-bit contents of a register or a memory location can be incremented or decremented by 1.
The 16-bit contents of a register pair can be incremented or decremented by 1. Increment or
decrement can be performed on any register or a memory location.
Logical Instructions
These instructions perform logical operations on data stored in registers and memory.
The logical operations are:
- AND
- OR
- XOR
- Rotate
- Compare
- Complement
2
AND, OR, XOR
Any 8-bit data, or the contents of register, or memory location can logically have AND operation,
OR operation, XOR operation with the contents of accumulator. The result is stored in
accumulator.
Rotate
Each bit in the accumulator can be shifted either left or right to the next position.
Compare
Any 8-bit data, or the contents of register, or memory location can be compares for:
- Equality
- Greater Than
- Less Than
with the contents of accumulator.
Complement
The contents of accumulator can be complemented. Each 0 is replaced by 1 and each 1 is replaced
by 0.
Branching Instructions
Branching instructions refer to the act of switching execution to a different instruction sequence
as a result of executing a branch instruction.
The three types of branching instructions are:
- Jump
- Call
- Return
Jump Instructions
The jump instruction transfers the program sequence to the memory address given in the
operand.
JMP 2050 (Jumps to the address 2050)
Call Instructions
The call instruction transfers the program sequence to the memory address given in the operand.
Before transferring, the address of the next instruction after CALL is pushed onto the stack.
CALL 2050 (Transfers program sequence to address 2050)
Return Instructions
The return instruction transfers the program sequence from the subroutine to the calling
program.
RET (Return from the subroutine)
Control Instructions
The control instructions control the operation of microprocessor.
3
Examples:
NOP (No operation is performed)
HLT (The CPU finishes executing the current instruction and halts any further execution)
DI (Disable Interrupts)
EI (Enable Interrupts)
4
MOV B, E Register B E
MOV B, H Register B H
MOV B, L Register B L
MOV C, A Register C A
MOV C, B Register C B
MOV C, C Register C C
MOV C, D Register C D
MOV C, E Register C E
MOV C, H Register C H
MOV C, L Register C L
MOV D, A Register D A
MOV D, B Register D B
5
MOV E, L Register E L
MOV H, A Register H A
MOV H, B Register H B
MOV H, C Register H C
MOV H, D Register H D
MOV H, E Register H E
MOV H, H Register H H
MOV H, L Register H L
MOV L, A Register L A
MOV L, B Register L B
MOV L, C Register L C
MOV L, D Register L D
MOV L, E Register L E
MOV L, H Register L H
MOV L, L Register L L
It moves / copies the data stored in
memory location whose address is
given in H-L register pair, to the given
MOV A, M Register indirect A M H L register.
6
MOV L, M Register indirect L M H L
This instruction moves / copies
the data in the given register to
the memory location addressed
MOV M, A Register M H L A by H-L register pair.
indirect
MOV M, C Register M H L C
indirect
MOV M, H Register M H L H
indirect
7
Arithmetic Group of Instructions
8
ADC D Register A A D CY
ADC E Register A A E CY
ADC H Register A A H CY
ADC L Register A A L CY
adds the content of memory
location whose address is given
in H-L register pair to the
accumulator with carry and the
ADC M Register A A M H L CY answer is stored in accumulator.
indirect
DAD D Register DE DE DE
DAD H Register HL HL HL
9
subracts the content of memory
location whose address is given in H-L
register pair with the accumulator and
SUB M Register A A M H L the answer is stored in accumulator.
indirect
indirect
SBI data Immediate A A data CY Subtract immediate with borrow
10
INR D Register D D 1
INR H Register H H 1
indirect
INX D Register DE DE 1
INX H Register HL HL 1
11
Decrements contents of memory address given
DCR M Register M H L M H L 1 by H-L pair by 1
indirect
DCX D Register DE DE 1
DCX H Register HL HL 1
12
ANA D Register A A.AND.D
Indirect
13
ORA E Register A A.OR.E
14
XRA L Register A¬ A XOR L
CMP B Register
CMP C Register
CMP D Register
CMP E Register
CMP H Register
CMP L Register
Indirect
15
The execution of this instruction inverts
A A COM
each bit of the accumulator contents and
CMA --- the result is saved in the accumulator.
Branching Group
Z=1.
16
Calls subroutine program
CNC addr Immediate if
CY=1.
17
Returns to main program
RP Register if
indirect S=0.
18
19