Mpi Program Ashish
Mpi Program Ashish
Experiment No: 5) 8-BIT BCD ADDITION 7) 16 Bit ADDITION USING REGISTER PAIR
AIM: To perform 8-bit Addition of two hexadecimal numbers using accumulator in 8085 3) 8-BIT SUBTRACTION USING ACCUMULATOR AIM: To perform addition of two 8-bit BCD numbers using 8085 microprocessor. AIM: To add two 16 bit numbers (4 digits) using the register pairs in 8085 microprocessor.
PROGRAM: AIM: To perform 8-bit Subtraction of two hexadecimal numbers using accumulator in 8085
PROGRAM: Address Program Explanation Address Program Explanation
LDA 8200 Load Data 1 into accumulator LHLD 8201 Load HL register pair with data in 8201 & 8202
LDA 8201 Load the first data in the accumulator
Address Program Explanation MOV Move Accumulator contents to Register B XCHG Exchange contents of HL with DE Register Pair
MOV B, A Move contents of Accumulator to B
LDA 9000 Load contents of address 9000 (Input l) into the accumulator LDA 8201 Load Data 2 into accumulator LHLD 8203 Load HL register pair with data in 8203 & 8204
LDA 8200 Load the second data in the accumulator
MOV Shift contents of accumulator to register B MVI A, 00 Set Accumulator , A = '0' for carry
MVI C, 00 Set C = '0' for carry MVI C, 00 Clear register C to account for Carry
LDA 9001 Load contents of address 9001 (Input 2) into the accumulator DAD D Double Addition
SUB B Subtract B from Accumulator & Store in Accumulator ADD B Add Data 2 to Data 1 and store in
ADD B Add data in B to accumulator & store in the accumulator Accumulator JNC Ahead If carry is not set go Ahead
STA 9002 Store the (Result) contents of accumulator to address 9002 JNC Ahead If carry is not set go Ahead INR A if carry = '1' , increment Accumulator to 01
DAA Convert the accumulator value to BCD value
JC Loci Jump to LOCI if carry is I INR C if carry = 'l' , increment register C to 01 Ahead SHLD 8205 Store contents of HL Register pair in Memory
JNC Ahead If , go Ahead
MVI A,oo Store value 00 in accumulator CMA Get 2's complement for Accumulator STA 8207 Store Register C (Carry) content to memory
INR C If Increment register C by I
STA 9003 Store the (Carry) contents of accumulator to address 9003 ADD 01 Add one to accumulator HLT End of program
Ahead STA 8203 Store Accumulator content (Result) to memory
HLT End of Program Ahead STA 8202 Store result in given location MOV Move contents of Register C to
Loc l: MVI A,01 Store value 01 in accumulator 8) 16 Bit HEXADECIMAL SUBTRACTION
MOV A,c Move carry to Accumulator Accumulator
STA 9003 Store the (Carry) contents of accumulator to address 9003 AIM: To subtract two 16-bit hexadecimal numbers using Accumulator with 8085 Microprocessor
STA 8203 Store Carry in given location STA 8204 Store Register C (Carry) content to memory
HLT End of Program
HLT End of Program HLT End of program Program
Program Explanation
Experiment No: 2 8-BIT ADDITION WITH MEMORY POINTER 4) 8-BIT SUBTRACTION WITH MEMORY POINTER Experiment No: 6) 16 BIT ADDITION USING ACCUMULATOR LDA 8202 Load contents of Accumulator with Lower byte of Data 2
AIM: To perform 8-bit Addition of two hexadecimal numbers using memory pointer in 8085 AIM: To perform 8-bit Subtraction of two hexadecimal numbers using memory pointer in 8085 AIM: To add two 16 bit numbers ( 4 digits) using the accumulator with 8085 microprocessor. MOV Move contents of Accumulator to Register B
PROGRAM: PROGRAM: PROGRAM: LDA 8200 Load contents of Accumulator with Lower byte of
Address Program Explanation Data 1
Address Program Explanation
Address Program Explanation LDA 8201 Get Data 1 (lower byte) into accumulator SUB B Subtract contents of B from Accumulator
LXI H, 8201 Setting pointer for data
LXI H, 8201 Setting pointer for getting data MOV Move Data to Register B from Accumulator STA 8204 Store Accumulator content (Lower byte of difference) to Memory
MVI C, 00 Clear register C to account for Carry
MVI C, OO Clearing register C for carry LDA 8203 Get Data 2 (lower byte) into accumulator LDA 8203 Load contents of Accumulator with Higher byte of Data 2
MOV A, M Get Data I into Accumulator
MOV A, M Getting Data 1 into the accumulator from memory ADD B Add Lower Bytes of Data 1 & Data 2 MOV Move contents of Accumulator to Register B
INX H Increment the memory pointer
INX H Increment pointer to the next memory location STA 8205 Store content of Accumulator , Lower Byte Result in Memory LDA 8201 Load contents of Accumulator with Higher byte of
SUB M Subtract Data 2 from Data I and store in Accumulator
ADD M Add second data to Accumulator and store it in accumulator Data 1
MVI C, 00 Set C = '0' for carry
JNC Ahead If carry==() , go Ahead
JNC Ahead If carry is 'O' , go to location 'Ahead' LDA 8202 Get Data 1 (higher byte) into accumulator
INRC If Increment register C by 1 SBB B Subtract contents of B from Accumulator along with Borrow, if any
INRC If carry is 'l ' , Increment register C to I MOV Move Data to Register B from Accumulator
CMA Get 2's complement for Accumulator data STA 8205 Store Accumulator content (Higher byte of difference) to Memory
Ahead INX H Increment pointer to the next memory location LDA 8204 Get Data 2 (higher byte) into accumulator
ADI 01 Add I to accumulator content HLT End of Program
MOV Store Sum in memory ADC B Add Higher Bytes of Data 1 & Data 2 with carry of Lower Bytes
Ahead INX H Increment the memory pointer
INX H Increment pointer to the next memory location STA 8206 Store content of Accumulator , Lower Byte
MOV Store Accumulator content (Result) to memory
MOV M,c Store Carry in memory Result in Memory
INX H Increment the memory pointer
HLT End of Program JNC Ahead If carry is not set go Ahead
MOV M,c Store Register C (Carry) content to memory
HLT End of program INR C if carry = 'I' , increment register C to 01
Ahead MOV A,c Move contents of Register C to Accumulator
STA 8207 Store Register C (Carry) content to memory
HLT End of program