MARS Mips添加两个以上的寄存器/打印解决方案

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

我做了一些计算(甚至不确定它们是否几乎接近准确,因为没有关于作业的说明(感谢毫无价值的教授)),但基本上我试图取$ t2,$ t3的值,$ t4和$ t5 ..将它们加在一起,然后将它们存储在$ t6中并将其打印到控制台。

[这里是我到目前为止的内容

    li $v0,10
    li $t1, 10
    add $t2, $t1, $t1
    sll $t3, $t1, 2
    and $t4, $t1, 0x0000FFFF
    or $t5, $t1, 0x0000FFFF
assembly integer mips add
1个回答
0
投票
这应该完成工作。

.data ## Data declaration section .text ## Assembly language instructions go in text segment main: ## Start of code section add $t1, $t2, $t3 # t1 = t2 + t3 add $t2, $t4, $t5 # t2 = t4 + t5 add $t6, $t2, $t1 # t6 = t1 + t2 move $a0, $t6 # a0 = t6 li $v0, 1 # system call code to print integer from a0 syscall # call operating system to perform operation li $v0, 10 # terminate program syscall

找到了示例Hello World!程序在这里:https://courses.cs.vt.edu/cs2506/Fall2014/Notes/L04.MIPSAssemblyOverview.pdf

我根据您的要求进行了扩展。

如果在MARS模拟器上运行该代码将输出0,因为t2,t3,t4,t5基本上为0。

© www.soinside.com 2019 - 2024. All rights reserved.