Assembly Language Programming in 8085
PROGRAMS
Steps to write a program:-
- Type the starting memory address using keyboard, in this 8085kit address belongs to C000 to FFFF. We can use any memory address between them. Ex: A C000 here A stands for assemble the program.
 - After that counting type the to the end.
 - Whenever label is given type their corresponding memory address where we want to jump our program.
 - When complete program is typed then enter key is pressed two times to execute the program.
 
Steps to execute a program:-
- Type G< starting address>, then press enter key, after that space key.
 - Type R, then press enter key. Which given the content of registers.
 - When memory address is given in program following step are performed.
 
B. After that step 1 is performed.
C. Type D<memory address>, then press enter key. Here memory address is the address where answer is stored which is already mention program.
Program No. 1
·        
Write a program for addition of two binary numbers stored in any two
register.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
06 
 | 
  
MVI B,06H 
 | 
  
//initialize register B// 
 | 
  ||
C001 
 | 
  
06 
 | 
  ||||
C002 
 | 
  
16 
 | 
  
MVI D,02H 
 | 
  
//initialize register D// 
 | 
  ||
C003 
 | 
  
02 
 | 
  ||||
C004 
 | 
  
78 
 | 
  
MOV A,B 
 | 
  
//Copy the content of register B in Accumulator// 
 | 
  ||
C005 
 | 
  
82 
 | 
  
ADD D 
 | 
  
//Add the content of register D with the content
  of Accumulator// 
 | 
  ||
C006 
 | 
  
CF 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:- B=06 & D=02
·       
Output:-
A=08, B=06, C=00, D=02, E=04, F=00, I=0F, H=08, L=00, M=0850, S=FFEB,
P=C007
Program
No. 2
·       
Write a program for subtraction of two binary numbers stored in any two
register.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
06 
 | 
  
MVI B,06H 
 | 
  
//initialize register B// 
 | 
  ||
C001 
 | 
  
06 
 | 
  ||||
C002 
 | 
  
16 
 | 
  
MVI D,02H 
 | 
  
//initialize register D// 
 | 
  ||
C003 
 | 
  
02 
 | 
  ||||
C004 
 | 
  
78 
 | 
  
MOV A,B 
 | 
  
//Copy the content of register B in Accumulator// 
 | 
  ||
C005 
 | 
  
92 
 | 
  
SUB D 
 | 
  
//Subtract  the content of register D with the content
  of Accumulator// 
 | 
  ||
C006 
 | 
  
CF 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:- B=06 & D=02
·       
 Output:-
A=04, B=06, C=00, D=02, E=00, F=10, I=0F, H=08, L=00, M=D800, S=FFEB,
P=C007
Program
No. 3
Write a program for a group of data is residing at C050 H memory
location to transfer in reverse order at memory location starting from D050 H.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex
  Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
21 
 | 
  
LXI H,C050 H 
 | 
  
//initialize HL pair register// 
 | 
  ||
C001 
 | 
  
50 
 | 
  ||||
C002 
 | 
  
C0 
 | 
  ||||
C003 
 | 
  
01 
 | 
  
LXI B,D054 H 
 | 
  
//initialize HL pair register// 
 | 
  ||
C004 
 | 
  
54 
 | 
  ||||
C005 
 | 
  
D0 
 | 
  ||||
C006 
 | 
  
16 
 | 
  
MVI D,05 H 
 | 
  
//Load 05 in D register// 
 | 
  ||
C007 
 | 
  
05 
 | 
  ||||
LOOP 
 | 
  
C008 
 | 
  
7E 
 | 
  
MOV A,M 
 | 
  
//Copy the content of HL pair in Accumulator// 
 | 
  |
C009 
 | 
  
02 
 | 
  
STAX B 
 | 
  
//save in register pair BC// 
 | 
  ||
C00A 
 | 
  
23 
 | 
  
INX H 
 | 
  
//increment in HL pair// 
 | 
  ||
C00B 
 | 
  
0B 
 | 
  
DCX B 
 | 
  
//Decrement in BC pair// 
 | 
  ||
C00C 
 | 
  
15 
 | 
  
DCR D 
 | 
  
//Decrement in D// 
 | 
  ||
C00D 
 | 
  
C2 
 | 
  
JNZ LOOP (C008) 
 | 
  
//Jump to the loop// 
 | 
  ||
C00E 
 | 
  
08 
 | 
  ||||
C00F 
 | 
  
C0 
 | 
  ||||
C010 
 | 
  
CF 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:- E_C050 [C050-1,51-2,52-3,53-4,54-5]
·       
Output:-D_D054 [D054-5,53-4,52-3,51-2,50-1]
A=01 BD0 C=53 D05 E=00 F=SS I=0F H=C0
L=51 M=05 S=FFFB P=C010
Program
No. 4
Write a program to sort given 10 numbers from memory location C050 H in
the ascending order.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
06 
 | 
  
MVI B,09 H 
 | 
  
//Initialize counter// 
 | 
  ||
C001 
 | 
  
09 
 | 
  ||||
START 
 | 
  
C002 
 | 
  
21 
 | 
  
LXI H,C050 H 
 | 
  
//Initialize memory pointer// 
 | 
  |
C003 
 | 
  
50 
 | 
  ||||
C004 
 | 
  
C0 
 | 
  ||||
C005 
 | 
  
0E 
 | 
  
MVI C,09 H 
 | 
  
//initialize counter// 
 | 
  ||
C006 
 | 
  
09 
 | 
  ||||
BACK 
 | 
  
C007 
 | 
  
7E 
 | 
  
MOV A,M 
 | 
  
//get the number// 
 | 
  |
C008 
 | 
  
23 
 | 
  
INX H 
 | 
  
//increment memory pointer// 
 | 
  ||
C009 
 | 
  
BE 
 | 
  
CMP M 
 | 
  
//compare number with next number// 
 | 
  ||
C00A 
 | 
  
DA 
 | 
  
JC SKIP (C015) 
 | 
  
//if less, don’t interchange// 
 | 
  ||
C00B 
 | 
  
15 
 | 
  ||||
C00C 
 | 
  
C0 
 | 
  ||||
C00D 
 | 
  
CA 
 | 
  
JZ SKIP (C015) 
 | 
  
//if equal, don’t interchange// 
 | 
  ||
C00E 
 | 
  
15 
 | 
  ||||
C00F 
 | 
  
C0 
 | 
  ||||
C010 
 | 
  
56 
 | 
  
MOV D,M 
 | 
  
//move the content of memory into D// 
 | 
  ||
C011 
 | 
  
77 
 | 
  
MOV M,A 
 | 
  
//move the content of Accumulator into memory// 
 | 
  ||
C012 
 | 
  
2B 
 | 
  
DCX H 
 | 
  
//decrement in HL pair// 
 | 
  ||
C013 
 | 
  
72 
 | 
  
MOV M,D 
 | 
  
//move the content of D into memory// 
 | 
  ||
C014 
 | 
  
23 
 | 
  
INX H 
 | 
  
//increment in HL pair// 
 | 
  ||
SKIP 
 | 
  
C015 
 | 
  
0D 
 | 
  
DCR C 
 | 
  
//Decrement in C// 
 | 
  |
C016 
 | 
  
C2 
 | 
  
JNZ BACK (C007) 
 | 
  
//If not zero, repeat// 
 | 
  ||
C017 
 | 
  
07 
 | 
  ||||
C018 
 | 
  
C0 
 | 
  ||||
C019 
 | 
  
05 
 | 
  
DCR B 
 | 
  
//Decrement in B// 
 | 
  ||
C01A 
 | 
  
C2 
 | 
  
JNZ START (C002) 
 | 
  
//If not zero, repeat// 
 | 
  ||
C01B 
 | 
  
02 
 | 
  ||||
C01C 
 | 
  
C0 
 | 
  ||||
C01D 
 | 
  
CF 
 | 
  
RST1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:- E_C050 [C050-9,51-8,52-7,53-6,54-5,55-4,56-3,57-2,58-1,59-0]
·       
Output:- D_C050 [C050-0,51-1,52-2,53-3,54-4,55-5,56-6,57-7,58-8,59-9]
A=08 B=00 C=00 D=00 E=00 F=55 I=0F
H=C059 M=C059 S=FFEB P=C01E
Program
No. 5
Write a program to multiply the 8-bit
unsigned number in memory location C050 H by the 8-bit unsigned number in
memory location C051 H. Store the 8 least significant bits of the result in
memory location C300H and the 8 most significant bits in memory location C301
H.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
LXI H, C050 H 
 | 
  
// initialize the memory pointer// 
 | 
  |||
C001 
 | 
  |||||
C002 
 | 
  |||||
C003 
 | 
  
MOV E,M 
 | 
  
// get multiplicand// 
 | 
  |||
C004 
 | 
  
MVI D,00 H 
 | 
  
// initialize register D by 00// 
 | 
  |||
C005 
 | 
  |||||
C006 
 | 
  
INX H 
 | 
  
//increment memory pointer// 
 | 
  |||
C007 
 | 
  
MOV A,M 
 | 
  
// get multiplier// 
 | 
  |||
C008 
 | 
  
LXI H,0000 
 | 
  
// product=0// 
 | 
  |||
C009 
 | 
  |||||
C00A 
 | 
  |||||
C00B 
 | 
  
MVI B,08 H 
 | 
  
//initialize counter with count 8// 
 | 
  |||
C00C 
 | 
  |||||
MULT: 
 | 
  
C00D 
 | 
  
DAD H 
 | 
  
// add the content of register pair HL with
  accumulator// 
 | 
  ||
C00E 
 | 
  
RAL 
 | 
  
// rotate accumulator left with carry// 
 | 
  |||
C00F 
 | 
  
JNC SKIP 
 | 
  
//jump if no carry// 
 | 
  |||
C010 
 | 
  |||||
C011 
 | 
  |||||
C012 
 | 
  
DAD D 
 | 
  
// add the content of register pair DE with
  accumulator// 
 | 
  |||
SKIP 
 | 
  
C013 
 | 
  
DCR B 
 | 
  
//decrement in register B// 
 | 
  ||
C014 
 | 
  
JNZ MULT 
 | 
  
//jump on no zero// 
 | 
  |||
C015 
 | 
  |||||
C016 
 | 
  |||||
C017 
 | 
  
SHLD C300 
 | 
  
// store the result// 
 | 
  |||
C018 
 | 
  |||||
C019 
 | 
  |||||
C01A 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:-
·       
Output:-
Program
No. 6
Write a program to convert a 2-digit
BCD number stored at memory address C200 H into its binary equivalent number
& store the result in a memory location C300 H.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
3A 
 | 
  
LDA C200 H 
 | 
  
//get BCD number// 
 | 
  ||
C001 
 | 
  
00 
 | 
  ||||
C002 
 | 
  
C2 
 | 
  ||||
C003 
 | 
  
47 
 | 
  
MOV B,A 
 | 
  
//save it// 
 | 
  ||
C004 
 | 
  
E6 
 | 
  
ANI OF H 
 | 
  
//mask most significant four bits// 
 | 
  ||
C005 
 | 
  
0F 
 | 
  ||||
C006 
 | 
  
4F 
 | 
  
MOV C,A 
 | 
  
//save unpacked BCD in C register// 
 | 
  ||
C007 
 | 
  
78 
 | 
  
MOV A,B 
 | 
  
//get BCD again// 
 | 
  ||
C008 
 | 
  
E6 
 | 
  
ANI FO H 
 | 
  
//mask least significant four bit// 
 | 
  ||
C009 
 | 
  
F0 
 | 
  ||||
C00A 
 | 
  
0F 
 | 
  
RRC 
 | 
  
//convert most significant four bits into
  unpacked BCD2// 
 | 
  ||
C00B 
 | 
  
0F 
 | 
  
RRC 
 | 
  
-“”- 
 | 
  ||
C00C 
 | 
  
0F 
 | 
  
RRC 
 | 
  
-“”- 
 | 
  ||
C00D 
 | 
  
0F 
 | 
  
RRC 
 | 
  
-“”- 
 | 
  ||
C00E 
 | 
  
47 
 | 
  
MOV B,A 
 | 
  
//save unpacked BCD2 in B register// 
 | 
  ||
C00F 
 | 
  
AF 
 | 
  
XRA A 
 | 
  
//clear accumulator (sum=0)// 
 | 
  ||
C010 
 | 
  
16 
 | 
  
MVI D,0A H 
 | 
  
//set D as a multiplier of 10// 
 | 
  ||
C011 
 | 
  
0A 
 | 
  ||||
SUM 
 | 
  
C012 
 | 
  
82 
 | 
  
ADD D 
 | 
  
//add 10 unit (B)=0// 
 | 
  |
C013 
 | 
  
05 
 | 
  
DCR E 
 | 
  
//decrement BCD2 by one// 
 | 
  ||
C014 
 | 
  
C2 
 | 
  
JNZ SUM 
 | 
  
//is multiplication complete? If not, go back and
  add again// 
 | 
  ||
C015 
 | 
  
12 
 | 
  ||||
C016 
 | 
  
C0 
 | 
  ||||
C017 
 | 
  
84 
 | 
  
ADD C 
 | 
  
//add BCD1// 
 | 
  ||
C018 
 | 
  
32 
 | 
  
STA C300 H 
 | 
  
// store the result// 
 | 
  ||
C019 
 | 
  
00 
 | 
  ||||
C01A 
 | 
  
C3 
 | 
  ||||
C01B 
 | 
  
CF 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
 Input:- E_C050-13
·       
Output:- D_C050 [C050-0D, 02, 03.....] 
A=0F B=00 C=05 D=0A
E=00 F=04 I=0F H=C0 L=59 M=C059 S=FFEB P=C01C
Program -07
Write a main Program and a conversion subroutine
to convert the binary number stored at D000H into its equivalent BCD number.
Store the result from memory location D100H.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
LXI SP,C7FF H 
 | 
  
//Initialize stack pointer// 
 | 
  |||
C001 
 | 
  |||||
C002 
 | 
  |||||
C003 
 | 
  
LDA D000 H 
 | 
  
//get the binary number in accumulator// 
 | 
  |||
C004 
 | 
  |||||
C005 
 | 
  |||||
C006 
 | 
  
CALL Subroutine (C00A) 
 | 
  
//call subroutine// 
 | 
  |||
C007 
 | 
  |||||
C008 
 | 
  |||||
C009 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  |||
Subroutine to convert binary number into its
  equivalent BCD number. 
 | 
 |||||
C00A 
 | 
  
PUSH B 
 | 
  
//save BC register pair content// 
 | 
  |||
C00B 
 | 
  
PUSH D 
 | 
  
//save DE register pair content// 
 | 
  |||
C00C 
 | 
  
MVI B, 64 
 | 
  
//load divisor decimal 100 in B register// 
 | 
  |||
C00D 
 | 
  |||||
C00E 
 | 
  
MVI C,0A 
 | 
  
//load divisor decimal 10 in C register// 
 | 
  |||
C00F 
 | 
  |||||
C010 
 | 
  
MVI D,00 
 | 
  
//initialize digit 1// 
 | 
  |||
C011 
 | 
  |||||
C012 
 | 
  
MVI E,00 
 | 
  
//initialize digit 2// 
 | 
  |||
C013 
 | 
  |||||
STEP1 
 | 
  
C014 
 | 
  
CMP B 
 | 
  
//check if number <decimal 100// 
 | 
  ||
C015 
 | 
  
JC STEP2 (C01D) 
 | 
  
//if yes go to step 2// 
 | 
  |||
C016 
 | 
  |||||
C017 
 | 
  |||||
C018 
 | 
  
SUB B 
 | 
  
//subtract decimal 100// 
 | 
  |||
C019 
 | 
  
INR E 
 | 
  
//increment register E by 1// 
 | 
  |||
C01A 
 | 
  
JMP STEP1 (C014) 
 | 
  
// go to step 1// 
 | 
  |||
C01B 
 | 
  |||||
C01C 
 | 
  |||||
STEP2 
 | 
  
C01D 
 | 
  
CMP C 
 | 
  
//check if number < decimal 10// 
 | 
  ||
C01E 
 | 
  
JC STEP3 (C026) 
 | 
  
//if yes go to step 3// 
 | 
  |||
C01F 
 | 
  |||||
C020 
 | 
  |||||
C021 
 | 
  
SUB C 
 | 
  
//subtract decimal 10// 
 | 
  |||
C022 
 | 
  
INR D 
 | 
  
//increment register by 1// 
 | 
  |||
C023 
 | 
  
JMP STEP2 (C01D) 
 | 
  
//go to step 2// 
 | 
  |||
C024 
 | 
  |||||
C025 
 | 
  |||||
STEP3 
 | 
  
C026 
 | 
  
STA D100 H 
 | 
  
//store digit 0// 
 | 
  ||
C027 
 | 
  |||||
C028 
 | 
  |||||
C029 
 | 
  
MOV A,M 
 | 
  
//get digit 1// 
 | 
  |||
C02A 
 | 
  
STA D101 H 
 | 
  
//store digit 1// 
 | 
  |||
C02B 
 | 
  |||||
C02C 
 | 
  |||||
C02D 
 | 
  
MOV A,E 
 | 
  
//get digit 2// 
 | 
  |||
C02E 
 | 
  
STA D102 H 
 | 
  
//store digit 2// 
 | 
  |||
C02F 
 | 
  |||||
C030 
 | 
  |||||
C031 
 | 
  
POP D 
 | 
  
//restore DE register pair// 
 | 
  |||
C032 
 | 
  
POP B 
 | 
  
//restore BC register pair// 
 | 
  |||
C033 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  |||
·       
Input:-
·       
Output:-
Program
No. -08
Write a program to convert the ASCII
number in memory to equivalent decimal.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
LXI H,C050H 
 | 
  
//point to data// 
 | 
  |||
C001 
 | 
  |||||
C002 
 | 
  |||||
C003 
 | 
  
MOV A,M 
 | 
  
//get operand// 
 | 
  |||
C004 
 | 
  
SUI 30H 
 | 
  
//convert to decimal// 
 | 
  |||
C005 
 | 
  |||||
C006 
 | 
  
CPI 0AH 
 | 
  
//check whether it is valid decimal number// 
 | 
  |||
C007 
 | 
  |||||
C008 
 | 
  
JC LOOP (C00D) 
 | 
  
//yes, store result// 
 | 
  |||
C009 
 | 
  |||||
C00A 
 | 
  |||||
C00B 
 | 
  
MVI A,FFH 
 | 
  
//no, make result=FF H// 
 | 
  |||
C00C 
 | 
  |||||
LOOP: 
 | 
  
C00D 
 | 
  
INX H 
 | 
  
//increment in register pair HL// 
 | 
  ||
C00E 
 | 
  
MOV M,A 
 | 
  
//move content of accumulator into memory// 
 | 
  |||
C00F 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
 Input:-
·       
Output:-
Program
No. 9
Two ten bytes are residing at location
starting from C050 & D050 respectively. Write a program to add them up
& store the result starting from C090.
Program:-
Label 
 | 
  
Address 
 | 
  
Hex
  Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
21 
 | 
  
LXI H,C050 H 
 | 
  
//initialize memory pointer one// 
 | 
  ||
C001 
 | 
  
50 
 | 
  ||||
C002 
 | 
  
C0 
 | 
  ||||
C003 
 | 
  
01 
 | 
  
LXI B,D050 H 
 | 
  
//initialize memory pointer two// 
 | 
  ||
C004 
 | 
  
50 
 | 
  ||||
C005 
 | 
  
D0 
 | 
  ||||
C006 
 | 
  
11 
 | 
  
LXI D,C090 H 
 | 
  
//initialize result pointer// 
 | 
  ||
C007 
 | 
  
90 
 | 
  ||||
C008 
 | 
  
C0 
 | 
  ||||
BACK: 
 | 
  
C009 
 | 
  
0A 
 | 
  
LDAX B 
 | 
  
//get the number from array two// 
 | 
  |
C00A 
 | 
  
86 
 | 
  
ADD M 
 | 
  
//add it eight number in array one// 
 | 
  ||
C00B 
 | 
  
12 
 | 
  
STAX D 
 | 
  
//store the addition in array three// 
 | 
  ||
C00C 
 | 
  
23 
 | 
  
INX H 
 | 
  
//increment pointer one// 
 | 
  ||
C00D 
 | 
  
03 
 | 
  
INX B 
 | 
  
//increment pointer two// 
 | 
  ||
C00E 
 | 
  
13 
 | 
  
INX D 
 | 
  
//increment result pointer// 
 | 
  ||
C00F 
 | 
  
7D 
 | 
  
MOV A,L 
 | 
  
//move the content of L in accumulator// 
 | 
  ||
C010 
 | 
  
FE 
 | 
  
CPI 0AH 
 | 
  
//check pointer one for last number// 
 | 
  ||
C011 
 | 
  
0A 
 | 
  ||||
C012 
 | 
  
C2 
 | 
  
JNZ BACK (C009) 
 | 
  
//if not repeat step four// 
 | 
  ||
C013 
 | 
  
09 
 | 
  ||||
C014 
 | 
  
C0 
 | 
  ||||
C015 
 | 
  
CF 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:- E_C050 [C050-1,51-2,52-3,53-4,54-5,55-6,56-7,57-8,58-9,59-A]
·       
Output:- D_D050 [D050-A,51-9,52-8,53-7,54-6,55-5,56-4,57-3,58-2,59-1]
A=0A B=D C=0A D=C E=4A F=54 I=0F H=C1
L=0A M=C10A S=FFEB P=C016
Program
No. 10
Write a program for a block of 16
signed binary numbers is residing at location starting from C050 add them up
& store the result in D050.
Program:
Label 
 | 
  
Address 
 | 
  
Hex 
Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
21 
 | 
  
LXI H,C050 H 
 | 
  
//initialize the pointer// 
 | 
  ||
C001 
 | 
  
50 
 | 
  ||||
C002 
 | 
  
C0 
 | 
  ||||
C003 
 | 
  
01 
 | 
  
LXI B,D050 H 
 | 
  
//initialize second pointer// 
 | 
  ||
C004 
 | 
  
50 
 | 
  ||||
C005 
 | 
  
D0 
 | 
  ||||
C006 
 | 
  
16 
 | 
  
MVI D,10 H 
 | 
  
//Initialize the counter// 
 | 
  ||
CO07 
 | 
  
10 
 | 
  ||||
C008 
 | 
  
7E 
 | 
  
MOV A,M 
 | 
  
//loading the number in accumulator// 
 | 
  ||
LOOP 
 | 
  
C009 
 | 
  
23 
 | 
  
INX H 
 | 
  
//incrementing the pointer// 
 | 
  |
C00A 
 | 
  
86 
 | 
  
ADD M 
 | 
  
//adding the binary number to the last number// 
 | 
  ||
C00B 
 | 
  
15 
 | 
  
DCR D 
 | 
  
//decrementing the counter// 
 | 
  ||
C00C 
 | 
  
C2 
 | 
  
JNZ LOOP (C009) 
 | 
  
//if not zero jump to loop// 
 | 
  ||
C00D 
 | 
  
09 
 | 
  ||||
C00E 
 | 
  
C0 
 | 
  ||||
C00F 
 | 
  
02 
 | 
  
STAX B 
 | 
  
//saving the addition to a new memory location// 
 | 
  ||
C010 
 | 
  
CF 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:- E C050- 1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10
·       
Output:-
A=89 B=D0 C=50 D=00 E=00 F=54 I=0F H=C0
L=60 M=C060 S=FFEB P=C011
Program
No. 11
Write a program to calculate the sum of
series of number. The length of the series is in memory location C050 & the
series begins from memory location C090.
Program:
Label 
 | 
  
Address 
 | 
  
Hex
  Code 
 | 
  
Nemonics 
 | 
  
Comment’s 
 | 
  
Remarks 
 | 
 
C000 
 | 
  
LDA C050 H 
 | 
  
//load accumulator with number// 
 | 
  |||
C001 
 | 
  
50 
 | 
  ||||
C002 
 | 
  
C0 
 | 
  ||||
C003 
 | 
  
MOV C,A 
 | 
  
//initialize counter// 
 | 
  |||
C004 
 | 
  
LXI H,C050 H 
 | 
  
//Initialize pointer// 
 | 
  |||
C005 
 | 
  
50 
 | 
  ||||
C006 
 | 
  
C0 
 | 
  ||||
C007 
 | 
  
SUB A 
 | 
  
//sum low=0// 
 | 
  |||
C008 
 | 
  
MOV B,A 
 | 
  
//sum high=0// 
 | 
  |||
BACK: 
 | 
  
C009 
 | 
  
ADD M 
 | 
  
//sum=sum + data// 
 | 
  ||
C00A 
 | 
  
JNC SKIP (C00E) 
 | 
  
//jump on no carry// 
 | 
  |||
C00B 
 | 
  |||||
C00C 
 | 
  |||||
C00D 
 | 
  
INR B 
 | 
  
//increment in B// 
 | 
  |||
SKIP 
 | 
  
C00E 
 | 
  
INX H 
 | 
  
//increment pointer // 
 | 
  ||
C00F 
 | 
  
DCR C 
 | 
  
//decrement counter// 
 | 
  |||
C010 
 | 
  
JNZ BACK (C009) 
 | 
  
//check if counter zero repeat// 
 | 
  |||
C011 
 | 
  |||||
C012 
 | 
  |||||
C013 
 | 
  
STA C300 H 
 | 
  
//store lower byte// 
 | 
  |||
C014 
 | 
  
00 
 | 
  ||||
C015 
 | 
  
C3 
 | 
  ||||
‘ 
 | 
  
C016 
 | 
  
MOV A,B 
 | 
  
//move counting of register B into accumulator// 
 | 
  ||
C017 
 | 
  
STA D050 H 
 | 
  
//store higher byte// 
 | 
  |||
C018 
 | 
  |||||
C019 
 | 
  |||||
C01A 
 | 
  
RST 1 
 | 
  
//terminate program execution// 
 | 
  
·       
Input:-
·       
Output:-
Comments
Post a Comment