MC Lab - EXP3
MC Lab - EXP3
MC Lab - EXP3
Expt No. 3
1.
Find the sum of ten 2-digit BCD numbers available in memory locations XX40 to
XX49. Store the result in R0, R1 and in memory locations XX50h and XX51H.
ORG 0000H
AJMP START
START:
UP:
DOWN:
HERE:
2.
Find the largest number of a memory array. Array begins at memory location 40H,
the length of the array is in memory location 30H. Store the result in memory location
XX60H.
ORG 0000H
AJMP START
START:
UP:
;length of array
; n-1 comparisions
Microcontroller Lab
DOWN1:
DOWN:
HERE:
3.
JNC DOWN1
MOV A, @R1
SJMP DOWN
MOV A,B
DJNZ R7, UP
MOV DPTR, #0060H
MOVX @DPTR, A
SJMP HERE
END
Transfer the contents of memory locations 50H to 59H in the same sequence to a
memory array which begins at 70H.
ORG 0000H
AJMP START
START:
UP:
HERE:
1.
START:
MOV A, #nn
DEC A
MOV 30H,A
NXT_PSS: MOV R7, 30H
MOV R6, 30H
MOV R0, #50H
NXT_CMP: MOV A, @R0
MOV R3, A
INC R0
MOV 0F0H, @R0
CLR C
SUBB A,B
JC DOWN
MOV A, R3
MOV @R0,A
DEC R0
MOV @R0,0F0H
; no. of elements
; pass and comparision counter
;
; Starting location of internal data memory
2
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104
Microcontroller Lab
DOWN:
HERE:
2.
INC R0
DJNZ R6, NXT_CMP ;continue with remaining elements
DJNZ 30H, NXT_PSS
SJMP HERE
; stop executing
END
START:
HERE:
3.
MOV A, #0ABH
MOV 0F0H, #10
DIV AB
MOV R7, 0F0H
MOV B, #10
DIV AB
MOV R6, 0F0H
MOV R5, A
SJMP HERE
END
Convert a 2-digit BCD number available in memory location XX50 into hexadecimal
and store the hexadecimal number in next memory location.
ORG 0000h
AJMP START
START:
HERE:
3
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104
Microcontroller Lab
4.
Convert a single digit data available in memory location XX50h into ASCII code and
store the ASCII code in the next location.
ORG 0000H
AJMP START
START:
DOWN:
HERE:
EXERCISES
1. Find the sum of ten 16 bit hexadecimal numbers available in memory starting from
location XX10h. store the result in XX50h onwards.
2. Find the number of occurrences of data 2Ah in a memory array. The last element of
the array is 3Ah. The array begins at XX30h. Store the result in memory location
XX80h.
3. Transfer ten elements of an array starting at location XX40h in external data memory to
a location XX45 in the same memory.
4. Convert a 2-digit hexadecimal number into BCD number.
PRACTICE PROGRAMS
1. Find the sum of odd and even numbers available in a memory array and store the result
in memory locations.
2. Convert a 2-digit BCD number into ASCII code.
3. Convert binary number into Gray code.
4. Convert Gray code into binary number.
5. Reverse the elements of an array.
6. Read a single digit hexadecimal number from the memory location and generate 7segment code for the number read and send the code to port1. Assume common anode
seven segment display.
4
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104