Homework: Memory Access
- Write the assembly instruction to set $t1 to the value 0x10010000
- Suppose $t1 contains the value 0x10010000. Write an instruction to
change the value in $t1 to 0x1001000C.
- Write the assembly instructions to set $t1 to the value 0x1001002C
Suppose that the data segment starts at address 0x10010000 and
you have the following code:
.data
value: .word 15
num: .word 50
chars: .space 10
- What is the address of the label value?
- What is the address of the label num?
- What is the address of the label chars?
- Assume that $t0 contains the starting address of the data segment.
What instruction will load the address of chars into $t1?
- Assume that $t0 contains the starting address of the data segment.
Write an instruction to store the contents of $t2 into num.
- Assume that $t0 contains the starting address of the data segment.
Write an instruction to load the fourth byte of chars into $t3.
- Assume that $t0 contains the starting address of the data segment.
Write the instructions to copy the value from num to $t3, add 1
to it, and then copy the result back into num.
Given the following data segment:
.data
length: .word 25
width: .word 45
area: .word
- Write the MIPS statements that are equivalent to the following Java
statement, using the variable names: area = length * width;
- Write the MIPS statements to print area, using the variable name.
- Write the MIPS statements that are equivalent to the following Java
statement, without using the variable names: area = length * width;
- Write the MIPS statements to print area, without using the variable name.
Given the following data segment:
.data
nums: .space 400 # space for an array of 100 ints
max: .word
count: .word
mychars: .space 100 # space for an array of 100 chars
prnums: .asciiz "Enter a number: "
prch: .asciiz "Enter a character: "
- Write the code to read 100 ints into nums.
- Write the code to read positive ints into nums. Stop reading when
the user enters 0. Keep track of how many ints you read (not including the
zero) and store that value in count.
- Assume that you have already written the code to read 100 ints
into nums. Write the code to print out every array element.
- Assume that you have already written the code to read 100 ints
into nums. Write the code to print out every other array element
(nums[0], nums[2], nums[4], ..., nums[98]).
- Assume that you have already written the code to read 100 ints
into nums. Write the code to find the largest int and store it in max.
- Assume that you have already written the code to read 100 ints
into nums. Write the code to print nums backward (print nums[99],
nums[98], ..., nums[0]).
- Write the code to read 100 chars into mychars.
- Assume that you have already written the code to read 100 chars into
mychars. Write the code to print out every array element.
- Assume that you have already written the code to read 100 chars into
mychars. Write the code to count the number of times the character 'a'
appears in the array, and print that count.
Email Me |
Office Hours |
My Home Page |
Department Home |
MCC Home Page
© Copyright Emmi Schatz 2009