WordPress Websites for Engineers: Elevate Your Brand
Assembly language i
1. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Introduction to the Assembly Language
Programming - I
CSE Department, THDC-IHET
February 25, 2014
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
2. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Table of contents
1
The 8085 Programming Model
2
Instruction Classification
3
Instruction, Data Format, and Storage
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
3. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
The 8085 Programming Mode
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
4. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
8085 Hardware Model
The hardware model in previous figure shows two major
segments
One segment includes the ALU and an 8-bit register called an
accumulator, instruction decoder and flags.
The second segment shows 8-bit and 16-bit registers.
The arithmetic and logical operations are performed in the
ALU
Results are stored in the accumulator
There are three buses: a16-bit unidirectional address bus, an
8-bit bidirectional data bus and a control bus.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
5. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
8085 Programming Model
The programming model consists of some segments of the
ALU and the registers.
The model includes six registers, one accumulator, and one
flag register. In addition it has two 16-bit registers: the stack
pointer and the program counter.
Registers:
The 8085 has six general purpose registers to store 8-bit data.
They are identified as B, C, D, E, H, L. They can combine as
register pairs BC, DE, and HL to perform some 16-bit
operations.
The programmer can use these registers to store or copy data
into the registers by using data copy instruction.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
6. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
8085 Programming Model (contd..)
Accumulator:
The Accumulator is an 8-bit register that is part of the
arithmetic/logic unit (ALU).
This register is used to store 8-bit data and to perform
arithmetic and logical operations
The result of an operation is stored in the accumulator.
Flags:
S- Sign flag After the execution of an arithmetic or logic
operation, if bit D7 of the result is 1, the sign flag is set. In a
given byte if D7 is 1 it will be considered negative ,if D7 is 0 it
is considered positive.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
7. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
8085 Programming Model (contd..)
Z- Zero flag The zero flag is set if the ALU operation results
in 0.
AC- Auxiliary carry flag In an arithmetic operation, when a
carry is generated by digit D3 and passed on to digit D4 , the
AC flag is set.
P- Parity flag After an arithmetic operation if the result has
even no. of 1s the flag is set. If it has odd nos of 1s, the flag
is reset.
CY- Carry flag If an arithmetic operation results in a carry,
the carry flag is set: otherwise it is reset.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
8. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Programming Counter (PC) and Stack Pointer (SP)
These are 2 16-bit registers used to hold memory addresses.
The size of these registers is 16-bits because memory
addresses are 16 bits.
PC register is used to sequence the execution of the
instruction. The function of the PC is to point to the memory
address from which the next byte is to be fetched.
PC incremented by 1 to point to next memory location after a
machine code has been fetched.
The SP points to a memory location in R/W memory, called
the stack.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
9. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
The 8085 Instruction set
An instruction is a binary pattern designed inside a microprocessor
to perform a specific function. The entire group of instructions is
called an instruction set. The 8085 instructions can be classified
into the following five functional categories
Data transfer (copy) operations
Arithmetic operations.
logical operations.
branching operations and
machine-control operations.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
10. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Data transfer (copy) operations
This group of instruction copies data from a location called a
source to another location called the destination, without
modifying the contents of the source .The various types of data
transfer are listed below together with examples of each type
Between registers- Eg. Copy the contents of register B into
register D
Specific data byte to a register or a memory location- Eg.
Load register B with data byte 32H
Between a memory location and a register- Eg. From the
memory location 2000H to register B.
Between an I/O device and the accumulator- Eg. From an
input keyboard to the accumulator.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
11. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Arithmetic Operations
Addition- Any 8 bit number, or the contents of a register, or
the contents of a memory location can be added to the
contents of the accumulator and the sum is stored in the
accumulator.
Subtraction- Any 8 bit number, or the contents of a register,
or the contents of a memory location can be subtracted from
the contents of the accumulator and the result is stored in the
accumulator.
Increment/Decrement- Any 8 bit number, or the contents
of a register, or the contents of a memory location can be
incremented or decremented by 1.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
12. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Logical Operations
AND, OR, Exclusive- OR- Any 8 bit number, or the
contents of a register, or the contents of a memory location
can be logically ANDed, ORed, or Exclusive ORed with the
contents of the accumulator and the result is stored in the
accumulator.
Rotate- Each bit in the accumulator can be shifted either left
or right to the next position.
Compare- Any 8 bit number, or the contents of a register, or
the contents of a memory location can be compared for
equality, greater than, or less than, with the contents of the
accumulator.
Complement- The content of the accumulator can be
complemented: all 0s are replaced by 1s and all 1s are
replaced by 0s.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
13. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Branching Operations
The group of instructions alters the sequence of program execution
either conditionally or unconditionally.
Jump- Conditional jumps are an important aspect of the
decision- making process in programming. These instructions
test for a certain condition and alter the program sequence
when the condition is met.
Call, Return and Restart- These instruction change the
sequence of a program either by calling a subroutine or
returning from a subroutine.
Machine Control Operation These instruction control machine
functions such as halt, Interrupt or do nothing.
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
14. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Instruction Word Size
The 8085 instruction set is classified into the following three
groups according to the word size or byte size. In the 8085 “byte”
and “word” are synonymous.
1-byte instructions
2-byte instructions
3-byte instructions
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
15. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
One-Byte instruction
A 1-byte instruction includes the opcode and the operand in the
same byte. For example
Task 1
Task: Copy the contents of ACM in reg. C
Opcode: MOV
Operand: C,A
Binary Code: 0100 1111
Hex Code: 4FH
Task 2
Task: Add the contents of reg. B to the contents of the ACM
Opcode: ADD
Operand: B
Binary Code: 1000 0000
Hex Code: 80H
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
16. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Two-Byte instruction
In a 2-byte instruction first byte specifies the opcode and second
byte specifies the operand For example:
Task 1
Task: Load an 8-bit data byte in the ACM
Opcode: MVI
Operand: A,32H
Binary Code: 0100 1111 first byte
0011 0010 second byte
Hex Code: 3E first byte
32 second byte
Task 2
Task: Load an 8-bit data byte in register B
Opcode: MVI
Operand: B, F2H
Binary Code: 0000 0110 first byte
1111 0010 second byte
Hex Code: 06 first byte
F2 THDC-IHET
CSE Department, second byte Introduction to the Assembly Language Programming - I
17. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Three-Byte instruction
In a 3-byte instruction first byte specifies the opcode and later two
bytes specifies the 16-bit address, For example:
Task 1
Task: Load contents of memory 2050H into A
Opcode: LDA
Operand: 2050H
Binary Code: 0011 1010 first byte
0101 0000 second byte
0010 0000 third byte
Hex Code: 3A first byte
50 second byte
20 third byte
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
18. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Opcode Format
In the design of the 8085 microprocessor chip, all operations,
registers, and status flags are identified with a specific code. For
example, all internal registers are identified as follows:
Code
Registers
000
B
001
C
010
D
011
E
100
H
101
L
111
A
110 Reserved for memory related operation
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
19. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Opcode Format Contd..
Code Register pair
00
BC
01
DE
10
HL
11
AF OR SP
Some of the operations codes are identified as follows
Function
Operation Code
1. Rotate each bit of the ACM 00000111 = 07H
to the left by one position
2. Add the contents of a regis- 10000 SSS (5-bit
ter to the accumulator
opcode- 3bits reserved for a register
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
20. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Opcode Format Contd..
This instruction is completed by adding the code of the
register. For example
Add
Register B
to A
Binary Instruction
: 10000
: 000
: Implicit
: 10000 000 = 80H
: Add Reg. B
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
21. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Data Format
The 8085 is an 8-bit µ processor and it processes only binary
numbers. However, the real world operates in decimal numbers
and languages of alphabets and characters. In 8-bit processor
systems, commonly used codes and data formats are
ASCII
BCD
Signed integers and
Unsigned integers
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
22. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
Data Format (Contd..)
ASCII code: This is a 7-bit alphanumeric code that
represents decimal nos, English alphabets and non-printable
characters.
BCD code: The term BCD stands for binary coded decimal:
it is used for decimal numbers. The decimal numbering
system has ten digits, 0 to 9. Therefore, we need only four
bits to represent ten digits.
Signed integers : A signed integer is either a positive
number or a negative number. In an 8-bit processor the MSB
is used for the sign; 0 represents the positive sign and 1
represents the negative sign.
Unsigned integers An integer without a sign can be
represented by all the 8-bits in a microprocessor register
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I
23. The 8085 Programming Model
Instruction Classification
Instruction, Data Format, and Storage
THANK YOU
CSE Department, THDC-IHET
Introduction to the Assembly Language Programming - I