어셈블리어(AT&T) - GNU 어셈블러
* 인스트럭션(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