Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

ESD LAB MANUAL SOLUTIONS EXPT.No.

1
1. To add two 8-bit numbers MOV R0,#40H MOV A,@R0 INC R0 ADD A,@R0 INC R0 MOV @R0,A HERE: SJMP HERE Input/output: Give two 8-bit numbers as input in 40H and 41H addressed memory locations and see the result in 43H addressed memory location 2. To add BCD numbers MOV R0,#40H MOV R2,#5 CLR A MOV R7,A ADD A,@R0 DA A JNC NEXT INC R7 INC R0 DJNZ R2, AGAIN SJMP HERE

AGAIN:

NEXT: HERE:

Input/output: Give five BCD numbers as input from 40th addressed memory location onwards and see the output in Accumulator 3. To subtract two 8 bit numbers CLR C MOV A,#4CH SUBB A,#6EH

;4C-6E

JNC NEXT CPL A INC A NEXT: MOV R1,A HERE: SJMP HERE Note: Output can see in R1 register and Cy flag. If Cy=1 then result is negative and if Cy=0 then result is Positive. In this program 4C-6EH = -22H [R1=0x22, Cy=1] [NOTE: Negative sign should not be given for Hexadecimal numbers, It is just for our understanding. For ex: -22H ; sign convention is wrong] 4. To subtract two 16 bit numbers CLR C MOV A,#62H SUBB A,#96H MOV R7,A MOV A,#27H SUBB A, #12H MOV R6,A HERE: SJMP HERE Note: Output can see in R6 and R7 registers. In this program 2762H 1296H = 14CCH [R6=0x14, R7=0xCC] 5. To subtract two 2 digit BCD numbers
CLR C MOV A,#99H SUBB A,#34H ADD A,#12H DA A JC L1 MOV R1,A MOV A,#99H SUBB A,R1 L1: ADDC A,#00H MOV R7,A HERE: SJMP HERE

;12H - 34H

Note: Output can see in R7 register along with Carry flag. If carry=1, result is positive and if carry =0, result is negative. In this program 12H 34H = - 22H [R7=0x22, Cy=0]

6. Multiplication of 8 bit BCD numbers

MOV R0,#99H MOV R1,#28H MOV A,R1 MOV B,#10H DIV AB MOV R6,A MOV R7,B MOV R2,#00H CLR A DO: ADD A,R0 DA A JNC L1 INC R2 L1: DEC R7 CJNE R7,#00,DO CJNE R6,#00,SR1 SJMP RESULT SR1: ADD A,R0 DA A JNC L2 INC R2 L2: mov R7,#09h DEC R6 SJMP DO RESULT: MOV R5,A MOV A,R2 MOV B,#10 DIV AB MOV R4,B MOV B,#10 DIV AB MOV R3,B MOV R2,A HERE: SJMP HERE Note: Output can see in R3, R4,R5 registers. In this program 99x28 = 2772 [R3=0x02, R4=0x07, R5=0x72]

You might also like