c++ - 将 C++ 转换为 MIPS 程序集

标签 c++ assembly mips

此代码将要从数组中找到最大元素我想将此代码转换为 MIPS 汇编代码任何人都可以帮助我...或者只是告诉我如何在 MIPS 中初始化数组。

void max_array()
{
    int a[10]={2,3,421,4,32,4,3,1,4,5},max;
    for(int i=0;i<9;i++)
    {
        cout<<a[i];
    }
    max=a[0];
    for(int j=1;j<9;j++)
    {
        if (max<a[j])
        {
             max=a[j];
        }
    }
    return max;

 }

最佳答案

举个例子

        .data
array1:     .space  12              #  declare 12 bytes of storage to hold array of 3 integers
        .text
__start:    la  $t0, array1     #  load base address of array into register $t0
        li  $t1, 5                  #  $t1 = 5   ("load immediate")
        sw $t1, ($t0)                #  first array element set to 5; indirect addressing
        li $t1, 13                  #   $t1 = 13
        sw $t1, 4($t0)           #  second array element set to 13
        li $t1, -7                  #   $t1 = -7
        sw $t1, 8($t0)           #  third array element set to -7
        done

关于c++ - 将 C++ 转换为 MIPS 程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7538659/

相关文章:

assembly - 了解 ARM7 上的 MRC

c - 程序集 : Returning 64 bits pointer address (nasm unix x64)

assembly - 尝试分配变量时,MIPS程序集解析错误

assembly - MIPS 汇编语言 - 临时寄存器与保存的寄存器

c++ - 如何将 C++ 函数指针作为带有一些固定值的参数传递?

c++ - 如何标记一个区域以使 clang-format 不会触及它?

android - QT+Android+Lib = VFP错误

Android NDK cmake 编译程序集(*.s) 文件

assembly - MIPS 组装中的泰勒级数

c++ - 如何编写工厂方法;我在遵循 c++ 代码时有错误