HCS12汇编语言 试图对数组进行冒泡排序,但事实证明,当我运行它并且只替换第一个元素时它会进入无限循环
;constants
STACK equ $2000
; data array
org $1000
Array db $FF, $FE, $01, $05, $83, $FF, $C0, $01
db $83, $02, $F3, $28, $80, $01, $00, $06
Array_End
Destination_Array ds Destination_Array-Array ; calculating size of array
End_Destination
org $2000
Start lds #STACK ; stack location
ldx #Array
ldy #Destination_Array
back:
ldaa 1,x+
staa 1,y-
cpx #Array_End-1
bne back
next_pass:
ldaa #$0
staa Array
ldx #Destination_Array
next:
ldaa 0,x
cmpa 1,x
blt notnow
ldab 1,x
stab 0,x
staa 1,x
ldaa #$01
staa Array
notnow:
inx
cpx #End_Destination
bne next
tst Array
bne next_pass
swi