You are on page 1of 6

MPMC-Lab 3

Name – Ritik Desai

Roll No. - U19EE007

Subject - MPMC Labs

1. Write an assembly language programming in 8051 microcontrollers for to


arrange 10 bytes of hexadecimal numbers in the ascending order starting from
the internal memory location 30h.

U19EE007 1
loop1:

// logic to check condition for each iteration for loop1


mov a, r6 subb a, r5 jnc exitloop1

loop2:

// logic to check condition for each iteration for loop2

mov a, r7 mov
r7, a subb a, r5
jnc exitloop2

// getting address of 2 temp vars


mov a, r2 add a, r6 mov r0, a ;
stored num[i] in r0

mov a, r2 add a, r7 mov r1, a


; stored num[j] in r1

mov a, @ r0 subb a, @
r1 ; r0-r1 jnc skipif

// swapping 2 numbers
mov a, @ r0 mov b, @ r1
mov @ r0, b mov @ r1, a

skipif:

mov a, r7
inc a mov r7,
a
JMP loop2

exitloop2: mov
r7, #0h

mov a, r6
inc a mov r6,
a

JMP loop1

U19EE007 2
exitloop1: ;
mov b, #2h

U19EE007 3
2. Write an assembly language programming in 8051 microcontrollers for to
arrange 10 bytes of hexadecimal numbers in descending order starting from the
internal memory location 30h.

U19EE007 4
3. Write an assembly language program in the 8051-micro controller for to find the

U19EE007 5
factorial of a number less than 5h. Store the results in the internal memory

U19EE007 6

You might also like