简体   繁体   English

MIPS中.space {value} sbrk(分配堆内存)之间有什么区别

[英]What is difference between .space {value} sbrk (allocate heap memory) in MIPS

in MIPS, we can allocate memory by using.space of setting $v0 to 9.在 MIPS 中,我们可以通过将 $v0 设置为 9 的 using.space 来分配 memory。

.data
arr: .space 12 # array of 12

or要么


li $v0, 9
li $a0, 12
syscall

I know that both will give me 12 bytes of space, sbrk allocates from heap but I actually do not know what does.space does.我知道两者都会给我 12 个字节的空间,sbrk 从堆中分配但实际上我不知道 does.space 做了什么。 Can you explain is there a difference between these two?你能解释一下这两者之间有区别吗?

Easiest way to see the difference is by looking at your compiled executable in a hex editor.查看差异的最简单方法是在十六进制编辑器中查看已编译的可执行文件。 When using .space n your file size has increased by n bytes.使用.space n时,您的文件大小增加了n个字节。 Try assembling the same program with and without the .space 12 , you'll see 12 extra zeroes in the hexdump of the version with the .space 12 .尝试使用和不使用.space 12来组装相同的程序,您会在带有.space 12的版本的 hexdump 中看到 12 个额外的零。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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