0

3x3 配列の対角線の値の平均を計算して格納する 68k アセンブリ プログラムがあります。

    ORG    $1000
START:                  ; first instruction of program

* Put program code here

        move.w      n,d6        ; d6 = 0000 0003
        clr.l       d7          ; sum = 0
        move.w      #2,d4       ; size of element 0000 0002
        mulu.w      d6,d4       ; n times size of element 
                                ; d4 0000 0006
        movea.l     #A,a0       ; address of the array

loop    tst.w       d6          ; if (n == 0)
        beq         done        ; go to done else go to next instruction
        subq.w      #1,d6       ; 3 - 1, 2 - 1, 1 - 1, done
        add.w       (a0)+,d7    ; a0 address is incremented 2 bytes since its word length
                                ; content of address a0 is stored in d7
                                ; d7 = 0000 0001, 0000 0005, 0000 0009

        add.l       d4,a0       ; increment for diagonals which in 3x3 = 3 position = 6 bytes
                                ; a0 = 02 + 06 = 08, 08 + 06 = 10 hex = 16 decimal
        bra         loop        ; restart loop until condition is met

done    divu.w      n,d7        ; now d7 has the sume of diagonals
                                ; d7 = 1 + 5 + 9 = 15
                                ; 15 / 3 = 5
                                ; result is stored in d7 = 5    
        move.l      d7,store    ; d7 is stored in 



    SIMHALT             ; halt simulator

* Put variables and constants here

A       dc.w    1,2,3,4,5,6,7,8,9
n       dc.w    3

        org     $2000           ; what does this do?
store   ds.l    1               ; notice its long word    

    END    START        ; last line of source

次の行を除いて、このコードで行われていることはすべて理解しています。

org     $2000           ; what does this do?
store   ds.l    1       ; notice its long word   

組織「$2000」が何をしているか、「ds.l 1」を簡単な言葉で説明してもらえますか。DS コマンドは何をしていて、その後の数字 1 は何を表しているのですか?

メモリ ブロック d7 の値がアドレス 0000 2000 に保存されていることを確認しましたが、これは DS.L の前の数字 1 と何の関係があり、ORG は一般的に何をしているのでしょうか?

4

2 に答える 2

1

ORG次の値が始まるメモリアドレスを定義します

ds.l長い単語を初期化せずに予約する

この場合、特定の値を割り当てずに 1 つのロング ワードが $2000 に予約されています。storeこの場所へのポインターとして理解されます。

お気に入りの検索エンジンに68k orgまたは68k ds.lを書き込むことをお勧めします。そうすれば、情報がすぐに利用可能になります。

于 2016-02-28T15:39:38.387 に答える
0

org $2000現在のアドレスを に設定するだけで、次のラベルが にあることを$2000意味します。なんらかの理由で、それが結果が期待される場所です。この場合、指定された数のロングワードを予約します。そこに書き込みます。これはおそらく、このタスクの仕様にあると思われます。つまり、「アドレス $2000 でロングワードの結果を生成する」のようなものです。store$2000ds.l1move.l d7,stored7

于 2016-02-28T15:40:15.030 に答える