① 編寫排序程序,將地址為30h~3fh的片內數據存儲器中的數據進行降序排序 (單片機8051系列的
_sort SEGMENTCODE
PUBLIC sort
RSEG_sort
sort:
MOV R0,#30H
R0_FOR_CMP:
MOVA,R0
ADDA,#256-3FH
JZR0_FOR_END
MOVA,R0
INCA
MOVR1,A
R1_FOR_CMP:
MOVA,R1
ADDA,#256-40H
JZR1_FOR_END
CLRC
MOVA,@R0
SUBB模宏敗A,@R1
JNCR1_FOR_ADJ
;SWAP
MOVA,@R0
XCHA,@R1
XCHA,@R0
R1_FOR_ADJ:
INCR1
AJMPR1_FOR_CMP
R1_FOR_END:
R0_FOR_ADJ:
INC旦顫R0
AJMP絕伏R0_FOR_CMP
R0_FOR_END:
RET
END