0% found this document useful (0 votes)
8 views2 pages

Homework Chapter 7

MIPS memory exercises
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Homework Chapter 7

MIPS memory exercises
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

HomeWorks

Assignment 1 Show the content of memory for the following declarations


a. .data
x: .word 0x1234
y: .byte 02
z: .half 05
b. .data
x: .word 0x1234

y: .half 02

z: .word 05
c. .data
x: .word 0x1234
y: .ascii “abcde”
z: .byte 05
d. .data
y: .asciiz “abcd”
z: .byte 05
x: .word 0x1234
e. .data
y: .ascii “abc”
z: .half 05
x: .word 0x1234
Assignment 2 Write a program which declares 4 integer variables: a, b, c, and sum. Allows user
input 3 integer variables a, b, c from keyboard.
a. Calculate sum = a+b-c
b. Print sum to screen

Assignment 3 Write a program which declares 1-D integer array with 5 elements and an integer
n.
a. Allow user input all elements of this array from keyboard
b. Calculate n = (array[0] + array[2] + array[4]) and print n to screen
c. Print sum of all elements of the array to screen
d. Allow user input variable n from keyboard then update all elements of array by using this
formulate: array[i] = array[i] + n

Assignment 4 Write a program which declares 2-D array A[3][3] and allow user input 4
elements of this array.
a. Print sum of A[0][0] + A[1][1] + A[2][2] to screen
b. Print sum of all elements at the first row of the array to screen
c. Print sum of all elements at the second column of the array to screen
d. Print sum of all elements of the array to screen

Assignment 5 Write a program which declares two integer x, y and a pointer p. Pointer p is a
word
a. Allow user input values for x and y from keyboard
b. Convert this C code to assembly: p = &x
c. Convert this C code to assembly *p = *p + y + 10

Assignment 6 Write a program which declares an asciiz string S =”wxyz”.


a. Update each element of this string by using this formulate: S[i] = S[i]-1 (except the ‘\0’)
b. Print the updated string to screen
c. Print the character at position 3 (or S[3]).

Assignment 7 Write a program which declares an ascii string S = “hello word” and an integer n
a. Allow user input value for n from keyboard and print its value to screen
b. Allow user input a string with length 8 to S and print S and n to screen
c. Allow user input a string with length 15 to S and print S and n to screen. Did n still keep
the previous value? Explain your answer.

You might also like