0

我想创建一个使用 ADD.B、ADD.W 和 ADD.L 将两个十六进制值相加的程序,看看有什么区别。我是汇编编程的新手,所以我似乎无法完全正确。没有错误,但是当我运行程序时,没有显示结果。寄存器 D3 中似乎也没有存储任何值。谁能告诉我我做错了什么?非常感谢您的帮助。

START   ORG     $1000       Program starts at loc $1000
        MOVE    $374D1FC4,D2     [D0] <- $374D1FC4
        MOVE    $F22C4663,D3    [D1] <- $F22C4663
        ADD.B   D2,D3           [D1] <- [D0] + [D1] 
*       ADD.W   D2,D3           [D1] <- [D0] + [D1]
*       ADD.L   D2,D3           [D1] <- [D0] + [D1]
        MOVE    D3,R
* The following three instructions will display [R] to Output Window
* Task number 3 of trap #15 is to display D1.L as a signed decimal
    MOVE    R,D1    [D1] <- R
    EXT.L   D1  Extend sign bit to presreve the sign
    MOVE    #3,D0   Assign task number to [D0]
    TRAP    #15 Ask "OS" to perform the task

    STOP    #$2700  Stop execution

* Data section
R   DS.W    1   int R;
    END START
4

1 回答 1

1

当您尝试运行程序时,Easy68K 会提示您出现问题:“地址错误:1006 处的指令访问地址 f22c4663”

这些行:

    MOVE    $374D1FC4,D2     [D0] <- $374D1FC4
    MOVE    $F22C4663,D3     [D1] <- $F22C4663

应改为:

    MOVE    #$374D1FC4,D2     [D0] <- $374D1FC4
    MOVE    #$F22C4663,D3     [D1] <- $F22C4663

假设您要加载立即值$374D1FC4$F22C4663.

于 2013-10-23T07:33:18.177 回答