zj3t

email: euntaejang@gmail.com

Latest Posts

어셈블리어-조건문

By 오후 11:53 ,


(gdb) disassemble Temp
Dump of assembler code for function Temp:
   0x080483ed <+0>: push   ebp
   0x080483ee <+1>: mov    ebp,esp
   0x080483f0 <+3>: sub    esp,0x10
   0x080483f3 <+6>: mov    DWORD PTR [ebp-0x4],0x1
   0x080483fa <+13>: cmp    DWORD PTR [ebp+0x8],0x1
   0x080483fe <+17>: jne    0x8048406 <Temp+25>
   0x08048400 <+19>: add    DWORD PTR [ebp+0x8],0x1
   0x08048404 <+23>: jmp    0x804840a <Temp+29>
   0x08048406 <+25>: add    DWORD PTR [ebp-0x4],0x1
   0x0804840a <+29>: mov    eax,DWORD PTR [ebp-0x4]
   0x0804840d <+32>: leave
   0x0804840e <+33>: ret  
End of assembler dump.
(gdb) disassemble main
Dump of assembler code for function main:
   0x0804840f <+0>: push   ebp
   0x08048410 <+1>: mov    ebp,esp
   0x08048412 <+3>: sub    esp,0x4
   0x08048415 <+6>: mov    DWORD PTR [esp],0x1
   0x0804841c <+13>: call   0x80483ed <Temp>
   0x08048421 <+18>: leave
   0x08048422 <+19>: ret  
End of assembler dump.

Quiz. 이 어셈블리어를 C언어로 구현하여라.


1 #include <stdio.h>
2 int Temp(int a)
3 {
4 int b=1;
5
6 if(a==1)
7 {
8 a++;
9 }
10 else
11 {
12 b++;
13 }
14
15 return b;
16 }
17
18 int main(int argc, char* argv[])
19 {
20 Temp(1);
21 }


You Might Also Like

0 개의 댓글