【问题标题】:add number to address in an address register assembly language在地址寄存器汇编语言中将数字添加到地址
【发布时间】:2014-11-30 09:45:44
【问题描述】:

我想学习如何用汇编语言(摩托罗拉 68k)映射数组。

我正在尝试将数据寄存器 D1 中的值移动到内存中,并且我想要将值移动到的内存中的地址保存在 A1 中。此外,值得一提的是,A1 地址指向一个声明的存储空间,大小为 500 字节,这对于我想要做的事情应该有足够的空间。我尝试以下方法:

moveq     #0,D1 *moves value of 0 into D1

loop:

cmpi.w    #10,D1 *checks if D1 is less than 10, else branch out to done
bge       done

move.w    D1,(A0) *moves 0 into address that A0 points to 



*then I get stuck here. I want to increment the address value ++ 
*(or whatever size I have to, which I am guessing is 1 word, since I am using words), so 
*that my values in memory are contiguous up to ten in memory, 
*such as 00 01 02 03 04 05 06 07 08 09 0a



addq.w    #1,D1  *D1 incremented by 1
bra       loop  *branch to loop again

done:

      break

你们能帮帮我吗?

谢谢!

【问题讨论】:

    标签: arrays assembly


    【解决方案1】:

    68k 具有后增量寻址模式,您可以使用尾随 + 指定该模式,如下所示:

    move.w    D1,(A0)+
    

    引用自 M68000 程序员参考手册:

    使用操作数地址后,根据操作数的大小分别递增一、二或四:字节、字或长字。

    【讨论】:

    猜你喜欢
    • 2012-01-19
    • 2015-01-24
    • 2013-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-12
    • 2020-07-21
    相关资源
    最近更新 更多