Question: I need to convert this C functions into assembly x 8 6 - 6 4 , using this format ( use 6 4 bits registers

I need to convert this C functions into assembly x86-64, using this format (use 64 bits registers if needed):
name_of_the_function PROTO
.data
.code
name_of_the_function PROC
name_of_the_function ENDP
END
Here are the functions:
#include
#include
#include
#include
short average_volume(short *samples, int num_samples){
int sum =0;
for (int i =0; i < num_samples; i++){
sum += abs(samples[i]);
}
return (short)(sum / num_samples);
}
short find_reference_volume(short *average_volumes, int num_blocks){
short max_volume = average_volumes[0];
for (int i =1; i < num_blocks; i++){
if (average_volumes[i]> max_volume){
max_volume = average_volumes[i];
}
}
return max_volume;
}
void compute_amplification_factors(short *average_volumes, int num_blocks, short reference_volume, int *amplification_factors){
for (int i =0; i < num_blocks; i++){
amplification_factors[i]=(int) fabs(((float)reference_volume /(float) average_volumes[i])*8192);
}
}
void apply_amplification_factor(short *samples, int num_samples, int amplification_factor){
int amp_factor = amplification_factor;
for (int i =0; i < num_samples; i++){
int amplified_sample =((int)samples[i]* amp_factor)>>13;
if (amplified_sample >32767){
samples[i]=32767;
} else if (amplified_sample <-32768){
samples[i]=-32768;
} else {
samples[i]=(short) amplified_sample;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!