简体   繁体   中英

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.

.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. 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. 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 .

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