简体   繁体   中英

Issue printing two strings in mips

.data

    string1: .byte 'H', 'e', 'l', 'l', 'o', ' '
    string2: .byte 'w', 'o', 'r', 'l', 'd', '!'

.text
.globl main

main:

la $a0, string1

jal PRINT_STRING

la $a0, string2

jal PRINT_STRING

j EXIT

PRINT_STRING:

addi $sp, $sp, -4

li $v0, 4
syscall

addi $sp, $sp, 4
jr $ra

EXIT:

li $v0, 10
syscall

I'm trying to print string1 and string2 one after another, my output should be "Hello world!" however my output ends up being "Hello world!world!". Can someone help me figure out what is wrong with my code?

Null终止你的字符串:用\\0替换string1空格

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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