Saturday, July 29, 2006

Bubble sort in 8085A assembly

;Sorts an array of five integers stored in memory using bubble sort ;algorithm,assuming the array elements to be distinct
;Input:the array,number of elements
;Output:the sorted array
;destroys:none
;calls:sort
;target microprocessor:Intel 8085A
;The array starts from 9000.B and C are the two loop variables.A memory location is used
;to store data (9050)


main:
LXI SP,A000
MVI B,05
L:CALL sort
DCR B
JNZ L
HLT

sort:
LXI H,9000
MVI C,04
L1:MOV A,M
INX H
CMP M
JC L2
STA 9050
MOV A,M
DCX H
MOV M,A
LDA 9050
INX H
MOV M,A
L2:DCR C
JNZ L1
RET

0 Comments:

Post a Comment

<< Home

free web counter
free web counter