The program I'm reversing does simple multiplication between float number and 8 byte integer:
section .data
va: dt 1.4426950408889634074
vb: dd 0x42424242
dd 0x41414141
section .text
global main
main:
fld tword[va]
fmul qword[vb]
ret
Result under gdb:
Breakpoint 1, 0x08048360 in main ()
(gdb) x/i $eip
0x8048360 <main>: fld TBYTE PTR ds:0x804953c
0x8048366 <main+6>: fmul QWORD PTR ds:0x8049546
0x804836c <main+12>: ret
(gdb) x/gx 0x8049546
0x8049546 <vb>: 0x4141414142424242
(gdb) si
0x08048366 in main ()
0x0804836c in main ()
(gdb) info float
=>R7: Valid 0x4014c726039c95268dc4 +3262848.902912714389
I'm trying to recreate this program in C (same 32bit environment):
#include <stdio.h>
int main() {
unsigned long long vb = 0x4141414142424242LL;
float r, va = 1.4426950408889634074F;
r = va * vb;
printf("%f\n", r);
}
...but I get very different results:
$ ./test
6783712964982603776.000000
What I'm doing wrong in my C program?