프로그래밍 언어/규격

어셈블리어(AT&T) - GNU 어셈블러

jjryu 2013. 5. 1. 02:57

* 인스트럭션(instruction)

니모닉 + 오퍼랜드


오퍼랜드

값(immediate value) : ${숫자, 문자, 레이블, 매크로 상수 or 수식}

the data to access is embedded in the instruction itself

immediate mode addressing # 주소 값

pointer

c.f. lea

레지스터

register addressing mode

직접 메모리 참조(direct memory reference) : 숫자(메모리 주소; 변수, 포인터 변수), 수식?

direct addressing

dereference ; effective address

간접 메모리 참조(indirect momory reference) : 레지스터

disp(base register, index register, scale)

scale: 1, 2, 4, or 8

c.f. lea


* 디렉티브(assembler directives or pseudo-operations)

점(.)으로 시작되고, 끝에 :이 붙어 있지 않은 행


.file

.section

.section .rodata

문자열 리터럴 등의 변경할 수 없는 데이터

.text

or .section .text


기계어 코드

.data

or .section .data


글로벌 변수(초기 데이터)

.comm

.bss 섹션

초기 값이 없는 글로벌 변수


.globl

.local

.size

.type

{@object|@function}


.int

.long

.string


* 레이블(label) : 메모리 주소

':'으로 끝나 있는 행

이름


* 코멘트

행 코멘트: # ..

블록 코멘트: /* .. */

$ as maximum.s -o maximum.o


$ ld maximum.o -o maximum

/*

$ gcc -S -Os hello.c


$ as -o hello.o hello.s


$ gcc hello.o -o hello

*/
$ ld -dynamic-linker /lib/ld-linux.so.2 -o helloworld-lib helloworld-lib.o -lc # GNU/Linux systems
/lib/ld-linux.so.2 # dynamic linker
-lc # libc.so; the c library
searches for a file called libc.so in the standard places (listed in /etc/ld.so.conf and in the contents of the LD_LIBRARY_PATH environment variable)


참조 사이트: