In MIPS Assembly how would I go about creating a program that would create an array of different size based on user input?
For example, the program would ask the user to input an integer X and create an array of length X.
Any code examples would be greatly appreciated.
You can use the sbrk
system call to allocate memory.
Consider the following:
.data
prompt: .asciiz "Number of integers "
.text
main:
#print prompt
la $a0 prompt
li $v0 4
syscall
#get int
li $v0 5
syscall
#allocate space
sll $a0 $v0 2 #number of bytes now in $a0
li $v0 9
syscall
#address of space now in $v0
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.