0
이 코드를 컴파일하고 변수 검사 결과 # 2 - 스택 주변의 스택이 손상되었습니다. 예외. 그러나 변경했을 때 결과는 배열 크기는 2에서 4 예외가 사라졌습니다. 왜 이런 일이 일어날 지 설명해 주시겠습니까? 죄송합니다.이 질문이 너무 기본적인 것으로 판명 된 경우.런타임 검사 오류 # 2 - 변수 '결과'주위의 스택이 손상되었습니다.
#include "stdafx.h"
string get_cpu_name()
{
uint32_t data[4] = { 0 };
_asm
{
cpuid;
mov data[0], ebx;
mov data[4], edx;
mov data[8], ecx;
}
return string((const char *)data);
}
void assembler()
{
cout << "CPU is " << get_cpu_name() << endl;
float f1[] = { 1.f , 22.f};
float f2[] = { 5.f , 3.f };
float result[2] = { 0.f };
/*float f1[] = { 1.f , 22.f , 1.f , 22.f };
float f2[] = { 5.f , 3.f , 1.f , 22.f };
float result[4] = { 0.f };*/
_asm
{
movups xmm1, f1;
movups xmm2, f2;
mulps xmm1, xmm2;
movups result, xmm1;
}
/*for (size_t i = 0; i < 4; i++)*/
for (size_t i = 0; i < 2; i++)
{
cout << result[i] << "\t";
}
cout << endl;
}
int main()
{
assembler();
getchar();
return 0;
}
SSE 어셈블리에 익숙하지 않아서 'movups'가 몇 바이트 씩 움직입니까? – immibis
@immibis. 보시다시피 저는 SSE가 처음입니다. 'xmm1'의 크기에 의존한다고 가정합니다. 'xmm1'의 크기는 128 비트입니다. –
x86에서'float'은 32b = 4B 길이입니다 (응답에서 2 * 4의 소스). 따라서 float result [4] 또는 double result [2] ('double'은 64b) 또는'uint8_t result [16]'을 사용하여 16 * bytes *를 얻을 수 있습니다. – Ped7g