답이 안나옵니다.
C code 로 프로그램 작성하고,
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]){
int answer=0;
int num;
for(int i=1; i<argc; i++) {
num = (argvi-'0')*10 + (argvi-'0');
if(num%3==0)
answer += num;
else
answer += num*2;
}
printf("%d",answer%100);
return answer%100;
}
ubuntu@ubuntu:/mnt/hgfs/STUDY$ gcc -S -masm=intel dream130.c
ubuntu@ubuntu:/mnt/hgfs/STUDY$ gcc -c -masm=intel dream130.s
ubuntu@ubuntu:/mnt/hgfs/STUDY$ objdump -d dream130.o
dream130.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <main>:
0: f3 0f 1e fa endbr64
4: 55 push %rbp
5: 48 89 e5 mov %rsp,%rbp
8: 89 7d ec mov %edi,-0x14(%rbp)
b: 48 89 75 e0 mov %rsi,-0x20(%rbp)
f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%rbp)
16: c7 45 f8 01 00 00 00 movl $0x1,-0x8(%rbp)
1d: e9 95 00 00 00 jmpq b7 <main+0xb7>
22: 8b 45 f8 mov -0x8(%rbp),%eax
25: 48 98 cltq
27: 48 8d 14 c5 00 00 00 lea 0x0(,%rax,8),%rdx
2e: 00
2f: 48 8b 45 e0 mov -0x20(%rbp),%rax
33: 48 01 d0 add %rdx,%rax
36: 48 8b 00 mov (%rax),%rax
39: 0f b6 00 movzbl (%rax),%eax
3c: 0f be c0 movsbl %al,%eax
3f: 8d 50 d0 lea -0x30(%rax),%edx
42: 89 d0 mov %edx,%eax
44: c1 e0 02 shl $0x2,%eax
47: 01 d0 add %edx,%eax
49: 01 c0 add %eax,%eax
4b: 89 c1 mov %eax,%ecx
4d: 8b 45 f8 mov -0x8(%rbp),%eax
50: 48 98 cltq
52: 48 8d 14 c5 00 00 00 lea 0x0(,%rax,8),%rdx
59: 00
5a: 48 8b 45 e0 mov -0x20(%rbp),%rax
5e: 48 01 d0 add %rdx,%rax
61: 48 8b 00 mov (%rax),%rax
64: 48 83 c0 01 add $0x1,%rax
68: 0f b6 00 movzbl (%rax),%eax
6b: 0f be c0 movsbl %al,%eax
6e: 83 e8 30 sub $0x30,%eax
71: 01 c8 add %ecx,%eax
73: 89 45 fc mov %eax,-0x4(%rbp)
76: 8b 4d fc mov -0x4(%rbp),%ecx
79: 48 63 c1 movslq %ecx,%rax
7c: 48 69 c0 56 55 55 55 imul $0x55555556,%rax,%rax
83: 48 c1 e8 20 shr $0x20,%rax
87: 48 89 c2 mov %rax,%rdx
8a: 89 c8 mov %ecx,%eax
8c: c1 f8 1f sar $0x1f,%eax
8f: 89 d6 mov %edx,%esi
91: 29 c6 sub %eax,%esi
93: 89 f0 mov %esi,%eax
95: 89 c2 mov %eax,%edx
97: 01 d2 add %edx,%edx
99: 01 c2 add %eax,%edx
9b: 89 c8 mov %ecx,%eax
9d: 29 d0 sub %edx,%eax
9f: 85 c0 test %eax,%eax
a1: 75 08 jne ab <main+0xab>
a3: 8b 45 fc mov -0x4(%rbp),%eax
a6: 01 45 f4 add %eax,-0xc(%rbp)
a9: eb 08 jmp b3 <main+0xb3>
ab: 8b 45 fc mov -0x4(%rbp),%eax
ae: 01 c0 add %eax,%eax
b0: 01 45 f4 add %eax,-0xc(%rbp)
b3: 83 45 f8 01 addl $0x1,-0x8(%rbp)
b7: 8b 45 f8 mov -0x8(%rbp),%eax
ba: 3b 45 ec cmp -0x14(%rbp),%eax
bd: 0f 8c 5f ff ff ff jl 22 <main+0x22>
c3: 8b 45 f4 mov -0xc(%rbp),%eax
c6: 48 63 d0 movslq %eax,%rdx
c9: 48 69 d2 1f 85 eb 51 imul $0x51eb851f,%rdx,%rdx
d0: 48 c1 ea 20 shr $0x20,%rdx
d4: 89 d1 mov %edx,%ecx
d6: c1 f9 05 sar $0x5,%ecx
d9: 99 cltd
da: 29 d1 sub %edx,%ecx
dc: 89 ca mov %ecx,%edx
de: 6b d2 64 imul $0x64,%edx,%edx
e1: 29 d0 sub %edx,%eax
e3: 89 c2 mov %eax,%edx
e5: 89 d0 mov %edx,%eax
e7: 5d pop %rbp
e8: c3 retq
하여 나온 hex값들을가지고
f30f1efa554889e5897dec488975e0c745f4c745f801e9958b45f84898488d14c5488b45e04801d0488b0fb60fbec08d50d089d0c1e201d1c089c18b45f84898488d14c5488b45e04801d0488b4883c10fb60fbec083e831c88945fc8b4dfc4863c14869c05655555548c1e8204889c289c8c1f81f89d629c689f089c201d201c289c829d085c075088b45fc0145f4eb088b45fc01c145f48345f8018b45f83b45ec0f8c5fffffff8b45f44863d04869d21f85eb5148c1ea2089d1c1f9059929d189ca6bd26429d089c289d05dc3
가 나와서 입력을 했는데, 답이 나오지 않습니다.
어떤 부분을 보면 좋을까요?
kos
댓글 32