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

时间:2011-01-11 02:09:40

标签: assembly ascii mips addition

我正在制作MIPS汇编计划。我是新手,我遇到了一些麻烦。

如何将.asciiz字符串中的数字转换为数字计数器部分。

EX: “1” - > 49

1 个答案:

答案 0 :(得分:0)

假设你使用像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

输出: 49505152