In: Computer Science
(Make sure in Mips) Use the correct “syscall” to create MIPS programs for the following.
!!! please use comments and ALWAYS use the correct syscall program code to end the program. !!!
1) Explain the difference between an address and a value for data stored in memory.
(this isn't a program just a basic question I also need.)
2) Write a program to print out a random number from
1..100.
Hint: Use random int range syscall 42, be mindful on how
to get a result that is between 1…100 and not 0...99
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate
the question. Thank You So Much.
An address will be the memory address in .data segment at which
the actual value is stored. while the value is stored in
register.
For example consider the below example.
In the above example. Address lable is memory address and having value 10 in it.
It will be like below in .data segment.
Hence here Address is memory address -x1001001 and value is 0x000000a.
2)
li $a1, 100 #Here you set $a1 to the max bound.
li $v0, 42 #generates the random number.
syscall #generate random number from 0-99
add $a0,$a0,1 #generate random number from 1-100
#no a0 will be having random number
li $v0,1
syscall #print the random number