I am revisiting code that I wrote a while ago that does some math on large numbers. When I wrote the code, the lab had a few x86s that were split between 32 and 64 bits. My work was on UltraSPARCs, and I vaguely remember pulling this line of code from an Intel manual to be sure that the code was being used on a 64-bit CPU.
unsigned long x[4];
x[0] = 0;
x[1] = 0;
x[2] = 0;
x[3] = 0;
asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) );
If x[0] was 0, all was well and the program started chugging away.
Can anyone explain to me what this line of code actually does?
"In addition to numeric operands, the BYTE directive allows character operands with a single character or string operands with many characters.
. FILL tells the assembler to set aside the next location in the program and initial- ize it with the value of the operand.
mov byte ptr [value_two],"e" : "Byte ptr" lets the assembler know you want to store a byte. This must be done, because value_two was declared as a word.
The bytes .byte 15
and .byte 162
represent the CPUID
instruction.
When it executes you get results in EAX
, EBX
, ECX
, and EDX
.
These results will be stored in the array elements:
x[0] <- EAX
x[1] <- EBX
x[2] <- EDX
x[3] <- ECX
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With