Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operation 관련 버그 모음 #19

Open
timedilation opened this issue Nov 25, 2018 · 3 comments
Open

operation 관련 버그 모음 #19

timedilation opened this issue Nov 25, 2018 · 3 comments

Comments

@timedilation
Copy link
Collaborator

보고서 쓸 때 자료를 남겨두면 편할 것 같아서 만들음. 생기고 해결할 때마다 댓으로 달 예정.

@timedilation
Copy link
Collaborator Author

reference subtraction bug

(test2) d[0] := a-b
-1
(test3) d[1] := b
4
(test4) d[0] := d[0] - d[1]
5
 movq    -296(%rbp), %rax        #   [  1] <  3> 55:     sub    t46_%r9 <- @t39_%r9, @t45_%r8 << t102_%r12 t39_%r9 t45_%r8 >>
 movl    (%rax), %eax-----------
movq    -320(%rbp), %rdx-------
movl    (%rdx), %edx-----------
subl    %eax, %edx-------------
movl    %edx, -324(%rbp)-------

그냥 sub src, dest 순서 문제였음;
reference의 경우 sub src2, src1 해야하는데 sub src1, src2 해버림

@timedilation
Copy link
Collaborator Author

timedilation commented Nov 29, 2018

x := a[0]/a[1] 꼴일 때
%rdx가 0으로 덮어져서 문제가됨 (%rdx에 쓰레기값이 있어도 오류뜸)

c1b175a 로 땜질함.
나누는 쪽이 reference나 const일 때 임시 변수에 옮겨 담아서 그것으로 나누게 함 - minki

@timedilation
Copy link
Collaborator Author

timedilation commented Nov 29, 2018

 │0x400d1e <l_CalcPrimes_14+20>   mov    -0x50(%rbp),%rdi                                                                                         
 │0x400d22 <l_CalcPrimes_14+24>   callq  0x4010f3 <WriteStr>                                                                                      
 │0x400d27 <l_CalcPrimes_14+29>   mov    -0x88(%rbp),%edx 

-0x88(%rbp) 값이 WriteStr call 이후에 바뀌는 것을 확인(????)

->
stack offset 문제로 rsp가 실제 스택 크기보다 위를 가리키고 있었음
param num을 스택 사이즈 계산에 넣은게 문제였음.
이 라인을 삭제함.

 54   if(param_num > 6){
 55     local_ofs -= 6 * 8;
 56     param_ofs = 16 + (param_num - 6)*8;                                                                                                           
 57   }
 58   else
 59     local_ofs -= param_num * 8;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant