MIPS: Size of .asciiz?

限于喜欢 提交于 2019-12-05 20:53:07

if you are asking about how many bytes in memory the string is stored in then it's 6 bytes

if you are asking about what should be returned by a function that count the string length (strlen C function for example) it should be 5

This particular asciiz string requires 6 bytes of storage.

In programming situations, you will measure the string size to be 5. As in strlen().

When using this string, very likely, your loop will be testing for NULL conditions, and will run for 5 iterations.

When copying, storing this string, your code will likely loop 5 times, and then (outside of loop), add an extra NULL '\0' character at the end, to maintain NULL termination. Therefore the destination storage space must be 1 more than strlen().

Agree with Robert, in this case the bytes in memory total 6. As Paxym explains however, in high-level languages it will measure the string 'size' to be 5.

Every character of ascii is 1 byte. if you write hello it is 5 byte

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!