You are on page 1of 18

Experiments on 8085A P

zBlock Data Transfer z8 Bit Addition z16 Bit addition zSubtraction zMultiplication zDivision

1 10/14/2010

Introduction
z

Ten bytes of Hexadecimal numbers are stored in consecutive memory locations starting from 2000H. Write an assembly language program to move data to a new memory location starting from 2800H. Registers used B,C,D,E,H,L Flags affected S,Z,P Data in 2000H-200AH Data to be sent to 2880H-288AH
2 10/14/2010

z z z z

Start

Flow Chart

Set up Index for source (HL reg pair) Set up index for destination ( DE reg pair) Make a counter (reg B)

LXI H 2000H LXI D 2880H MVI, B 0AH

Get Data from memory location

* MOV A, M

Store it in new memory location

STAX D

Increment Source index (HL HL + 1) Increment Destination index ( DE DE + 1) Decrement counter (B B 1)

INX H INX D DCR B

No
Is count (B) = 0 ?

Yes
END

3 10/14/2010

Program
Memory Location Mnemonics 2000 2001 200A 2010 LXI H,2000H 2011 2012 2013 LXI D,2880H 2014 2015 2016 MVI B,0A 2017 2018 MOV A,M* 2019 STAX D 201A INX H 201B INX D Hex. Codes Remark Data bytes loaded from 2000H 200AH Set up HL as an index for source memory Set up DE as an index for destination use B as a counter for 10 bytes get data from memory store at new location point HL to next location point DE to next location

21 00 20 11 80 28 06 0A 7E 12 23 13

4 10/14/2010

Program
Memory Location 201C 201D 201E 201F 2020 Mnemonics DCR B JNZ * Hex. Codes 05 C2 18 20 EF,76 Remark one transfer is complete if transfer is incomplete go back to * End of program

RST or HALT

DATA: 4A,62,7F,8A,BD,AD,AE,1A,2B,14

5 10/14/2010

Assume 4 bytes of data are stored in consecutive memory locations starting from 2000H. Write a program to shift this data to a new location starting from 2800H using both direct and indirect addressing modes. DATA: 24,9A,1C,20

Direct addressing mode: Registers used: Accumulator. No. of bytes used:24


z

Memory Location 2000 2001 2002 2003 2010 2011 2012 2013 2014 2015

Mnemonics

Hex. codes DATA DATA DATA DATA 3A 00 20 32 00 28

Remarks input data in memory location 2000-2003H load contents of mem loc 2000H to accumulator. store contents of accu. in mem loc 2800H

LDA 2000 STA 2800

6 10/14/2010

Memory Location 2016 2017 2018 2019 201A 201B 201C 201D 201E 201F 2020 2021 2022 2023 2024 2025 2026 2027 2028

Mnemonics LDA 2001 STA 2801 LDA 2002 STA 2802 LDA 2003 STA 2803 RST,HALT

Hex. codes 3A 01 20 32 01 28 3A 02 20 32 02 28 3A 03 20 32 03 28 EF,76

Remarks data in mem loc 2001H is copied in accu. data in accu stored in mem loc 2801H data in mem loc 2002H is copied in accu. store the contents of the accu in mem loc 2802H data in mem loc 2003H is copied in accu data in accu is stored in mem loc 2803H end of program
7 10/14/2010

Assume 4 bytes of data are stored in consecutive memory locations starting from 2000H. Write a program to shift this data to a new location starting from 2800H using both direct and indirect addressing modes. DATA: 24,9A,1C,20

Indirect Addressing mode


z z z

Registers used: B,C,D,H and L Flag used: Z No. of bytes used: 17

Memory Location 2000 2001 2002 2003 2010 2011

Mnemonics

Hex. codes DATA DATA DATA DATA

Remarks input data in memory location 2000-2003H uses D as a counter


8 10/14/2010

MVI D,04

16 04

Memory Location 2012 2013 2014 2015 2016 2017 2018 2019 201A 201B 201C 201D 201E 201F 2020

Mnemonics LXI H, 2000H LXI B, 2800H

Hex. codes 21 00 20 01 00 28 7E 02 23 03 15 C2 18 20 EF,76

Remarks mem add 2000H is in HL,used as a memory pointer memory address 2800H is loaded in BC reg pair used as destination move 1st data to accu. store in new location inc mem loc to 2001H inc 2800H to 2801H decr counter by 1 check for counter if 0 end else go to mem loc 2018 end of program

MOV A,M STAX B INX H INX B DCR D JNZ *

RST,HALT

9 10/14/2010

Addition of Two Hexadecimal numbers


Develop a program to find sum of two hex numbers as per instructions 8-bit addition ignoring carry using register-register addressing, sum Stored in register/memory location 8 bit addition without and with carry using immediate, direct and indirect addressing modes Addition of 10 8-bit numbers stored in mem loc 2000-200A H, Store The sum and carry if any in mem loc 200B and 200C H Find the sum of first 10 natural numbers Registers used: Accumulator, B, C, D, E, H, L Flags affected: S, Z, CY Data in memory/register Sum/Carry in memory/register

10 10/14/2010

Immediate addressing mode


MEMORY LOCATION

MNEMONICS MVI A, data (1) MVI B, data(2) ADD B MOV C,A RST5 or HALT STA 2009

HEX. CODES

REMARKS load 1st number in the accumulator immediately load 2nd number in register B immediately add the two numbers see the result in reg C end of program see the result in memory location 2009H end of program result
11 10/14/2010

2000 2001 2002 2003 2004 2005 2006 2005 2006 2007 2008 2009

3E N1 06 N2 80 79 EF,76 32 09 20

RST5

EF N1+N2

Indirect addressing mode


Memory Location Mnemonics Hex. Codes Remarks

2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B MOV A,M INX H ADD M INX H MOV M,A RST5 or HALT LXI H,2000H

N1 N2 N1+N2 21 00 20 7E 23 86 23 77 EF,76

1st Number 2nd Number Sum load the address of N1 in HL pair, used as a memory index or pointer move 1st number to accu. point to the 2nd number add the two numbers point to the next location shift accu contents 2002 end of program
12 10/14/2010

A simple 8085 program

1+ 2 + ...+ n, ori
i =1

Algorithm 1: 2: 3: 4: sum=0,i=0 sum=sum+i, i=i+1 IF in THEN GOTO 2 total=sum


13 10/14/2010

LDA MOV XRA Loop: ADD DCR JNZ STA

n B,A A B B Loop total

i= n sum=A

A=0

sum=sum+i i=i-1 IF in THEN GOTO Loop total=sum

14 10/14/2010

Start Bring contents of memory to A Copy contents of A to B (Make a counter showing n = i) LDA 2000H MOV B, A

Clear the A for addition

XRA A

ADD B Decrement counter (B B 1)

INX H DCR B

No
Is register content (B) =0?

Yes
Store sum in new memory location STA 2001 H

END

15 10/14/2010

Summary
State what has been learned z Define ways to apply this training session z Request feedback of training session
z

16 10/14/2010

Where to Get More Information


Other training sessions z List books, articles, electronic sources z Consulting services, other sources
z

17 10/14/2010

Resources
z

Brey, Barry B. Intel Microprocessors: Architecture, Programming and Interfacing. Prentice Hall, 2000. ISBN 0-13-995408-2 Gaonkar, Ramesh S. Microprocessor Architecture, Programming, and Applications with the 8085. Toronto: Collier Macmillan Canada Inc., 1999. ISBN 0-13901257-5 Haskell, Richard E. Introduction to Computer Engineering: Logic Design and the 8086 Microprocessor. Prentice Hall, 1993. ISBN 0-13-489436-7 Smyth, Graham and Christine Stephenson. Computer Engineering: An Activity-Based Approach. Toronto: Holt Software Associates, 2000. ISBN 0-921598-36-X

18 10/14/2010

You might also like