본문 바로가기

전체

[Assembly] 최대값 구하기 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. max.asmsection .datafirst db "first : "len1 equ $ -firstsecond db "second :"len2 equ $ -second section .bssnum1 resb 5num2 resb 5 section .textglobal _start _start:mov eax,4mov ebx,1mov ecx,firstmov edx,len1int 80h mov eax.. 더보기
[Assembly] 매크로 사용해보기 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. macro.asmsection .bss num resb 1 temp resb 1 section .data msg db "hello",0x0a len equ $ -msg msg1 db "hi",0x0a len1 equ $ -msg1 end db 0x0a section .test global _start ;매크로 사용 %macro write 2 mov eax,4 mov ebx,1 mov ecx,%1.. 더보기
[Assembly] 숫자 곱하기 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. mul.asmsection .datafirst db 'first : 'len1 equ $ -firstsecond db 'second : 'len2 equ $ -secondend db 0x0a section .bssnum1 resb 5num2 resb 5result resb 5result1 resb5 section .textglobal _start _start:;first 출력mov eax,4mo.. 더보기
[Assembly] 숫자 빼기 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. minus.asmsection .bssnum1 resb5num2 resb5result resb 5section .datafirst db "first : "len1 equ $ -firstsecond db "second : "len2 equ $ -secondend db 0x0asection .textglobal _start _start:;first 출력mov eax,4mov ebx,1mov ecx,.. 더보기
[Assembly] 숫자 나누기(몫과 나머지 출력) 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. div.asmsection .dataend db 0x0asection .bssresult1 resb5 result2 resb5 section .textglobal _start _start:mov al,'9'sub al,'0' mov bl,'2'sub bl,'0'div bl add al,'0'add ah,'0';ah -> 나머지 값이 들어감 mov [result1],almov [result2],a.. 더보기
[Assembly] 사칙연산 프로그램 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. calc.asmsection .datafirst db "first : "len1 equ $ -firstsecond db "second : "len2 equ $ -secondoperator db "operator : "len3 equ $ -operatorend db 0ahsection .bssnum1 resb 5num2 resb 5op resb 5result resb 5section .textgl.. 더보기
[Assembly] 배열선언 및 숫자더하기 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. array.asmsection .bss result resb1section .datax: db 2,3,4end db 0ahsection .textglobal _start _start:;배열 정보를 가져와서 함계를 출력해 본다.;초기화 부분mov eax,3;값이 3개가 들어있으니 3번 돌리겠다라고 가정한다.mov ebx,0;값을 더해주기 위한 공간 mov ecx,x;x가 가르키는 것은? --> 배.. 더보기
[Assembly] 숫자 더하기 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. addDouble.asmsection .datafirst db 'first : 'len1 equ $ -firstsecond db 'second : 'len2 equ $ -secondthird db 'third : 'len3 equ $ -thirdend db 0x0asection .bssnum1 resb 5;초기화 되지 않은 bss영역에서 5byte만큼 공간을 할당하겠다라는 의미num2 resb .. 더보기
[Assembly] 짝수 홀수 판별2 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. EvenOddcmp.asmsection .datanum db "num : "len1 equ $ -numeven db "even"len2 equ $ -evenodd db "odd"len3 equ $ -oddend db 0ahsection .bssinput resb 1temp resb 1section .textglobal _start _start:;num 출력mov eax,4mov ebx,1mov .. 더보기
[Assembly] 짝수 홀수 판별1 실행환경- cpu : 인텔계열(64bit)- 컴파일러 : nasm- 리눅스 : ubuntu 16.04 LTS 설치방법- sudo apt-get install nasm 컴파일- nasm -f elf64 파일명.asm -o 파일명.o --> 목적파일을 만든다.- ld 파일명.o -o 파일명 --> 실행파일을 만든다. EvenOdd.asmsection .bssinput resb 1temp resb 1section .datanum db "num : "len1 equ $ -numodd db "odd "len2 equ $ -oddeven db "even "len3 equ $ -evenend db 0ahsection .textglobal _start _start:;num 출력mov eax,4mov ebx,1mov e.. 더보기