使用fasm使用xmm regsister求和-linux:
$./fasm file.asm
$ gcc -s file.o -o file -lm
结果应该是14,但是我得到了7.000000000000000000000000000000
。
这是源代码:
format elf64
extrn printf
section '.data' writeable align 16
rad dq 7.0
fmt db "%.30lf",0ah,0
section '.text' executable align 16
public main
main:
push rbp
mov rbp,rsp
pxor xmm0,xmm0
movsd xmm0,[rad]
pxor xmm2,xmm2
movsd xmm2,[rad]
addsd xmm2,xmm0
mov rax,1
mov rdi,fmt
call printf
mov rsp,rbp
pop rbp
ret
答案 0 :(得分:1)
解决:
format elf64
extrn printf
section '.data' writeable align 16
rad dq 7.0
fmt db "%.30lf",0ah,0
section '.text' executable align 16
public main
main:
push rbp
mov rbp,rsp
pxor xmm0,xmm0
movsd xmm0,[rad]
movsd xmm2,[rad]
addsd xmm0,xmm2
mov rax,1
mov rdi,fmt
call printf
mov rsp,rbp
pop rbp
ret