/* Implement the following specified functions adhering to the * C/assembly-interface conventions. */ /* In: v1 - vector 1 * v2 - vector 2 and destination of sum * n - dimension of vectors * Out: -1 - if error (e.g., overflow) * 0 - success * Computes vector sum of v1 and v2 of dimension n. For example, * the vsum of { 1, 3, -9 } and { -1, 3, 3 } is { 0, 6, -6 }. * * Difficulty: easy */ short vsum(short * v1, short * v2, unsigned short n); /* In: table - table of unsigned shorts (2 bytes) * n - size of table * Out: difference between maximum and minimum element * (undefined if n == 0) * For example, the range of {1, 7, 3, 9} is 9 - 1 = 8. * * Difficulty: medium */ short range(unsigned short * table, unsigned short n); /* In: data - table of ASCII characters * n - number of characters * Out: * Adds an odd parity bit to each character in bit position #7 so that * all characters have an odd number of bits. For example, if the * original data are { $61, $61, $72, $6f, $6e }, then the final data * are { $61, $61, $f2, $ef, $6e } since $61 has 3 bits (odd), $72 has * 4 bits (even), $6f has 6 bits (even), and $6e has 5 bits (odd). * * Difficulty: medium (conceptual) */ void parity(char * data, unsigned short n); /* Add an implementation of the following function to buf.x68: * * In: buf - a pointer to memory that has been initialized via new * Out: the number of values that can be put'ed without error * (assuming that get is not called) * Returns the available space in the buffer. * * Difficulty: hard (conceptual) */ short space(char * buf);