Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Im getting a seg fault somewhere in my code but cant figure out why. x 8 6 assembly get _ input: ; Prompt user for
Im getting a seg fault somewhere in my code but cant figure out why. x assembly
getinput:
; Prompt user for a float
mov rax,
mov rdi, promptforfirstside ; Please enter first side:
call printf
; Get user name input
mov rax,
sub rsp ; push qword
mov rdi, rsp
mov rsi,
mov rdxstdin
call fgets
; Remove the newline character
mov rax,
mov rdi, rsp
call strlen
mov rsp rax byte
;Check if input is a float
mov rax,
mov rdi, rsp
call isfloat
cmp rax, false
je badinput
; Convert the input from string to float
mov rax,
mov rdi, rsp
call atof
movsd xmm xmm
jmp getinput
badinput:
add rsp
; Tell the user the input is bad
mov rax,
mov rdi, printbadinput
call printf
; 'Loop' back to the beginning
jmp getinput
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SECOND SIDE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getinput:
; Prompt user for a float
mov rax,
mov rdi, promptforsecondside ; Please enter a float number:
call printf
; Get user name input
mov rax,
sub rsp ; push qword
mov rdi, rsp
mov rsi,
mov rdxstdin
call fgets
; Remove the newline character
mov rax,
mov rdi, rsp
call strlen
mov rsp rax byte
;Check if input is a float
mov rax,
mov rdi, rsp
call isfloat
cmp rax, false
je badinput
; Convert the input from string to float
mov rax,
mov rdi, rsp
call atof
movsd xmm xmm
jmp getinput
badinput:
add rsp ; pop that qword
; Tell the user the input is bad
mov rax,
mov rdi, printbadinput ;That ain't no float, try again!
call printf
; 'Loop' back to the beginning
jmp getinput
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ANGLE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
getinput:
; Prompt user for a float
mov rax,
mov rdi, promptforangle ; Please enter a float number:
call printf
; Get user name input
mov rax,
sub rsp ; push qword
mov rdi, rsp
mov rsi,
mov rdxstdin
call fgets
; Remove the newline character
mov rax,
mov rdi, rsp
call strlen
mov rsp rax byte
;Check if input is a float
mov rax,
mov rdi, rsp
call isfloat
cmp rax, false
je badinput
; Convert the input from string to float
mov rax,
mov rdi, rsp
call atof
movsd xmm xmm
jmp exit
badinput:
add rsp ; pop qword
; Tell user input is bad
mov rax,
mov rdi, printbadinput
call printf
; 'Loop' back to the beginning
jmp getinput
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EXIT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
exit:
add rsp
; Convert the float from degree to radian
mulsd xmm qwordpi
divsd xmm qwordoneeighty
; Find cos of the angle
mov rax,
movsd xmm xmm
call cos
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started