N A ME : R E G . NO : 19BEC08 58 COURSE CODE : ECE3 00 3 COURSE TITLE : MICROCONTROLLER AND ITS APPLICATIONS SHAHUKARI CHETAN LAB TASK - 1 FALL Semester 2020-21 19BEC08 58 SHAHUKARI CHETAN FACULTY NAME : PROF. SUNDAR .S SLOT : L41+L42 Basic Assembly Language Programs
19BEC08 58 SHAHUKARI CHETAN QUESTION -01 Write a program to find the Decimal sum of the 5 bytes of data from code space starting at address 300H and store the Sum part of the result into RAM Space of 50H and Carry part of the results in to 60H .The data must be your Mobile number PROGRAM:- ORG 0000H MOV R0,#50H MOV R1,#60H MOV R2,#05H MOV DPTR,#300H MOV R3,#00 MOV R4,#00 LOOP: MOV A,#00 MOVC A,@A+DPTR ADD A,R3 MOV R3,A JNC CON INC R4 CON:INC DPTR DJNZ R2,LOOP MOV A,R3 MOV @R0,A MOV A,R4 MOV @R1,A HERE:SJMP HERE ORG 300H DB 95 ,02,18,12,00 END
19BEC08 58 SHAHUKARI CHETAN RESULT:-
19BEC08 58 SHAHUKARI CHETAN OBSERVATION:- We can observe that the final sum of 95 +02+18+12+00=127 in Decimal is stored as Hexadecimal with the sum part at 50H and carry part at 60H. Sum part value will be “7F”and carry value will be “0” therefore total sum will be “ 7F ” in hexadecimal form. QUESTION - 02 Write and assemble a program to add the following data and then use the simulator to examine the CY flag. 92H, 23H, 66H, 87H, F5H PROGRAM:- Org 0000h MOV A,#92H MOV B,#23H ADD A,B JNC L1 INC R0 L1: MOV B,A MOV A,#66H ADD A,B
19BEC08 58 SHAHUKARI CHETAN RESULT:- OBSERVATION:- In this we used to add two numbers that are been stores in A and B register with the help of the “ADD” command and the final result store in the “A” register. QUESTION - 03 Write and assemble a program to load values into each of registers R0 - R4 and then push each of these registers onto the stack. Single-step the program, and examine the stack and the SP register after the execution of each instruction . PROGRAM:- ORG 000H MOV R0,#01H MOV R1,#07H MOV R2,#09H MOV R3,#05H MOV R4,#03H
19BEC08 58 SHAHUKARI CHETAN OBSERVATION:- In the above output we overserve that we were able to pop the data out of stack and also see the variation in stack pointer QUESTION - 04 Write and assemble a program to: Set SP = 0D Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08, POP each stack location into registers R0 - R4. Use the simulator to single-step and examine the registers, the stack, and the stack pointer. PROGRAM: - ORG 0000H MOV SP,#0DH MOV 0DH, #10H MOV 0CH, #11H MOV 0BH, #12H MOV 0AH, #13H MOV 09H,#14H MOV 08,#16H POP 0 POP 1 POP 2 POP 3 POP 4 END
19BEC08 58 SHAHUKARI CHETAN RESULT:- OBSERVATION:- In this code with the help of the “pop” command we used to pop the values of the different register values to the memory address like D:08H so that values are been stored into that particular location
19BEC08 58 SHAHUKARI CHETAN QUESTION – 05 Write a program to transfer a string of data from code space starting at address 200H to RAM locations inside the CPU starting at 40H. The data is as shown below: MYDATA: DB VIT University Using the simulator, single-step through the program and examine the data transfer and registers PROGRAM:- ORG 0000H MOV A,#00H MOV DPTR,#200H MOV R1,#0EH MOV R0,#40H LOOP:CLR A MOVC A,@A+DPTR MOV @R0,A INC DPTR INC R0 DJNZ R1,LOOP HERE:SJMP HERE ORG 200H DB ‘VIT UNIVERSITY’ END
19BEC08 58 SHAHUKARI CHETAN RESULT STORE IN ROM:-
19BEC08 58 SHAHUKARI CHETAN RESULT STORE IN RAM:- OBSERVATION:- By this we are able to store the transfer the data using register from Code space to RAM location 40H.
19BEC08 58 SHAHUKARI CHETAN QUESTION – 06 Add the following subroutine to the program 1, single-step through the subroutine and examine the RAM locations. After data has been transferred from ROM space into RAM, the subroutine should copy the data from RAM locations starting at 40H to RAM locations starting at 60H. PROGRAM:- ORG 000H MOV DPTR,#200H MOV R0,#40H MOV R1,#0EH LOOP:CLR A MOVC A,@A+DPTR MOV @R0,A INC R0 INC DPTR DJNZ R1,LOOP MOV R0,#40H ;R0 =40 MOV R1,#60H ;R1 =60 MOV R3,#0EH ; R3 =14D LOOP2:CLR A MOV A,@R0 MOV @R1,A INC R0 INC R1 DJNZ R3,LOOP2 HERE:SJMP HERE ORG 200H DB ‘VIT UNIVERSITY’ END
19BEC08 58 SHAHUKARI CHETAN RESULT:- RESULT’S STORED IN ROM:-
19BEC08 58 SHAHUKARI CHETAN RESULT’S STORED IN RAM:- OBSERVATION:- Using the above code, we are able to transfer the data from one Ram location to anothe
19BEC08 58 SHAHUKARI CHETAN QUESTION -07 Write a program to add two multi-byte BCD numbers together and store the result in RAM locations 40H - 44H. The two multi-byte items are stored in the ROM space starting at 120H and 150H. See the following example data. ORG 120H DATA_1: DB 54H,76H,65H,98H;number 98657654H ORG 150H DATA_2 DB 93H,56H,77H,38H;number 38775693H Pick your own data for your program. Notice that you must first bring the data from ROM space into the CPU's RAM and then add them together. Use a simulator to single-step the program and examine the data. PROGRAM:- ORG 0000H MOV DPTR,#120H MOV R4,#05H MOV R0,#40H MOV R3,#00H LOOP: CLR A MOVC A,@A+DPTR MOV R3,A MOV A,#30H MOVC A,@A+DPTR ADD A,R3 DA A MOV @R0,A INC R0 INC DPTR DJNZ R4,LOOP HERE:SJMP HERE ORG 120H DB 54H,76H,65H,98H ORG 150H DB 93H,56H,97H,38H END
19BEC08 58 SHAHUKARI CHETAN RESULT:-
19BEC08 58 SHAHUKARI CHETAN OBSERVATION:- In this we used to store the 4 bytes number in 120H in ROM and another 4 bytes number into 150H in ROM and by using “add” command we used to store the add values into RAM from the 40 th location without the carry values. QUESTION -08 Write a program to calculate y where y = x 2 + 2x + 9. x is between 0 and 9 and the look-up table for x 2 is located at the address (code space) of 200H. Register R0 has the x, and at the end of the program R2 should have y. Use the simulator to change the x value and single-step through the program, examining the registers as you go. PROGRAM:- ORG 000H MOV DPTR,#200H MOV A,#03H;x=3 MOV R1,A ;R1=03 MOV R0,A;R0=03 ADDC A,R1; 2x MOV R1,A ; R1<=2X MOV A,R0 ;A=03 MOVC A,@A+DPTR ADDC A,#09H ADDC A,R1 MOV R2,A HERE: SJMP HERE ORG 200H DB 00H,01H,04H,09H,10H,19H,24H,31H,40H,51H END
19BEC08 58 SHAHUKARI CHETAN RESULT:-
19BEC08 58 SHAHUKARI CHETAN OBSERVATION:- At first accumulator will be cleared the the accumulator value will be stored with the hexadecimal values then these hexadecimal values will moved to the equation . In this code we used to store the values of the squared numbers in the hexadecimal form in the 200 th location of the ROM and then we used to implement the values into the algebra equation y = x^2 + 2x + 9 and we used to get the final output after values passed into the equation. QUESTION – 09 Write a program to convert Hex to Decimal, and then to ASCII. For example, if the hex data is FBH, which is equal to 251 in decimal, after conversion we will have 32H, 35H, and 31H. Place the ASCII result in RAM locations starting at 40H. Using a simulator, single-step the program and examine the data. PROGRAM:- ORG 0000H MOV A,#0FBH MOV R0,#40H LOOP:MOV B,#10 DIV AB XCH A,B; we are collecting the reminder ADD A,#30H; For ASCII Conversion we have to add 30 MOV @R0,A XCH A,B ; Taking the quo in A reg INC R0 JNZ LOOP END
19BEC08 58 SHAHUKARI CHETAN OBSERVATION:- In this code we used to give the values into the A and R0 register and then we used to divide the values and then i will convert into hexa-decimal and it will store in D:40H location RESULT:-