넷와이드 어셈블러

넷와이드 어셈블러(Netwide Assembler, NASM)은 인텔 x86 아키텍처용 어셈블러이자 역어셈블러이다. 16비트, 32비트(IA-32), 64비트(x86-64) 프로그램 작성에 사용할 수 있다. NASM은 가장 대중적인 리눅스용 어셈블러들 가운데 하나로 인식된다.[1]

넷와이드 어셈블러
원저자Simon Tatham, 줄리안 홀
개발자H. Peter Anvin
안정화 버전
2.13.03 / 2018년 2월 20일(6년 전)(2018-02-20)
저장소
운영 체제윈도우, 유닉스 계열, OS/2, OS X, 도스
언어영어
종류x86 어셈블러
라이선스BSD 2-clause
웹사이트www.nasm.us

NASM은 원래 줄리안 홀(Julian Hall)의 도움을 받아 Simon Tatham에 의해 작성되었다. 2016년 기준으로, H. Peter Anvin이 주도하는 조그마한 팀에 의해 유지보수되고 있다.[2] 단순화된 (2-clause) BSD 라이선스 조항에 의거하여 출시되는 오픈 소스 소프트웨어이다.[3]

운영 체제별 프로그램의 예 편집

아래는 도스용 운영 체제를 위한 헬로 월드 프로그램이다.

section .textorg 0x100movah, 0x9movdx, helloint0x21movax, 0x4c00int0x21section .datahello:db 'Hello, world!', 13, 10, '$'

비슷한 프로그램으로 마이크로소프트 윈도우용의 예는 다음과 같다:

global _mainextern _MessageBoxA@16extern _ExitProcess@4section code use32 class=code_main:pushdword 0 ; UINT uType = MB_OKpushdword title ; LPCSTR lpCaptionpushdword banner ; LPCSTR lpTextpushdword 0 ; HWND hWnd = NULLcall_MessageBoxA@16pushdword 0 ; UINT uExitCodecall_ExitProcess@4section data use32 class=databanner:db 'Hello, world!', 0title:db 'Hello', 0

리눅스용으로는 다음과 같다:

global _startsection .text_start:moveax, 4 ; writemovebx, 1 ; stdoutmovecx, msgmovedx, msg.lenint0x80 ; write(stdout, msg, strlen(msg));moveax, 1 ; exitmovebx, 0int0x80 ; exit(0)section .datamsg:db"Hello, world!", 10.len:equ$ - msg

아래는 애플 OS X용 64비트 프로그램의 하나로, 키 입력을 받아 화면에 표시하는 부분이다

global _startsection .dataquery_string:db"Enter a character: "query_string_len:equ$ - query_stringout_string:db"You have input: "out_string_len:equ$ - out_stringsection .bssin_char:resw 4section .text_start:movrax, 0x2000004 ; put the write-system-call-code into register raxmovrdi, 1; tell kernel to use stdoutmovrsi, query_string; rsi is where the kernel expects to find the address of the messagemovrdx, query_string_len; and rdx is where the kernel expects to find the length of the messagesyscall; read in the charactermovrax, 0x2000003; read system callmovrdi, 0; stdinmovrsi, in_char; address for storage, declared in section .bssmovrdx, 2; get 2 bytes from the kernel's buffer (one for the carriage return)syscall; show user the outputmovrax, 0x2000004; write system callmovrdi, 1; stdoutmovrsi, out_stringmovrdx, out_string_lensyscallmovrax, 0x2000004; write system callmovrdi, 1; stdoutmovrsi, in_charmovrdx, 2; the second byte is to apply the carriage return expected in the stringsyscall; exit system callmovrax, 0x2000001; exit system call        xor     rdi, rdisyscall

개발 편집

2007년 11월 28일, 버전 2.00이 출시되었으며 x86-64 확장 지원을 추가하였다.[2] 개발 버전들은 소스포지에 업로드되지 않지만, 프로젝트 웹 페이지에서 이용 가능한 바이너리 스냅샷을 포함하여 프로젝트 자체의 Git 저장소에서 검진된다.

NASM 문서의 검색 엔진 또한 이용이 가능하다.[4]

2.07 버전의 NASM은 단순화된 (2-clause) BSD 라이선스 하에서 배포된다.

RDOFF 편집

RODFF(Relocatable Dynamic Object File Format)는 개발자들이 NASM의 오브젝트 파일 출력 속성을 테스트하는 목적으로 사용된다. 상당 부분 NASM의 내부 구조에 기반을 두고 있으며[5] 필수적으로 출력 드라이버 함수 호출과 실행 가능한 코드나 데이터를 포함하는 섹션 배열의 직렬화를 포함하는 헤더로 이루어져 있다. 링커와 로더를 포함한, 이 포맷을 사용하는 도구들은 NASM 배포판에 포함되어 있다.

같이 보기 편집

각주 편집

  1. Ram Narayan. “Linux assemblers: A comparison of GAS and NASM”. 2013년 10월 3일에 원본 문서에서 보존된 문서. two of the most popular assemblers for Linux, GNU Assembler (GAS) and Netwide Assembler (NASM) 
  2. “The Netwide Assembler”. 2008년 6월 27일에 확인함. 
  3. “NASM Version History”. 2009년 7월 19일에 확인함. 
  4. “NASM Doc Search Engine”. 2010년 1월 23일에 원본 문서에서 보존된 문서. 2009년 9월 14일에 확인함. 
  5. “NASM Manual Ch. 6”. 2008년 6월 27일에 확인함. 

참고 문헌 편집

  • Jeff Duntemann (2000). 《Assembly Language Step by Step》. J Wiley and Sons. ISBN 0-471-37523-3. 

외부 링크 편집