본문 바로가기
공부,일/어셈블리

ch3 . element of assembly language

by fromnothing1 2021. 8. 12.

MASM : Microsoft Macro Assembler .

 

 

1. Assembly Language Statements

directive

ssembler directives are directions to the assembler to take some action or change a setting. Assembler directives do not represent instructions, and are not translated into machine code.

 

directive 는 어셈블러 의 셋팅을 조절하는 방식이라 생각하면 된다. ('#', '.'  등으로 시작한다.)

 

ex)

  • .text – The .text directive tells the assembler that the information that follows is program text (assembly instructions), and the translated machine code is to be written to the text segment of memory.
  • .data – The .data directive tells the assembler that information that follows is program data. The information following a .data instruction will be data values, and will be stored in the data segment.
  • .label – A label is an address in memory corresponding to either an instruction or data value. It is just a convenience so the programmer can reference an address by a name. It will be used as follow:
  • # - the # (hashtag) is used to specify a comment. Anything on a line which begins with a “#” is a comment line and ignored by the assembler.
  • 즉 # 는 주석이다.

macro

c 언어에서 함수와 같은 역활을 한다.  매크로는 여러가지 어셈블리 구문을 모아둔것이다. 

함수와 다른점은 함수의 경우 코드가 추가 되는 것이 아니라 코드가 분기 되어서 함수를 위치에 갔다가 다시 돌아 오지만 메크로의 경우 그냥 코드가 추가 되는것으로 너무 남발하면 코드의 길이가 너무 커질것이다. 

 

출처:https://blog.naver.com/PostView.nhn?isHttpsRedirect=true&blogId=credenda&logNo=80040724519

어셈불리 명령어 구조

 

 

위와 같이 name mnemonic operand(s) ; commnet 순으로 나열된다. 

 

이름 활용

label 로 활용가능

add eax ,158 명령어를 반복적으로 사용할때는  addLoop 라는 이름 을 붙임으로 쉽게 구현할 수 있다.

 

cf) 어셈블리 구문은 대소문자 구분하지 않는다. 

 

 

댓글