My code is trying to find the entropy of a signal (stored in data and interframe - in the full code these would contain the signal, here I ve just put in some random values). When I compile with gcc temp.c it compiles and runs fine. Output:
entropy: 40.174477
features: 0022FD06
features[0]: 40
entropy: 40
但是,当我用快乐——最快的————我们——智慧——来汇编时,它汇编了材料,但没有执行第48条。 它需要拥有所有四条旗帜才能失败,其中三条是罚款。
这部法典可能看起来是 we的——我只把失败的比喻排除在一个更大的方案之外。 我只想到编造者旗帜是什么,有人把他们带进去(他们通常更多),但我发现这些是坏的。
一切帮助都受到高度赞赏。
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
#include <math.h>
static void calc_entropy(volatile int16_t *features, const int16_t* data,
const int16_t* interframe, int frame_length);
int main()
{
int frame_length = 128;
int16_t data[128] = {1, 2, 3, 4};
int16_t interframe[128] = {1, 1, 1};
int16_t a = 0;
int16_t* features = &a;
calc_entropy(features, data, interframe, frame_length);
features += 1;
fprintf(stderr, "
entropy: %d", a);
return 0;
}
static void calc_entropy(volatile int16_t *features, const int16_t* data,
const int16_t* interframe, int frame_length)
{
float histo[65536] = {0};
float* histo_zero = histo + 32768;
volatile float entropy = 0.0f;
int i;
for(i=0; i<frame_length; i++){
histo_zero[data[i]]++;
histo_zero[interframe[i]]++;
}
for(i=-32768; i < 32768; i++){
if(histo_zero[i])
entropy -= histo_zero[i]*logf(histo_zero[i]/(float)(frame_length*2));
}
fprintf(stderr, "
entropy: %f", entropy);
fprintf(stderr, "
features: %p", features);
features[0] = entropy; //execution fails here
fprintf(stderr, "
features[0]: %d", features[0]);
}
Edit: I m 采用4.5.2, 并配有x86 结构。 而且,如果我汇编和操作虚拟局(gcc -lm -mstackrealign -msse -Os -ftree-vectorize temp.c),它就执行得当。
Edit2:我获得治疗
entropy: 40.174477
features: 00000000
然后,窗口发出的信息告诉我,该方案已经停止。
Edit3: In the five months since I originally posted the question I ve updated to gcc 4.7.0, and the code now runs fine. I went back to gcc 4.5.2, and it failed. Still don t know why!