Jump to content

GNU Assembler

This is a fully translated article. Click here for more information.
From DawoumWiki, the free Mathematics self-learning
GNU Assembler
Developer(s)GNU Project
Stable release
2.34 / February 1, 2020; 4 years ago (2020-02-01)
Written inC
PlatformCross-platform
TypeAssembler
LicenseGNU General Public License v3
Websitewww.gnu.org/software/binutils/

공통적으로 gas 또는 간단히 그것의 실행-가능한 이름, as로 알려져 있는, GNU AssemblerGNU 프로젝트에 의해 사용되는 어셈블러입니다. 그것은 GCC의 기본 백-엔드입니다. 그것은 GNU 운영 시스템리눅스 커널, 및 다양한 다른 소프트웨어를 어셈블하기 위해 사용됩니다. 그것은 GNU Binutils 패키지의 일부입니다.

GAS 실행-가능as, 유닉스 어셈블러에 대해 표준 이름으로 이름-지어졌습니다. GAS는 크로스-플랫폼이고, 둘 다는 다양한 컴퓨터 아키텍처에서 실행되고 어셈블됩니다. GNU General Public License v3에 따라 출시된, GAS는 자유 소프트웨어입니다.

History

GAS의 첫 번째 버전은 1986-1987년에 출시되었습니다.[1] 그것은 Dean Elsner에 의해 작성되었고, VAX 아키텍처를 지원했습니다.[1]

General syntax

GAS는 지원되는 모든 아키텍처에서 작동하는 일반 구문을 지원합니다. 일반 구문은 어셈블러 지시문과 주석 처리 방법을 포함합니다.

Directives

GAS는 C 프로그래밍 언어에서 전처리기 지시문과 유사하게 동작하는 마침표로 시작하는 키워드인 어셈블러 지시문 (유사 연산이라고도 함)을 사용합니다. 사용 가능한 대부분의 어셈블러 지시문은 대상 아키텍처에 관계없이 유효하지만, 일부 지시문은 기계 의존적입니다.[2]

Comments

GAS는 두 가지 주석 스타일을 지원합니다:[3]

Multi-line comments

C에서처럼 여러-줄 주석은 거울같이 비추는 슬래시-별표 쌍으로 시작하고 끝납니다:

/* 
comment
*/

Single-Line comments

한 줄 주석은 어떤 아키텍처가 어셈블되는지에 따라 몇 가지 다른 형식을 가집니다.

Usage

인기 있는 컴파일러 제품군, 즉 GCC에 대해 백엔드인, GNU 어셈블러는 현대 오픈 소스 소프트웨어를 컴파일하는 데 매우 널리 사용됩니다. GAS는 자주 다른 GNU 소프트웨어와 연결에서 GNU/Linux 운영 시스템에서 어셈블러로 사용됩니다. GAS의 수정된 버전은 OS X 이후 Macintosh 운영 시스템의 개발 도구 패키지에서도 찾을 수 있습니다.

Example program

기본 AT&T 구문을 사용하는 IA-32에서 리눅스에 대해 표준 "Hello, world!" 프로그램:

.global	_start

.text
_start:
	movl  $4, %eax   # 4 (code for "write" syscall) -> EAX register
	movl  $1, %ebx   # 1 (file descriptor for stdout) -> EBX (1st argument to syscall)
	movl  $msg, %ecx # address of msg string -> ECX (2nd argument)
	movl  $len, %edx # len (32 bit address) -> EDX (3rd arg)
	int   $0x80      # interrupt with location 0x80 (128), which invokes the kernel's system call procedure

	movl  $1, %eax   # 1 ("exit") -> EAX
	movl  $0, %ebx   # 0 (with success) -> EBX
	int   $0x80      # see previous
.data
msg:
	.ascii  "Hello, world!\n" # inline ascii string
	len =   . - msg           # assign value of (current address - address of msg start) to symbol "len"

Intel syntax

버전 2.10부터, 인텔 구문이 .intel_syntax 지시문의 사용을 통해 사용될 수 있습니다.[4][5][6]

See also

References

  1. ^ a b "The GNU Assembler". CiteSeerX 10.1.1.32.4503. {{cite journal}}: Cite journal requires |journal= (help)
  2. ^ "The GNU Assembler - Assembler Directives".
  3. ^ Red Hat Inc. "Using as". Retrieved Jan 10, 2013.
  4. ^ "GNU Assembler News".
  5. ^ "AT&T Syntax versus Intel Syntax". Retrieved 28 July 2014.
  6. ^ Ram Narayan (2007-10-17). "Linux assemblers: A comparison of GAS and NASM". IBM DeveloperWorks. Archived from the original on 3 March 2009. Retrieved 28 July 2014.

External links