0% found this document useful (0 votes)
24 views96 pages

8085 MICROPROCESSOR 2078-HSMallik

The document describes a program for adding two 8-bit hexadecimal numbers in memory locations 8000 and 8001, storing the result in 8002. It provides the algorithm, code implementation, and an example run. A second program is described for adding two 8-bit decimal numbers while adjusting for decimal format. A third program is outlined for adding two 16-bit hexadecimal numbers.

Uploaded by

prabin chand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views96 pages

8085 MICROPROCESSOR 2078-HSMallik

The document describes a program for adding two 8-bit hexadecimal numbers in memory locations 8000 and 8001, storing the result in 8002. It provides the algorithm, code implementation, and an example run. A second program is described for adding two 8-bit decimal numbers while adjusting for decimal format. A third program is outlined for adding two 16-bit hexadecimal numbers.

Uploaded by

prabin chand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 96

MICROPROCESSOR 8085 -Program

Hari Shankar Mallik, PhD


Assistant Professor
Central Department of Physics, TU, Kirtipur
Nepal
8085 programming model
Registers
Program:
Examples
Program (1):

Hexadecimal addition of two 8-bit Hexadecimal numbers.

Plan:
This program will add two 8-bit hex numbers
at address 8000 and 8001.
The result is stored at address 8002.
Algorithm:

Steps:
•Initialize HL register pair with address of first
number i.e. address 8000.
•Move this number into accumulator.
•Get the second number from address 8001.
•Add second number to accumulator.
•Point the address for result.
•Move the result from accumulator to address 8002.
•Go back to monitor.
• Switch ON the given trainer kit

• Push the RESET key.

• Push the EXAM MEM key

• Enter 8000

• and press NEXT key.

• Enter and store all the codes sequentially


Address Code Label Mnemonic Operand Comments

8000 Data First number to be added

8001 Data Second number to be added

8002 00 Result

8003 Start LXI H, 8000 Point to first number


8004 00
8005 80
8006 MOV A,M Move to accumulator

8007 INX H Point to second number

8008 ADD M Add second number to


accumulator
8009 INX H Point the address for
result
800A MOV M,A Store the result

800B RST 5 Go back to monitor


Address Code Label Mnemonic Operand Comments

8000 Data First number to be added

8001 Data Second number to be added

8002 00 Result

8003 Start LXI H, 8000 Point to first number


8004 00 CODE Chart
8005 80
8006 MOV A,M Move to accumulator

8007 INX H Point to second number

8008 ADD M Add second number to


accumulator
8009 INX H Point the address for
result
800A MOV M,A Store the result

800B RST 5 Go back to monitor


Address Code Label Mnemonic Operand Comments

8000 Data First number to be added

8001 Data Second number to be added

8002 00 Result

8003 21 Start LXI H, 8000 Point to first number


8004 00
8005 80
8006 7E MOV A,M Move to accumulator

8007 23 INX H Point to second number


Add second number to
86
8008 ADD M
accumulator
8009
23 INX H Point the address for
result
800A 77 MOV M,A Store the result

800B EF RST 5 Go back to monitor


Accumulator

Memory Add Data


8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 00

Memory Add Data


8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 00

Memory Add Data


8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 00

Memory Add Data


8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 00
16
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 00
16
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 01
16
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 01
16
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 01
16+56
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 01
6C
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 01
6C
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 02
6C
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 02
6C
Memory Add Data
8000 16
8001 56
8002 00
8003
8004
.
.
Accumulator 80 02
6C
Memory Add Data
8000 16
8001 56
8002 6C
8003
8004
.
.
Accumulator 80 02
6C
Memory Add Data
8000 16
8001 56
8002 6C
8003
8004
.
.
Observations:

(a) Address Data (b) Address Data

Before Execution

8000 16 8000 AB
8001 56 8001 23

After Execution

8002 6C (Result) 8002 CE (Result)

NOTE: Carry will be neglected


Instructional Summary for Microprocessor 8085.pdf

8085 Simulator
Program (2):
Decimal addition of two 8-bit decimal numbers
(the result should not be greater than 99).

PLAN:

This program will add two 8-bit decimal numbers at address 8000 and

8001. The result is stored at address 8002.


ALGORITHM:
Steps:
1. Initialize HL register pair with address of first number i.e. address
8000.
2. Move this number into accumulator.
3. Get the second number from address 8001.
4. Add second number to accumulator.

5. Adjust the decimal.


6. Point the address for result.
7. Move the result from accumulator to address 8002.
8. Go back to monitor.
PROGRAM:
Address Code Label Mnemonic Operand Comments
8000 Data First number to be
added
8001 Data Second number to be
added
8002 Data Result

Step 1 8003 21 Start LXI H, 8000 Point to first number


8004 00
8005 80

Step 2 8006 7E MOV A,M Move to accumulator

Step 3 8007 23 INX H Point to second number


Step 4 8008 86 ADD M Add second number to
accumulator

Step 5 8009 27 DAA Convert to decimal

Step 6 800A 23 INX H Point the address for


result

Step 7 800B 77 MOV M,A Store the result

Step 8 800C EF RST 5 Go back to monitor


(a) Address Data b) Address Data

Before Execution

8000 16 8000 81
8001 56 8001 15

After Execution

8002 72 (Result) 8002 96 (Result)

Previously: in program 1

8002 6C (Result) 8002 96 (Result)


Program (3):

Addition of two 16-bit hexadecimal numbers


(neglecting the carry).

PLAN:

This program will add two 16-bit hexadecimal numbers

at address 8000, 8001, 8002 and 8003.

The result is stored at address 8004 and 8005.


ALGORITHM:

Steps:

1. Load the first number in HL pair.

2. Exchange this number to DE pair.

3. Load the second number in HL pair.

4. Add the contained of DE pair with contained of HL pair.

5. Store the result.

6. Go back to monitor.
PROGRAM:

Address Code Label Mnemonic Operand Comments


8000 LSB (1st no.) First 16-bit
8001 MSB (1st no.) number
8002 LSB (2nd no.) Second 16-
8003 MSB (2nd no.) bit number
8004 LSB (Result) Result
8005 MSB (Result)
Step 8006 2A Start LHLD 8000 Load HL pair with
1 first number
8007 00
8008 80

Step 8009 EB XCHG Exchange HL pair


2 with DE pair
Step 800A 2A LHLD 8002 Load HL pair with
3 second number
800B 02
800C 80

Step 800D 19 DAD D Add the DE with


4 HL
Step 800E 22 SHLD 8004 Store the result in
5 8004 and 8005
800F 04
8010 80

Step 2011 EF RST 5 Go back to monitor


6
(a) Address Data (b) Address Data
8000 CA (LSB1) 8000 11 (LSB1)
8001 A7 (MSB1) 8001 2A (MSB1)
8002 6B (LSB2) 8002 22 (LSB2)
8003 B9 (MSB2) 8003 2B (MSB2)

8004 35 (LSB1+
LSB2) 8004 33 (LSB1+
LSB2)
8005 61 (MSB1+
MSB2) 8005 55(MSB1+
MSB2)

XX XX
A7 CA
(a) Address Data (b) Address Data
8000 CA (LSB1) 8000 11 (LSB1)
8001 A7 (MSB1) 8001 2A (MSB1)
8002 6B (LSB2) 8002 22 (LSB2)
8003 B9 (MSB2) 8003 2B (MSB2)

8004 35 (LSB1+
LSB2) 8004 33 (LSB1+
LSB2)
8005 61 (MSB1+
MSB2) 8005 55(MSB1+
MSB2)

A7 CA
XX XX
(a) Address Data (b) Address Data
8000 CA (LSB1) 8000 11 (LSB1)
8001 A7 (MSB1) 8001 2A (MSB1)
8002 6B (LSB2) 8002 22 (LSB2)
8003 B9 (MSB2) 8003 2B (MSB2)

8004 35 (LSB1+
LSB2) 8004 33 (LSB1+
LSB2)
8005 61 (MSB1+
MSB2) 8005 55(MSB1+
MSB2)

A7 CA
B9 6B
(a) Address Data (b) Address Data
8000 CA (LSB1) 8000 11 (LSB1)
8001 A7 (MSB1) 8001 2A (MSB1)
8002 6B (LSB2) 8002 22 (LSB2)
8003 B9 (MSB2) 8003 2B (MSB2)

8004 35 (LSB1+
LSB2) 8004 33 (LSB1+
LSB2)
8005 61 (MSB1+
MSB2) 8005 55(MSB1+
MSB2)

A7 CA
B9 +A7 6B +CA
(a) Address Data (b) Address Data
8000 CA (LSB1) 8000 11 (LSB1)
8001 A7 (MSB1) 8001 2A (MSB1)
8002 6B (LSB2) 8002 22 (LSB2)
8003 B9 (MSB2) 8003 2B (MSB2)

8004 35 (LSB1+
LSB2) 8004 33 (LSB1+
LSB2)
8005 61 (MSB1+
MSB2) 8005 55(MSB1+
MSB2)

A7 CA
61 35
Program (4):

Addition of 8-bit number series (neglecting the carry)

PLAN:
This program adds ‘n’ number of hexadecimal numbers from
address 8101 onwards.

The address 8100 has the number of hexadecimal bytes to be


added. At last the result is added at location 8100.
ALGORITHM:
Steps:
1. Load the contents from 8100 location
(which is number of bytes to be added).
2. Move this number (i.e. count) into register B.
3. Make 00 in accumulator.
4. Point first number to be added.
5. Add this number with accumulator.
6. Decreases register B by one.
7. Check whether register B is 00 or not. If not repeats from
step 4.
8. Store the result at location 8100.
9. Go back to monitor.
PROGRAM:

Address Code Label Mnemonic Operand Comments

Step 8000 21 Start LXI H,8100 Point to no. of


1 bytes to be added
8001 00
8002 81

Step 8003 46 MOV B,M Load count into


2 register B

Step 8004 AF XRA A Clear the


3 accumulator
Step 8005 23 Loop INX H Point to the first number
4

Step 8006 86 ADD M Add with total of


5 accumulator

Step 8007 05 DCR B Subtract one from count


6

Step 8008 C2 JNZ Loop Test to see if done


7
8009 05
800A 80
Step 800B 32 STA 8100 Store the result
8
800C 00
800D 81
Step 800E EF RST 5 Go back to monitor
9

OBSERVATIONS:
(a) Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 8100 04
xx 8101 02
8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 8100 04
xx 8101 02
81 00 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 8100 04
xx 8101 02
81 00 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 04 8100 04
xx 8101 02
81 00 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 04 8100 04
xx 8101 02
81 00 8102 10
XOR
8103 03
xx
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 04 8100 04
00 8101 02
81 00 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 04 8100 04
00 8101 02
81 01 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 04-1 8100 04


00+02 8101 02
81 01 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 03 8100 04
02 8101 02
81 01 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 03 8100 04
02 8101 02
81 01 8102 10
8103 03
Not zero 8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 03 8100 04
02 8101 02
81 02 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 03-1 8100 04


02+10 8101 02
81 02 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 02 8100 04
12 8101 02
81 02 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 02 8100 04
12 8101 02
81 02 8102 10
8103 03
Not zero 8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 02 8100 04
12 8101 02
81 03 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 02-1 8100 04


12+03 8101 02
81 03 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 01 8100 04
15 8101 02
81 03 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 01 8100 04
15 8101 02
81 03 8102 10
8103 03
Not zero 8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 01 8100 04
15 8101 02
81 04 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 01-1 8100 04


15+08 8101 02
81 04 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 00 8100 04
1D 8101 02
81 04 8102 10
8103 03
8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 00 8100 04
1D 8101 02
81 04 8102 10
8103 03
Zero 8104 08
.
Address Data (b) Address Data
8100 04 8100 03
8101 02 8101 02
8102 10 8102 10
8103 03 8103 03
8104 08 8104 08
8100 1D (Result) 8100 15 (Result)
Memory Add Data

Accumulator 00 8100 1D
1D 8101 02
81 04 8102 10
8103 03
8104 08
.
Program (5):

Separation of hexadecimal number into two digits.

PLAN:
This program breaks the byte of data stored
at 8100 into two nibbles.

The MS nibble and LS nibble are stored at


8102 and 8101 location respectively.
ALGORITHM:
Steps:
1. Load the given byte into accumulator from location 8100.
2. Clear the MS nibble.
3. Store it at 8101 location (Result 1).
4. Repeat step 1.
5. Clear the LS nibble.
6. Store it at 8102 location (Result 2).
7. Go back to monitor.
PROGRAM:
Address Code Label Mnemonic Operand Comments

Step 1 Get the given number in


8000 3A Start LDA 8100 accumulator

8001 00
8002 81

Step 2 Mask off the MS nibble


8003 E6 ANI 0F

8004 0F

Step 3 Store result 1


8005 32 STA 8101
8006 01
8007 81
Step 4 Get the given number again
8008 3A LDA 8100
8009 00
800A 81

Step 5 Mask off the LS nibble


800B E6 ANI F0

800C F0

Step 6 Store result 2


800D 32 STA 8102
800E 02
800F 81

Step 7 Go back to monitor


8010 EF RST 5
OBSERVATIONS:
(a) Address Data (b) Address Data

8100 AB 8100 12
8101 00 8101 00
8102 00 8102 00

After program executes

8100 AB 8100 12
8101 0B 8101 02
8102 A0 8102 10
Program (6):

Combination of two hex nibbles to form one byte number.

PLAN:

This program takes two nibbles from 8100, 8101 and


combines to form a byte.

The nibble from 8100 is taken as MS nibble and


8101 is taken as LS nibble of the byte to be formed
and the result is stored at 8102.
ALGORITHM:
Steps:
1. Initialize memory pointer with 8100 location i.e. point to
MS nibble.
2. Move it into accumulator.
3. Shift the four bits towards the left in accumulator.
4. Point to LS nibble i.e. at location 8101.
5. ‘OR’ its contents with the contents of accumulator.
6. Increment the memory pointer to store the result at 8102.
7. Store the result.
8. Go back to monitor.
PROGRAM:
Address Code Label Mnemonic Operand Comments
Step 1 point to MS nibble
8000 21 Start LXI H,8100
8001 00
8002 81

Step 2 Move it into


8003 7E MOV A,M accumulator

Step 3
8004 07 RLC
8005 07 RLC
Move it to MSB
8006 07 RLC
8007 07 RLC
Step 4 Point to LS nibble
8008 23 INX H

Step 5 ‘OR’ the LS nibble and


8009 B6 ORA M contents of accumulator

Step 6 Point to result location


800A 23 INX H

Step 7 Store the result


800B 77 MOV M,A
Step 8 Go back to monitor
800C EF RST 5
OBSERVATIONS:

(a) Address Data (b) Address Data

8100 0A 8100 01
8101 0B 8101 02
8102 00 8102 00

After program executes

8100 0A 8100 01
8101 0B 8101 02
8102 AB 8102 12
Program (7):

Identification of odd or even parity of given hex number.

PLAN:
This program checks the hex number stored in location
8100 for odd or even parity.

If the parity is odd, 00 will be stored in location 8101


otherwise EE is stored in 8101.
ALGORITHM:

Steps:
1. Initialize memory pointer with 8100 location i.e. point to
given hex number.
2. Move it into accumulator.
3. ‘OR’ the contents of accumulator with itself.
4. Check the parity register for odd or even parity and store 00
or EE in location 8101 depending upon whether it is odd or
even parity.
5. Go back to monitor.
PROGRAM:

Address Code Label Mnemonic Operand Comments


Step 1 Get the given
8000 21 Start LXI H,8100 number

8001 00
8002 81

Step 2
8003 7E MOV A,M Move it into
accumulator

Step 3
8004 B7 ORA A Set the flag
Step 4 If the parity is odd, jump
8005 E2 JPO ODD to ODD
8006 0C
8007 80
Point to memory
8008 2C INR L location for result
8009 36 MVI M, EE Store EE in 8101

800A EE

Step 5 200B EF RST 5 Go back to monitor

Point to memory
Step 4 800C 2C ODD INR L location for result
800D 36 MVI M, 00 Store 00 in 8101

800E 00
Step 5 800F EF RST 5 Go back to monitor
OBSERVATIONS:

(a) Address Data (b) Address Data

8100 20 8100 44

8101 00 (Result) 8101 EE (Result)


Program (8):

Multiplication by two, employing bit rotation.

PLAN:

This program multiplies a hex number stored in

location 8100 by 2 and stores the result in location

8101.
ALGORITHM:

Steps:
1.Load the data of location 8100 in the accumulator.
2.Set the carry flag to zero.
3.Rotate the accumulator through carry.
4.Store the contents of accumulator (result) in location
8101.
5.Go back to monitor.
PROGRAM:
Address Code Label Mnemonic Operand Comments
Step 8000 3A Start LDA 8100 Get the given number
1 in accumulator
8001 00
8002 81
Step 8003 37 STC Set the carry flag to 1
2 8004 3F CMC Complement the carry

Step 8005 17 RAL Rotate accumulator to


3 left through carry
(i.e. ×2)
Step 8006 32 STA 8101 Store the result in
4 8101
8007 01
8008 81
Step 8009 EF RST 5 Go back to monitor
5
OBSERVATIONS:

(a) Address Data (b) Address Data

8100 1A 8100 2A

8101 34 (Result) 8101 54 (Result)


Program (9):

Multiplication of two 8-bit hex numbers without neglecting carry.

PLAN:
This program multiplies data stored in
location 8100 (multiplicand) and in
location 8101 (multiplier) and stored
the result in location 8102 (LSB) and
in location 8103 (MSB).
ALGORITHM:
Steps:
1. Load the multiplicand (D1) and multiplier (D2) in HL pair.
2. Stored it into DE pair.
3. Clear HL pair.
4. Move multiplicand into register B (as a counter)
5. Clear register D
6. Add HL and DE pair (result is in HL pair).
7. Decrease 1 from multiplicand.
8. Check whether register B is 00 or not. If not repeats from step 6.
9. Store the result at location 8102 and 8103.
10.Go back to monitor.
PROGRAM:
Address Code Label Mnemonic Operand Comments
Step 1 8000 2A Start LHLD 8100 Load HL pair with
D1 and D2
8001 00
8002 81
Step 2 8003 EB XCHG Exchange HL and
DE register pair

Step 3 8004 26 MVI H Put 00 in H


register
8005 00
8006 2E MVI L Put 00 in L
register
8007 00
Step 4 8008 42 MOV B,D Load D1 in
register B
Step 5 8009 16 MVI D Store 00 in register
D
800A 00
Step 6 800B 19 Loop DAD D Add HL and DE
register pair

Step 7 800C 05 DCR B Decrease 1 from B

Step 8 800D C2 JNZ Loop Test to see if done

800E 0B
800F 80

Step 9 8010 22 SHLD Store the result

8011 02
8012 81
Step10 8013 EF RST 5 Go back to
monitor
OBSERVATIONS:

(a) Address Data (b) Address Data


8100 1A 8100 AB
8101 02 8101 CD
8102 34 (LSB) 8102 EF (LSB)
8103 00 (MSB) 8103 88 (MSB)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy