22
Introduction to 8085 Introduction to 8085 Assembly Language Assembly Language Programming Programming

Mp Ch5 Introduction to 8085 Assembly Language Programming

Embed Size (px)

Citation preview

Page 1: Mp Ch5 Introduction to 8085 Assembly Language Programming

Introduction to 8085 Assembly Introduction to 8085 Assembly Language ProgrammingLanguage Programming

Page 2: Mp Ch5 Introduction to 8085 Assembly Language Programming

7-2

Assembly ProcessConvert 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

Page 3: Mp Ch5 Introduction to 8085 Assembly Language Programming

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

Page 4: Mp Ch5 Introduction to 8085 Assembly Language Programming

8085 inst Classification

• The instruction set is classified into the following five functional categories:

1. Data transfer (copy) operations2. Arithmetic operations3. Logical operations4. Branching operations5. Machine control operations

Page 5: Mp Ch5 Introduction to 8085 Assembly Language Programming

Data transfer (copy) operation

• Copying data from source to destination without modifying the contents of the source

• The data is transferred :1. Between registers2. Specific data byte to reg. or mem loc3. Between mem loc and registers4. Between an I/O device and accumulator

Page 6: Mp Ch5 Introduction to 8085 Assembly Language Programming

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 accumulatoraccumulator

– Subtraction - Subtracting any 8-bit numbers, mem loc, or reg. content can be subtracted from the contents of the accumulator (using 2’s complement)

– Increment / Decrement

Page 7: Mp Ch5 Introduction to 8085 Assembly Language Programming

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.

Page 8: Mp Ch5 Introduction to 8085 Assembly Language Programming

Branching Operations

• (conditional and noncondithional(• Jump: conditional jump, decision making,

Z, CY flags.• Call, return, and restart

Page 9: Mp Ch5 Introduction to 8085 Assembly Language Programming

Machine control operations

Halt, Interrupt, or do nothing

Page 10: Mp Ch5 Introduction to 8085 Assembly Language Programming

Data format

• The instruction consists of the following tow parts:

– Operation code (opcode)– Operand

Page 11: Mp Ch5 Introduction to 8085 Assembly Language Programming

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)

Page 12: Mp Ch5 Introduction to 8085 Assembly Language Programming

One – byte instruction

• Includes the opcode and operand in the same byte, such as

TaskopcodeoperandBinary code

Hex code

Copy the contents of acc to reg. CMOVC, A0100 11114FH

Add the cont. of reg. B to the Acc.ADDB1000 000080H

Complement the contents of the acc.

CMA----0010 11112FH

Page 13: Mp Ch5 Introduction to 8085 Assembly Language Programming

Tow Byte Instructions

• The first byte specifies the opcode and the second specifies the operand

TaskopcodeoperandBinary codeHex code

Load an 8-bit data byte in the acc.

MVIA, DATA 0011 1110DATA

3EHDATA

Page 14: Mp Ch5 Introduction to 8085 Assembly Language Programming

Three byte instruction

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

TaskopcodeoperandBinary codeHex code

Transfer the prog sequ. To the mem loc 2085H

JMP2085H1100 00111000 01010010 0000

C3H85H20H

Page 15: Mp Ch5 Introduction to 8085 Assembly Language Programming

Data Format

• ASCII Code• BCD Code• Signed Integer• Unsigned Integers

Page 16: Mp Ch5 Introduction to 8085 Assembly Language Programming

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

Page 17: Mp Ch5 Introduction to 8085 Assembly Language Programming

• FLOW CHART

End

Start

Load Hexadecimal Numbers

Add Numbers

Display Sum

Page 18: Mp Ch5 Introduction to 8085 Assembly Language Programming

MVI A,32H ; Load the Register A with 32H

MVI B,48H ; Load the Register B with 48H

ADD B ; Add the 2 bytes and save res in A

OUT 01H ; Display the acc. Contents at port 01H

HALT ; End

Page 19: Mp Ch5 Introduction to 8085 Assembly Language Programming

Mnemonics Hex Code

MVI A,32H 3E32

MVI B,48H 0648

ADD B 80OUT 01H D3

01HALT 67

CONVERTING FROM ASSEMBLY LANGUAGE TO HEX CODE

Page 20: Mp Ch5 Introduction to 8085 Assembly Language Programming

STORING IN MEMORY AND CONVERTING FROM HEX STORING IN MEMORY AND CONVERTING FROM HEX CODE TO BINARY CODECODE 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:

1. Reset the system2. Enter the first memory address using Hex key where

the program should be stored say 2000H3. Enter each machine code by pushing Hex Key, for

example to enter the first 3EH, press 3, then E, then STORE keys.

4. Repeat step 3 untill the last machine code 5. Reset the system.

Page 21: Mp Ch5 Introduction to 8085 Assembly Language Programming

• How hex code converted into binary ??

Mnemonics Hex Codememory contents Mem AddMVI A,32H 3E 0 0 1 1 1 1 1 0 2000

32 0 0 1 1 0 0 1 0 2001MVI B,48H 06 0 0 0 0 0 1 1 0 2002

48 0 1 0 0 1 0 0 0 2003ADD B 80 1 0 0 0 0 0 0 0 2004OUT 01H D3 1 1 0 1 0 0 1 1 2005

01 0 0 0 0 0 0 0 1 2006HLT 76 0 1 1 1 1 1 1 0 2007

Page 22: Mp Ch5 Introduction to 8085 Assembly Language Programming

8085 Mnemonics

Hex Code

Binary Code

Flow Chart

ManualLookup

Monitor Program

To memory for Storage