啦啦啦拉拉裤 2021-10-31 23:20 采纳率: 69.1%
浏览 86
已结题

编写一个将C语言变成 MIPS 汇编程序

望各位帮忙看看,现在就想要答案,蟹蟹各位潜水专家,感谢解答,感谢回答,感谢解答。编写一个 MIPS 汇编程序,相当于这个 C 程序:在原有的基础上完成这个程序。我需要答案,我想要的是直接把代码告诉我

//  read a line from stdin and and then an integer n
//  Print the character in the nth-position

#include <stdio.h>

// line of input stored here
char line[256];

int main(void) {

    printf("Enter a line of input: ");
    fgets(line, 256, stdin);

    printf("Enter a position: ");
    int n;
    scanf("%d", &n);

    printf("Character is: ");
    printf("%c", line[n]);
    printf("%c", '\n');

    return 0;
}



#  read a line from stdin and and then an integer n
#  Print the character in the nth-position

# n in $t0

main:
    la   $a0, str0       # printf("Enter a line of input: ");
    li   $v0, 4
    syscall

    la   $a0, line       # fgets(buffer, 256, stdin)
    la   $a1, 256
    li   $v0, 8
    syscall

    la   $a0, str1       # printf("Enter a position: ");
    li   $v0, 4
    syscall

    li   $v0, 5          # scanf("%d");
    syscall
    move $t0, $v0

    la   $a0, str2       # printf("Character is: ");
    li   $v0, 4
    syscall


    li   $a0, '?'        # printf("%c", '?');
    li   $v0, 11
    syscall


    li   $a0, '\n'       # printf("%c", '\n');
    li   $v0, 11
    syscall

    li   $v0, 0          # return 0
    jr   $ra

.data
str0:
    .asciiz "Enter a line of input: "
str1:
    .asciiz "Enter a position: "
str2:
    .asciiz "Character is: "


# line of input stored here
line:
    .space 256

  • 写回答

2条回答 默认 最新

  • 有问必答小助手 2021-11-02 10:07
    关注

    你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


    本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 11月15日
  • 已采纳回答 11月7日
  • 创建了问题 10月31日

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试