简体   繁体   English

添加两个数字字符串-MIPS ASSEMBLY

[英]adding two numeric strings - MIPS ASSEMBLY

I am working on a MIPS Assembly program. 我正在研究MIPS汇编程序。 I am new at this, and am having some trouble. 我对此很陌生,遇到了一些麻烦。

How do you convert digits in a .asciiz string to there numeric counter parts. 如何将.asciiz字符串中的数字转换为数字计数器部分。

EX: "1" -> 49 例如:“ 1”-> 49

Assuming you use a simulator like http://sourceforge.net/projects/spimsimulator/ : 假设您使用http://sourceforge.net/projects/spimsimulator/之类的模拟器:

.data
input:    .asciiz "1234"

.text
main:   
    la $t0, input         # load address of input
loop:
    lb $a0, ($t0)         # load one byte
    beq $a0, $0, exit     # exit if null-byte
    li $v0, 1             # print integer system call
    syscall             
    addi $t0, $t0, 1      # increment address
    j loop

exit:   
    jr $ra

Output: 49505152 输出:49505152

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM