Anda di halaman 1dari 22

Introduction to 8085 Assembly Language Programming

Assembly Process
Convert assembly language file (.asm) into an executable file (.obj) for the LC-3 simulator.

First Pass:
* scan program file * find all labels and calculate the corresponding addresses; this is called the symbol table

Second Pass:
* convert instructions to machine language, using information from symbol table
7-2

Instruction Classification
Instruction: is a binary pattern designed inside p to perform a specific function. Instruction Set: is the entire group of instructions 8085 is upward compatible

8085 inst Classification


1. 2. 3. 4. 5. The instruction set is classified into the following five functional categories: Data transfer (copy) operations Arithmetic operations Logical operations Branching operations Machine control operations

Data transfer (copy) operation


Copying data from source to destination without modifying the contents of the source The data is transferred : Between registers Specific data byte to reg. or mem loc Between mem loc and registers Between an I/O device and accumulator

1. 2. 3. 4.

Arithmetic operations
Perform arithmetic operations such as:
Addition adding any 8-bit numbers, mem loc, or reg. content can be added to the contents of the accumulator Subtraction - Subtracting any 8-bit numbers, mem loc, or reg. content can be subtracted from the contents of the accumulator (using 2s complement) Increment / Decrement

Logical operations
AND, OR, Exclusive OR:- ANDing, ORing, or XORing any 8-bit numbers, mem loc, or reg. content can be ANDed, ORed, or XORed with the contents of the accumulator Rotate: shifting the bits in the accumulator Compare: (=, <, >, with the contents of acc.) Complement: complementing the cont. of acc.

Branching Operations
(conditional and noncondithional) Jump: conditional jump, decision making, Z, CY flags. Call, return, and restart

Machine control operations

Halt, Interrupt, or do nothing

Data format

The instruction consists of the following tow parts:


Operation code (opcode) Operand

Instruction Word Size


The 8085 instructions are classified as follows:
One word or 1 byte instruction Tow word or 2 byte instruction Three word or 3 word instruction ( Word = 1 byte in 8085)

One byte instruction


Includes the opcode and operand in the same byte, such as
Task opcode operand Binary code Hex code

Copy the contents of acc to reg. C


Add the cont. of reg. B to the Acc. Complement the contents of the acc.

MOV
ADD CMA

C, A
B ----

0100 1111
1000 0000 0010 1111

4FH
80H 2FH

Tow Byte Instructions


The first byte specifies the opcode and the second specifies the operand
Task Load an 8-bit data byte in the acc. opcode operand Binary code Hex code MVI A, DATA 0011 1110 DATA 3EH DATA

Three byte instruction


The first byte specifies the opcode and the next two bytes specify 16 bit address

Task Transfer the prog sequ. To the mem loc 2085H

opcode operand Binary code Hex code JMP 2085H 1100 0011 1000 0101 0010 0000 C3H 85H 20H

Data Format

ASCII Code BCD Code Signed Integer Unsigned Integers

Writing, Assembling and Execution of Assembly programs


Add two hex. Numbers
PROBLEM STATEMENT Write instruction to load 2 hex no. 32H and 48H in reg. A and B respectively, Add the numbers and display the sum at the led output port1 PROBLEM ANALYSIS Divide the problem into small steps as follows
Load the numbers in the registers Add the numbers Display the sum at the output port PORT1

FLOW CHART

Start

Load Hexadecimal Numbers

Add Numbers

Display Sum

End

MVI A,32H MVI B,48H ADD B OUT 01H HALT

; Load the Register A with 32H ; Load the Register B with 48H ; Add the 2 bytes and save res in A ; Display the acc. Contents at port 01H ; End

CONVERTING FROM ASSEMBLY LANGUAGE TO HEX CODE

Mnemonics MVI A,32H

Hex Code 3E 32 06
48

MVI B,48H
ADD B OUT 01H HALT

80 D3 01 67

STORING IN MEMORY AND CONVERTING FROM HEX CODE TO BINARY CODE


Assume that R/W memory range from 2000H to 20FFH and the system has LED output port with the address 01H now to enter the program: Reset the system Enter the first memory address using Hex key where the program should be stored say 2000H Enter each machine code by pushing Hex Key, for example to enter the first 3EH, press 3, then E, then STORE keys. Repeat step 3 untill the last machine code Reset the system.

1. 2. 3.

4. 5.

How hex code converted into binary ??


Mnemonics MVI A,32H MVI B,48H ADD B OUT 01H D3 HLT Hex Code memory contents 3E 0011 1110 32 0011 0010 06 0000 0110 48 0100 1000 80 1000 0000 1101 0011 01 0000 0001 76 0111 1110 Mem Add 2000 2001 2002 2003 2004 2005 2006 2007

Flow Chart 8085 Mnemonics

Manual Lookup Hex Code

Monitor Program Binary Code

To memory for Storage

Anda mungkin juga menyukai