gpt4 book ai didi

mips - .asciiz 与 .ascii 之间有什么区别

转载 作者:行者123 更新时间:2023-12-02 01:56:01 36 4
gpt4 key购买 nike

我读到 .asciiz null 终止字符串(附加 \n?)...但是当查看 QtSPIM 的用户数据段时,

User data segment [10000000]..[10040000]
[10000000]..[1000ffff] 00000000
[10010000] 6c6c6548 6f57206f 00646c72 6c6c6548 H e l l o W o r l d . H e l l
[10010010] 6f57206f 00646c72 00000000 00000000 o W o r l d . . . . . . . . .
[10010020]..[1003ffff] 00000000

我没看出什么区别吗?

.data
str1: .asciiz "Hello World" # string str1 = "Hello World"
str2: .ascii "Hello World" # string str2 = "Hello World"

.text
.globl main
main:
li $v0, 4 # print_string

# print(str1)
la $a0, str1 # load address of str1 into $a0
syscall

# print(str2)
la $a0, str2 # load address of str2 into $a0
syscall

j $ra

输出“Hello WorldHello World

更新

分别有什么含义或者什么时候使用? asciiz 听起来像是“正确的”方法?

最佳答案

正如 @osgx 所写,ASCIIZ 表示字符串以 \0(ASCII 代码 0)NUL 字符终止。他们甚至被称为C strings 。引用那里的内容:

In computing, a C string is a character sequence terminated with a null character ('\0', called NUL in ASCII). It is usually stored as one-dimensional character array.[dubious – discuss] The name refers to the C programming language which uses this string representation. Alternative names are ASCIIZ (note that C strings do not imply the use of ASCII) and null-terminated string.

关于mips - .asciiz 与 .ascii 之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7783044/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com