Sunday, 8 September 2013

How to access values in an xmm register

How to access values in an xmm register

I'm looking to sum a total of integers inputted by the user. I have a loop
set up by using compares and jumps. Here is the way I'm approaching it,
but I can't get it to work.
;====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
Then I just need to display xmm0 which is the total right? I'm not sure
how to. I tried something like this.
mov rdi, formatfloatdecimaloutput
mov qword rax, 1
call printf

No comments:

Post a Comment