我想要总结用户输入的整数。我通过比较和跳转设置循环。这是我接近它的方式,但我无法让它发挥作用。
;====Display message asking user========
mov qword rdi, stringformat
mov qword rsi, promptfloatnumber
mov qword rax, 0
call printf
;====Input number========
push qword 0
mov qword rdi, floatinputformat
mov qword rsi, rsp
mov qword rax, 0
call scanf
pop r14
;===== Copy input to SSE======
push r14
movsd xmm1, [rsp]
pop rax
;=== Keeps a total count throughout the loops? =====
addsd xmm0,xmm1 ;xmm0 = xmm0 + xmm1
;Then it jumps back up if user wants to input more values
然后我只需要显示xmm0即总权利?我不知道该怎么做。我试过这样的事情。
mov rdi, formatfloatdecimaloutput
mov qword rax, 1
call printf
答案 0 :(得分:1)
这就是我的OS X机器上clang
的作用 - 为了清晰起见注释:
# this is the constant '(double)2.5'
LCPI0_0:
.quad 4612811918334230528 ## double 2.500000e+00
## (0x4004000000000000)
leaq L_.str(%rip), %rdi # arg1 = format string address
movsd LCPI0_0(%rip), %xmm0 # float arg2 = 2.5
movb $1, %al # number of floating-point arguments
callq _printf
.section __TEXT,__cstring,cstring_literals
L_.str:
.asciz "%f\n" # here's the format string