I'm fairly new to X86-64 assembly, and was writing a hybrid program (c++ and assembly) to get the user's name, two sides of a triangle, and one angle. my following code :
Here's the prompts :
segment .data
align 16
NamePrompt db "--Please enter your name: ",0
SideAPrompt db "--Please enter side A : ",0
SideBPrompt db "--Please enter side B : ",0
AnglePrompt db "--Please enter Angle : ",0
Entryconf1 db "You entered--------------------> %1.5lf and %1.5lf and %1.5lf and %1.5lf ",0
XMM13Value db "XMM 13 Value : %1.5lf",10,0
andstat db ", and ",0
Conclusion db "The Triangle with side A = %1.5lf"
db ", Side B = %1.5lf, and Angle= %1.5lf"
db ", has an Area = sq units \0",0
;Entryconf2 db "Is that correct------->",0
goodbye db "Hope to see you again, Goodbye",10
stringformat db "%s", 0
align 64
Here's the uninitialized variables :
segment .bss ;uninitialized data
Name resb 32
SideA resd 32
SideB resd 32
Angle resd 32
TArea resd 32
and here's how I'm obtaining the value of SideA and attempting to add it to xmm13 :
;ask for SideA
mov rax, 0
mov rdi, SideAPrompt
call printf
;obtain SideA
mov rax, 0
mov rdi, SideA
mov rsi, 32
mov rdx, [stdin]
call fgets
;save in xmm13
mov rax, SideA
push rax
movsd xmm13, [rsp]
pop rax
;print xmmm13
mov rax,2
mov rdi, XMM13Value
;movsd xmm0, xmm13
call printf
I get
XMM 13 Value : 0.00000
Also, I'm trying to print out a statement that confirms all the entries :
Entryconf1 db "You entered--------------------> %1.5lf and %1.5lf and %1.5lf and %1.5lf ",0
but when I use the following code :
mov qword rax, 2
mov rdi, Entryconf1
mov rsi, SideA
mov rdx, SideB
mov rbx, Angle
call printf
it outputs :
You entered--------------------> 0.00000 and 0.00000 and 0.00000 and -nan
Any help would be greatly appreciated.