가능한 중복 : 어셈블리에서 고조파 시리즈의 버전을하려고
harmonic series with x86-64 assembly요약
현재 코드는 1 + 2 + 1합니다/3 + 1/4 + 1/n의 합계 값이 입력 된 값보다 커질 때까지. (부동 소수점 값)
현재 코드를 통해 첫 번째 루프 후 루프에서 빠져 나와는
내 종료 조건이다 0.33333를 출력?
denominator:
xor r14,r14 ;zero out r14 register
add r14, 2 ;start counter at 2
fld1 ;load 1 into st0
fxch st2
denomLoop:
fld1
mov [divisor], r14 ;put 1 into st0
fidiv dword [divisor] ;divide st0 by r14
inc r14 ;increment r14
fst qword [currentSum] ;pop current sum value into currentSum
addParts:
fxch st2 ;put the current value that is in st2 into st0
fadd qword [currentSum] ;add result of first division to 1
fxch st2 ;place result of addition into st2
fld qword [realNumber] ;place real number into st0
;compare to see if greater than inputed value
fcom st2 ;compare st0 with st2
fstsw ax ;needed to do floating point comparisons on FPU
sahf ;needed to do floating point comaprisons on FPU
jae done ;jump if greater than
jmp denomLoop ;jump if less than
낯선 사람에게 문제를 알리기보다는 디버거에서 코드를 단계별로 실행해야합니다. –
의견을 보내 주셔서 감사합니다. 게시판은 협력하고 서로 도울 수 있다고 생각했습니다. 당신은 내가 이미 이것을 디버깅하려하지 않았다고 생각합니까? – user1050632
Stack Overflow는 메시지 보드가 아닙니다. 다른 사람들이 코드를 디버깅 할 수있는 곳이 아닙니다. 사용자는 디버깅 작업의 결과를 알리지 않았습니다. 디버거에서이 단계를 밟아 본다면 자신의 질문에 대답 할 수 있습니다. –