반복문 : for, while
- while 반복문
1 2 3 4 5 6 7 8 9 10 | int cnt = 10; int main() { while( cnt > 0 ) { printf("%d\n", cnt); cnt--; } return 0; } | cs |
- for 반복문
1 2 3 4 5 6 7 8 9 10 | int cnt = 10; int main() { for( ; cnt > 0; cnt --){ printf("%d\n", cnt); cnt--; } return 0; } | cs |
for, while 반목문은 거의 동일하게 표현된다는것을 알 수 있다.
어셈블리로 표현하면 아래와 같이 표현할 수 있다.
EX) 문자열을 압력받아서 거꾸로 표현하는 어셈블리 프로그램을 작성하시오
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <stdio.h> char buffer[1024]; int end = 0; int main() { printf("input: "); gets(buffer); while ( buffer[end] != NULL ) end++; end--; while( end >= 0 ){ printf("%c", buffer[end]); end--; } printf("\n"); return 0; } | cs |
어셈블리로 표현하면 아래와 같이 나타낼 수 있다.
'Pwnable' 카테고리의 다른 글
어셈블리에서의 함수 및 메모리 구조1 (0) | 2018.07.30 |
---|---|
어셈블리 프로그래밍 심화3 (0) | 2018.07.19 |
어셈블리 프로그래밍 심화2 (0) | 2018.07.12 |
어셈블리 프로그래밍 심화 및 CPU 구조 (0) | 2018.07.04 |
어셈블리 와 C언어, 리눅스의 이해 (0) | 2018.07.04 |