用汇编语言反转数组(68HC12)

时间:2016-04-06 04:09:53

标签: assembly

我需要复制和反转数组。我唯一能做的就是复制,但我不明白如何扭转它。请帮帮我。

这就是我现在所拥有的

STACK                   equ     $2000

                        org     $1000
Source_Array            db      $01, $FF, $13, $22, $12, $25, $12, $FE
End_Source

Destination_Array       ds      Destination_Array-Source_Array 
End_Destination
                        org     $2000
Start                   lds     #STACK
                        ldx     #Source_Array
                        ldy     #Destination_Array
Loop                    ldaa    1,x+
                        staa    1,y+

                        cpx     #End_Source
                        bne     Loop
                        swi
                        end

1 个答案:

答案 0 :(得分:2)

将数组反转复制应该就像将y设置为第二个数组的末尾并使用预减量而不是后增量进行存储一样简单; (希望我能从记忆中得到正确的减量)

STACK                   equ     $2000

                        org     $1000
Source_Array            db      $01, $FF, $13, $22, $12, $25, $12, $FE
End_Source

Destination_Array       ds      Destination_Array-Source_Array 
End_Destination
                        org     $2000
Start                   lds     #STACK
                        ldx     #Source_Array
                        ldy     #End_Destination
Loop                    ldaa    1,x+
                        staa    1,-y

                        cpx     #End_Source
                        bne     Loop
                        swi
                        end