How to convert the code below to use std::vector and std::copy. Is it even possible? I'm just having some fun and trying to convert a piece of my code to c++ style.
This is what I have done so far, but I'm a bit stuck in std::copy.Code:// Just an example, missing some stuff. std::string vendor; // already in c++ unsigned int registers[4]; asm volatile ( "pushq %%rbx\n\t" "cpuid\n\t" "movq %%rax, (%1)\n\t" "movq %%rbx, 4(%1)\n\t" "movq %%rdx, 8(%1)\n\t" "movq %%rcx, 12(%1)\n\t" "popq %%rbx\n\t" : : "a"(cpuidOperation), "S"(registers) ); memcpy((void *)vendor.c_str(),®isters[1],3*sizeof(unsigned int));
Thanks for any hints.Code:std::string vendor; std::vector<unsigned int> registers_cpuinfo; registers_cpuinfo.reserve(4); asm volatile ( "pushq %%rbx\n\t" "cpuid\n\t" "movq %%rax, (%1)\n\t" "movq %%rbx, 4(%1)\n\t" "movq %%rdx, 8(%1)\n\t" "movq %%rcx, 12(%1)\n\t" "popq %%rbx\n\t" : : "a"(cpuidOperation), "S"(®isters_cpuinfo) ); std::copy(registers_cpuinfo.begin(), registers_cpuinfo.begin() + 3*sizeof(unsigned int),vendor.begin()); ??



LinkBack URL
About LinkBacks




