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