문제

I am working on a MIPS Assembly program. I am new at this, and am having some trouble.

How do you convert digits in a .asciiz string to there numeric counter parts.

EX: "1" -> 49

도움이 되었습니까?

해결책

Assuming you use a simulator like 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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top