5-37 PM Thu Jan 31 72% cs sfuca 2 of 3 . 10 marks) Convolution-Part The realm of digital signal processing (DSP) attempts to quantify the cont inous world by using a sequence of discrete samples. Those samples are usually represented s an array of length N, say char x [N 0123456789 10 11 12 13 As a fuaction, the signal can have many turas maxima and minima and also inflection points periodic behaviours, and perhaps other mathematically usefal properties. To determine them, a con eolution can be used, which is defined as follows Let h be a second array. The convolution of x with h b. (x * h)Inl- x [m] , h[n-m]. This is essentially a dot product where one array runs forwards and the other one backwards. Conven tionally, array elements that are not defined have a value of O. E.g, Following the figure, let: xtO..143-0,4,8,6,5,6,7,4,1,-2,-5,-7,-4,-2,0 Then the convolution would be (2+h) [O.16]-[0.40,-6, 1, 2,0.-4.0.0.0.1, 5.-1,0.-2,0 Many arrays h[1 are possible, each supplying some information about the characteristics of the signal This particular h highlights changes in direction: large positive bumbers indicate an upward swing (concave up): large negatives indicate a dowward swing (concave down). For this problem, you will implement a function convO that computes the reversed dot product of two arrays. In other words, given a pair of arays x [n], hn], it will return x [m] h[n] 5-37 PM Thu Jan 31 72% 3 of 3 The Specification The registers %rdi and %rsi will contain the base pointer of the two arrays, and %edx will contain the length of the arays. Both arrays contain char values, Le, one byte per value, each in the range -128, 127 * Thoe register %al will carry the return vnlue, the snmmation ks described above. Your code will Deed to use the inul instruction. Note, however, there is no imulb instruction. * As per the function call protocol, you may only use the scratch registers %raxZrcx. %rdxZr 1. rdi. %rS.xr9Zr10 and %r 11. You uill submit (a) 7 marks an eleetronle copy of your cov.s assembly souree. This code will be tested for correct (b) 3 marks)a hard copy of your conv.s assembly source. Your soarce should be well documented, ness with a varicty of inpats. so that any other programmer coukd read your code and mdenstand it. Your documentation shall inelade a synopsis of the algorithm you used to perform the computation. (c) 3 BONUS marks) Because of the size of the retarn value, there is a chance of overflow, ie, that the true result falls out of the range [-128, 127. Though one solution might be to broaden the range. , return a abort or an int, another solution is to return whether or not the result generated an overflow by another means: by using a register. For the BONUS marks, amend your conv.s so that when your subroatine returns, the register rdr will contain the value 0 if and olly if no overflow occurred. (The register %al should still hold the result of the computation) Thu 17:34 Text Editor Home snap firefox comenon Downloads care-as , main.c Open sinclude
har conv(char *, char , tnt): / char conv(char x, char *h, unt n); adefine N 28 #defLne M 3 char signal[N)-{ o, o, o, 4, B, 6, s, 6, 7, 4, i, .2, .5, -7, -1, .2, o, o, o char h[M] 1, -2, 1: votd natn O int ti puts("Original stgnal: printfC s4d", signalftp) putchar('In'): puts("Convolved signal: "): for (t = o; t har conv(char *, char , tnt): / char conv(char x, char *h, unt n); adefine N 28 #defLne M 3 char signal[N)-{ o, o, o, 4, B, 6, s, 6, 7, 4, i, .2, .5, -7, -1, .2, o, o, o char h[M] 1, -2, 1: votd natn O int ti puts("Original stgnal: printfC s4d", signalftp) putchar('In'): puts("Convolved signal: "): for (t = o; t<><>