본문 바로가기
나머지/IT개발.잡다한것.

db, dw, equ에 대해 자세히나와있는 사이트 [어셈블리어 강좌?], "dscr.a51"

by 무늬만학생 2012. 9. 27.
반응형

주소 : http://www.c-jump.com/CIS77/ASM/DataTypes/lecture.html


Data Organization: DB, DW, and EQU


밑의 그림을 참고하면서 보면 쉽게 이해된다. 


Representing data types in assembly source files requires appropriate assembler directives.


The directives allocate data and format x86 little-endian values.


Bytes are allocated by define bytes DB.


Words are allocated by define words DW.


Both allow more than one byte or word to be allocated.


Question marks specify uninitialized data.


Strings allocate multiple bytes.


Labels in front of the directives remember offsets from the beginning of the segment which accommodates the directive.


DUP allows to allocate multiple bytes. The following two lines produce identical results:


    DB ?, ?, ?, ?, ?

    DB 5 DUP(?)

Note that EQU directive does not allocate any memory: it creates a constant value to be used by Assembler:


    CR EQU 13

    DB CR

    .

    mov al, CR





 

  내가 "dscr.a51" 물어본거에 대한 답변 


db는 byte단위이고

 dw는 word단위 즉, 4byte입니다.


 즉, define byte 의 약자가 db, define word의 약자가 dw입니다.

 결국 c에서 어레이 선언하는거와 동일한 선언입니다.


 여기 어셈에서는 ORG를 선언안했거든요

 그대신 public이라는 걸로 앞부분에서 선언했습니다.

 즉, 그로벌영역으로 가는거죠

 어셈에서 특정 주소에 테이블을 넣고 싶으면

 org directive를 사용하면 됩니다.

 가령 주소 0x0300 번지에 어떤 테이블을 선언하고 싶으면

     ORG  300H

 DATA_A:   DB 50

 이렇게 선언하면

 DATA_A는 0x300번지에 링커에서 지정되버리는거죠

 만약 특정 문자열을 하고 싶을때도 그렇게 하면 됩니다.

   ORG  500H

DATA_B:  DB  "XXX Systems Co."

 이렇게 선언할수 있는거죠





반응형

'나머지 > IT개발.잡다한것.' 카테고리의 다른 글

MFC 예제 sample @ MSDN  (0) 2012.10.11
인터레이스, 프로그래시브  (0) 2012.10.09
usb boot, 0xc0, RSEG, SEGMENT  (0) 2012.09.27
db Cx51 Compiler User's Guide Keil Software  (0) 2012.09.27
DWORD and WORD  (0) 2012.09.27