You are on page 1of 1

CSC 112.

1-CS Computer Organization and Architecture Laboratory


First Semester, SY 2020-2021

Assignment No. 1
Due: January 6, 2021 (Wednesday) at 11:55PM

Complete the 8051 assembly language program below by implementing the bubble sort
algorithm. The data to be sorted in ascending order is located at address 30H in the data
memory (RAM) and is 20 bytes long. The first part of the program below copies the data
to be sorted from the code memory (ROM) to address 30H in RAM. You can use the
simulation facility of the MCU 8051 IDE to test and simulate your completed program.

ORG 0000H

; copy the data to be sorted to RAM first


MOV DPTR,#SORTDATA ; location of data in code
; ROM
MOV R0,#30H ; destination of data in RAM
MOV R7,#20D ; count of bytes to transfer
COPYLOOP: CLR A ; zero A (offset from DPTR)
MOVC A,@A+DPTR ; copy data byte from code
; ROM to A
MOV @R0,A ; copy data byte from A to
; RAM
INC DPTR ; increment data byte
; location in code ROM
INC R0 ; increment data byte
; destination in RAM
DJNZ R7,COPYLOOP ; decrement count and loop if
; not zero

;
; ??? - complete this part of the program
;
; bubble sort in ascending order the copy of the data in
; the RAM here
;

; end of program
ENDLOOP: SJMP ENDLOOP ; infinite loop

; the data to be sorted


SORTDATA: DB 0CH,03H,04H,06H,0FH,10H,0BH,02H,0AH,0EH,02H
DB 01H,03H,09H,08H,01H,05H,07H,04H,0DH

END

You might also like