如何在不使用la / li的情况下打印在Assembly中的内存中的.word值

问题描述 投票:0回答:1

如何在不使用la/li的情况下打印汇编内存中的.word值?我只能使用基本功能。我可以打印.asciiz,但我不知道我错误的是它没有在内存地址中打印值(整数):(

这是我打印出我的asciiz的代码:

lui $a0, 0x1001
addi $a0, $a0, 12 # set the address to my string location
addi $v0, $0, 4 
syscall

我写了相同的代码,除了不同的地址,但它没有打印任何东西。我也尝试搜索,但找不到这个问题的确切答案。

请指教。任何帮助将不胜感激。如果我误解了任何事情,请纠正我。先感谢您。

memory assembly printing mips
1个回答
1
投票

您的代码中存在一些错误。

首先,如果要打印整数,则应使用系统调用#1而不是#4

然后,如果要打印存储在内存中的整数,则必须从内存中加载该字。

您的代码应如下所示:

  lw $a0, 0x100C   # Load the contents of word stored at address 0x1000 + 12
  addi $v0, $0, 1  # Set service #1 (which prints an integer)
  syscall          # Do the system call
© www.soinside.com 2019 - 2024. All rights reserved.