Microsoft 매크로 어셈블러 BNF 문법
이 페이지에는 MASM 문법에 대한 BNF 설명이 포함되어 있습니다. 그것은 참조에 대한 보충으로 제공되며 완료될 것이라고 보장되지 않습니다. 키워드, 매개 변수, 작업 등에 대한 전체 정보는 참조를 참조하세요.
BNF의 사용을 설명하기 위해 다음 다이어그램은 비터미널로 시작하는 지시문의 TYPEDEF
정의를 보여 줍니다 typedefDir
.
각 가로 중괄호 아래의 항목은 터미널(예: NEAR16
, NEAR32
FAR16
및 FAR32
)입니다. 또는 , qualifiedType
distance
, 등의 qualifier
비터미널이며 protoSpec
추가로 정의할 수 있습니다. 정의의 typedefDir
기울임꼴이 아닌 각 기울임꼴은 BNF의 항목이기도 합니다. 세로 점 3개는 단순성을 위해 이 그림이 보여 주지 않는 비터미널에 대한 분기 정의를 나타냅니다.
BNF 문법은 재귀 정의를 허용합니다. 예를 들어 문법은 정의의 구성 요소이기도 한 가능한 정의qualifiedType
qualifier
로 사용합니다qualifiedType
. "|" 기호는 대체 식 중에서 선택 항목을 지정합니다. 예를 들면 다음과 같습니다 endOfLine
| comment
. 이중 중괄호는 선택적 매개 변수(예: ⟦ macroParmList
⟧)를 지정합니다. 대괄호는 실제로 소스 코드에 표시되지 않습니다.
MASM 비터미널
;;
endOfLine
| comment
=Dir
id
=
immExpr
;;
addOp
+
| -
aExpr
term
| aExpr
&&
term
altId
id
alpha
모든 대문자 또는 소문자(A-Z) 또는 다음 네 문자 중 하나: @ _ $ ?
arbitraryText
charList
asmInstruction
mnemonic
exprList
⟦ ⟧
assumeDir
ASSUME
assumeList
;;
| ASSUME NOTHING
;;
assumeList
assumeRegister
| assumeList
,
assumeRegister
assumeReg
register
:
assumeVal
assumeRegister
assumeSegReg
| assumeReg
assumeSegReg
segmentRegister
:
assumeSegVal
assumeSegVal
frameExpr
| NOTHING
| ERROR
assumeVal
qualifiedType
| NOTHING
| ERROR
bcdConst
sign
⟦ ⟧decNumber
binaryOp
==
| !=
| >=
| <=
| >
| <
| &
bitDef
bitFieldId
:
bitFieldSize
=
constExpr
⟦ ⟧
bitDefList
bitDef
| bitDefList
,
;;
⟦ ⟧bitDef
bitFieldId
id
bitFieldSize
constExpr
blockStatements
directiveList
| .CONTINUE
.IF
cExpr
⟦ ⟧
| .BREAK
.IF
cExpr
⟦ ⟧
bool
TRUE
| FALSE
byteRegister
AL
| AH
| CL
| CH
| DL
| DH
| BL
| BH
| R8B
| R9B
| R10B
| R11B
| R12B
| R13B
| R14B
| R15B
cExpr
aExpr
| cExpr
||
aExpr
character
줄 바꿈(10)을 제외한 0~255 범위의 서수가 있는 문자입니다.
charList
character
| charList
character
className
string
commDecl
nearfar
⟦ ⟧ ⟦ langType
⟧ id
:
commType
:
constExpr
⟦ ⟧
commDir
COMM
commList
;;
comment
;
text
;;
commentDir
COMMENT
delimiter
text
text
delimiter
text
;;
commList
commDecl
| commList
,
commDecl
commType
type
| constExpr
constant
digits
radixOverride
⟦ ⟧
constExpr
expr
contextDir
PUSHCONTEXT
contextItemList
;;
| POPCONTEXT
contextItemList
;;
contextItem
ASSUMES
| RADIX
| LISTING
| CPU
| ALL
contextItemList
contextItem
| contextItemList
,
contextItem
controlBlock
whileBlock
| repeatBlock
controlDir
controlIf
| controlBlock
controlElseif
.ELSEIF
cExpr
;;
directiveList
controlElseif
⟦ ⟧
controlIf
.IF
cExpr
;;
directiveList
controlElseif
⟦ ⟧
.ELSE
⟦ ;;
directiveList
⟧
.ENDIF
;;
coprocessor
.8087
| .287
| .387
| .NO87
crefDir
crefOption
;;
crefOption
.CREF
| .XCREF
idList
⟦ ⟧
| .NOCREF
idList
⟦ ⟧
cxzExpr
expr
| !
expr
| expr
==
expr
| expr
!=
expr
dataDecl
DB
| DW
| DD
| DF
| DQ
| DT
| dataType
| typeId
dataDir
id
⟦ ⟧ dataItem
;;
dataItem
dataDecl
scalarInstList
| structTag
structInstList
| typeId
structInstList
| unionTag
structInstList
| recordTag
recordInstList
dataType
BYTE
| SBYTE
| WORD
| SWORD
| DWORD
| SDWORD
| FWORD
| QWORD
| SQWORD
| TBYTE
| OWORD
| REAL4
| REAL8
| REAL10
| MMWORD
| XMMWORD
| YMMWORD
decdigit
0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
decNumber
decdigit
| decNumber
decdigit
delimiter
제외한 모든 문자 whiteSpaceCharacter
digits
decdigit
| digits
decdigit
| digits
hexdigit
directive
generalDir
| segmentDef
directiveList
directive
| directiveList
directive
distance
nearfar
| NEAR16
| NEAR32
| FAR16
| FAR32
e01
e01
orOp
e02
| e02
e02
e02
AND
e03
| e03
e03
NOT
e04
| e04
e04
e04
relOp
e05
| e05
e05
e05
addOp
e06
| e06
e06
e06
mulOp
e07
| e06
shiftOp
e07
| e07
e07
e07
addOp
e08
| e08
e08
HIGH
e09
| LOW
e09
| HIGHWORD
e09
| LOWWORD
e09
| e09
e09
OFFSET
e10
| SEG
e10
| LROFFSET
e10
| TYPE
e10
| THIS
e10
| e09
PTR
e10
| e09
:
e10
| e10
e10
e10
.
e11
| e10
expr
⟦ ⟧
| e11
e11
(
expr
)
| expr
⟦ ⟧
| WIDTH
id
| MASK
id
| SIZE
sizeArg
| SIZEOF
sizeArg
| LENGTH
id
| LENGTHOF
id
| recordConst
| string
| constant
| type
| id
| $
| segmentRegister
| register
| ST
| ST
(
expr
)
echoDir
ECHO
arbitraryText
;;
%OUT
arbitraryText
;;
elseifBlock
elseifStatement
;;
directiveList
elseifBlock
⟦ ⟧
elseifStatement
ELSEIF
constExpr
| ELSEIFE
constExpr
| ELSEIFB
textItem
| ELSEIFNB
textItem
| ELSEIFDEF
id
| ELSEIFNDEF
id
| ELSEIFDIF
textItem
,
textItem
| ELSEIFDIFI
textItem
,
textItem
| ELSEIFIDN
textItem
,
textItem
| ELSEIFIDNI
textItem
,
textItem
| ELSEIF1
| ELSEIF2
endDir
END
immExpr
⟦ ⟧;;
endpDir
procId
ENDP
;;
endsDir
id
ENDS
;;
equDir
textMacroId
EQU
equType
;;
equType
immExpr
| textLiteral
errorDir
errorOpt
;;
errorOpt
.ERR
textItem
⟦ ⟧
| .ERRE
constExpr
optText
⟦ ⟧
| .ERRNZ
constExpr
optText
⟦ ⟧
| .ERRB
textItem
optText
⟦ ⟧
| .ERRNB
textItem
optText
⟦ ⟧
| .ERRDEF
id
optText
⟦ ⟧
| .ERRNDEF
id
optText
⟦ ⟧
| .ERRDIF
textItem
,
textItem
optText
⟦ ⟧
| .ERRDIFI
textItem
,
textItem
optText
⟦ ⟧
| .ERRIDN
textItem
,
textItem
optText
⟦ ⟧
| .ERRIDNI
textItem
,
textItem
optText
⟦ ⟧
| .ERR1
textItem
⟦ ⟧
| .ERR2
textItem
⟦ ⟧
exitDir
.EXIT
expr
⟦ ⟧;;
exitmDir
:
EXITM
| EXITM
textItem
exponent
E
sign
⟦ ⟧decNumber
expr
SHORT
e05
| .TYPE
e01
| OPATTR
e01
| e01
exprList
expr
| exprList
,
expr
externDef
langType
⟦ ⟧ id
⟦ (
altId
)
⟧ :
externType
externDir
externKey
externList
;;
externKey
EXTRN
| EXTERN
| EXTERNDEF
externList
externDef
| externList
,
;;
⟦ ⟧externDef
externType
ABS
| qualifiedType
fieldAlign
constExpr
fieldInit
initValue
⟦ ⟧ |structInstance
fieldInitList
fieldInit
| fieldInitList
,
;;
⟦ ⟧fieldInit
fileChar
delimiter
fileCharList
fileChar
| fileCharList
fileChar
fileSpec
fileCharList
| textLiteral
flagName
ZERO?
| CARRY?
| OVERFLOW?
| SIGN?
| PARITY?
floatNumber
sign
⟦ ⟧ decNumber
.
⟦ decNumber
⟧ ⟦ exponent
⟧
| digits
R
| digits
r
forcDir
FORC
| IRPC
forDir
FOR
| IRP
forParm
id
:
forParmType
⟦ ⟧
forParmType
REQ
| =
textLiteral
fpuRegister
ST
expr
frameExpr
SEG
id
| DGROUP
:
id
| segmentRegister
:
id
| id
generalDir
modelDir
| segOrderDir
| nameDir
| includeLibDir
| commentDir
| groupDir
| assumeDir
| structDir
| recordDir
| typedefDir
| externDir
| publicDir
| commDir
| protoTypeDir
| equDir
| =Dir
| textDir
| contextDir
| optionDir
| processorDir
| radixDir
| titleDir
| pageDir
| listDir
| crefDir
| echoDir
| ifDir
| errorDir
| includeDir
| macroDir
| macroCall
| macroRepeat
| purgeDir
| macroWhile
| macroFor
| macroForc
| aliasDir
gpRegister
AX
| EAX
| CX
| ECX
| DX
| EDX
| BX
| EBX
| DI
| EDI
| SI
| ESI
| BP
| EBP
| SP
| ESP
| R8W
| R8D
| R9W
| R9D
| R12D
| R13W
| R13D
| R14W
| R14D
groupDir
groupId
GROUP
segIdList
groupId
id
hexdigit
a
| b
| c
| d
| e
| f
| A
| B
| C
| D
| E
| F
id
alpha
| id
alpha
| id
decdigit
최대 길이는 247자입니다.
idList
id
| idList
,
id
ifDir
ifStatement
;;
directiveList
elseifBlock
⟦ ⟧
ELSE
⟦ ;;
directiveList
⟧ ;;
ifStatement
IF
constExpr
| IFE
constExpr
| IFB
textItem
| IFNB
textItem
| IFDEF
id
| IFNDEF
id
| IFDIF
textItem
,
textItem
| IFDIFI
textItem
,
textItem
| IFIDN
textItem
,
textItem
| IFIDNI
textItem
,
textItem
| IF1
| IF2
immExpr
expr
includeDir
INCLUDE
fileSpec
;;
includeLibDir
INCLUDELIB
fileSpec
;;
initValue
immExpr
| string
| ?
| constExpr
DUP
(
scalarInstList
)
| floatNumber
| bcdConst
inSegDir
labelDef
⟦ ⟧inSegmentDir
inSegDirList
inSegDir
| inSegDirList
inSegDir
inSegmentDir
instruction
| dataDir
| controlDir
| startupDir
| exitDir
| offsetDir
| labelDir
| procDir
localDirList
⟦ ⟧ ⟦ inSegDirList
⟧endpDir
| invokeDir
| generalDir
instrPrefix
REP
| REPE
| REPZ
| REPNE
| REPNZ
| LOCK
instruction
instrPrefix
⟦ ⟧asmInstruction
invokeArg
register
::
register
| expr
| ADDR
expr
invokeDir
INVOKE
expr
,
⟦ ⟦ ;;
⟧ invokeList
⟧;;
invokeList
invokeArg
| invokeList
,
;;
⟦ ⟧invokeArg
keyword
예약어입니다.
keywordList
keyword
| keyword
keywordList
labelDef
id
:
| id
::
| @@:
labelDir
id
LABEL
qualifiedType
;;
langType
C
| PASCAL
| FORTRAN
| BASIC
| SYSCALL
| STDCALL
listDir
listOption
;;
listOption
.LIST
| .NOLIST
| .XLIST
| .LISTALL
| .LISTIF
| .LFCOND
| .NOLISTIF
| .SFCOND
| .TFCOND
| .LISTMACROALL
| .LALL
| .NOLISTMACRO
| .SALL
| .LISTMACRO
| .XALL
localDef
LOCAL
idList
;;
localDir
LOCAL
parmList
;;
localDirList
localDir
| localDirList
localDir
localList
localDef
| localList
localDef
macroArg
%
constExpr
| %
textMacroId
| %
macroFuncId
(
macroArgList
)
| string
| arbitraryText
| <
arbitraryText
>
macroArgList
macroArg
| macroArgList
,
macroArg
macroBody
localList
⟦ ⟧macroStmtList
macroCall
id
macroArgList
;;
| id
(
macroArgList
)
macroDir
id
MACRO
macroParmList
⟦ ⟧;;
macroBody
ENDM
;;
macroFor
forDir
forParm
,
<
macroArgList
>
;;
macroBody
ENDM
;;
macroForc
forcDir
id
,
textLiteral
;;
macroBody
ENDM
;;
macroFuncId
id
macroId
macroProcId
| macroFuncId
macroIdList
macroId
| macroIdList
,
macroId
macroLabel
id
macroParm
id
:
parmType
⟦ ⟧
macroParmList
macroParm
| macroParmList
,
;;
⟦ ⟧macroParm
macroProcId
id
macroRepeat
repeatDir
constExpr
;;
macroBody
ENDM
;;
macroStmt
directive
| exitmDir
| :
macroLabel
| GOTO
macroLabel
macroStmtList
macroStmt
;;
| macroStmtList
macroStmt
;;
macroWhile
WHILE
constExpr
;;
macroBody
ENDM
;;
mapType
ALL
| NONE
| NOTPUBLIC
memOption
TINY
| SMALL
| MEDIUM
| COMPACT
| LARGE
| HUGE
| FLAT
mnemonic
명령 이름입니다.
modelDir
.MODEL
memOption
,
modelOptlist
⟦ ⟧;;
modelOpt
langType
| stackOption
modelOptlist
modelOpt
| modelOptlist
,
modelOpt
module
directiveList
⟦ ⟧endDir
mulOp
*
| /
| MOD
nameDir
NAME
id
;;
nearfar
NEAR
| FAR
nestedStruct
structHdr
id
⟦ ⟧;;
structBody
ENDS
;;
offsetDir
offsetDirType
;;
offsetDirType
EVEN
| ORG
immExpr
| ALIGN
constExpr
⟦ ⟧
offsetType
GROUP
| SEGMENT
| FLAT
oldRecordFieldList
constExpr
⟦ ⟧ | oldRecordFieldList
,
⟦ constExpr
⟧
optionDir
OPTION
optionList
;;
optionItem
CASEMAP
:
mapType
| DOTNAME
| NODOTNAME
| EMULATOR
| NOEMULATOR
| EPILOGUE
:
macroId
| EXPR16
| EXPR32
| LANGUAGE
:
langType
| LJMP
| NOLJMP
| M510
| NOM510
| NOKEYWORD
:
<
keywordList
>
| NOSIGNEXTEND
| OFFSET
:
offsetType
| OLDMACROS
| NOOLDMACROS
| OLDSTRUCTS
| NOOLDSTRUCTS
| PROC
:
oVisibility
| PROLOGUE
:
macroId
| READONLY
| NOREADONLY
| SCOPED
| NOSCOPED
| SEGMENT
:
segSize
| SETIF2
:
bool
optionList
optionItem
| optionList
,
;;
⟦ ⟧optionItem
optText
,
textItem
orOp
OR
| XOR
oVisibility
PUBLIC
| PRIVATE
| EXPORT
pageDir
PAGE
pageExpr
⟦ ⟧;;
pageExpr
+
| pageLength
⟦ ⟧ ⟦ ,
pageWidth
⟧
pageLength
constExpr
pageWidth
constExpr
parm
parmId
:
qualifiedType
⟦ ⟧
| parmId
constExpr
⟦ ⟧ ⟦ :
qualifiedType
⟧
parmId
id
parmList
parm
| parmList
,
;;
⟦ ⟧parm
parmType
REQ
| =
textLiteral
| VARARG
pOptions
distance
⟦ ⟧ ⟦ langType
⟧ ⟦ oVisibility
⟧
primary
expr
binaryOp
expr
| flagName
| expr
procDir
procId
PROC
pOptions
⟦ ⟧ ⟦ <
macroArgList
>
⟧
usesRegs
⟦ ⟧ ⟦ procParmList
⟧
processor
| .386
| .386p
| .486
| .486P
| .586
| .586P
| .686
| .686P
| .387
processorDir
processor
;;
| coprocessor
;;
procId
id
procItem
instrPrefix
| dataDir
| labelDir
| offsetDir
| generalDir
procParmList
,
⟦ ⟦ ;;
⟧ parmList
⟧
,
⟦ ⟦ ;;
⟧ parmId
:VARARG
⟧
protoArg
id
⟦ ⟧ :
qualifiedType
protoArgList
,
⟦ ⟦ ;;
⟧ protoList
⟧
,
⟦ ⟦ ;;
⟧ ⟦ id
⟧ :VARARG
⟧
protoList
protoArg
| protoList
,
;;
⟦ ⟧protoArg
protoSpec
distance
⟦ ⟧ ⟦ langType
⟧ ⟦ protoArgList
⟧
| typeId
protoTypeDir
id
PROTO
protoSpec
pubDef
langType
⟦ ⟧id
publicDir
PUBLIC
pubList
;;
pubList
pubDef
| pubList
,
;;
⟦ ⟧pubDef
purgeDir
PURGE
macroIdList
qualifiedType
type
| distance
⟦ ⟧ PTR
⟦ qualifiedType
⟧
qualifier
qualifiedType
| PROTO
protoSpec
quote
"
| '
qwordRegister
RAX
| RCX
| RDX
| RBX
| RSP
| RBP
| RSI
| RDI
| R8
| R9
| R10
| R11
| R12
| R13
| R14
| R15
radixDir
.RADIX
constExpr
;;
radixOverride
h
| o
| q
| t
| y
| H
| O
| Q
| T
| Y
recordConst
recordTag
{
oldRecordFieldList
}
| recordTag
<
oldRecordFieldList
>
recordDir
recordTag
RECORD
bitDefList
;;
recordFieldList
constExpr
⟦ ⟧ | recordFieldList
,
⟦ ;;
⟧ ⟦ constExpr
⟧
recordInstance
{
;;
⟦ ⟧ recordFieldList
⟦ ;;
⟧}
| <
oldRecordFieldList
>
| constExpr
DUP
(
recordInstance
)
recordInstList
recordInstance
| recordInstList
,
;;
⟦ ⟧recordInstance
recordTag
id
register
specialRegister
| gpRegister
| byteRegister
| qwordRegister
| fpuRegister
| SIMDRegister
| segmentRegister
regList
register
| regList
register
relOp
EQ
| NE
| LT
| LE
| GT
| GE
repeatBlock
.REPEAT
;;
blockStatements
;;
untilDir
;;
repeatDir
REPEAT
| REPT
scalarInstList
initValue
| scalarInstList
,
;;
⟦ ⟧initValue
segAlign
BYTE
| WORD
| DWORD
| PARA
| PAGE
segAttrib
PUBLIC
| STACK
| COMMON
| MEMORY
| AT
constExpr
| PRIVATE
segDir
.CODE
segId
⟦ ⟧
| .DATA
| .DATA?
| .CONST
| .FARDATA
segId
⟦ ⟧
| .FARDATA?
segId
⟦ ⟧
| .STACK
constExpr
⟦ ⟧
segId
id
segIdList
segId
| segIdList
,
segId
segmentDef
segmentDir
inSegDirList
⟦ ⟧ endsDir
simpleSegDir
| ⟦ inSegDirList
⟧ ⟦ ⟧ endsDir
segmentDir
segId
SEGMENT
segOptionList
⟦ ⟧;;
segmentRegister
CS
| DS
| ES
| FS
| GS
| SS
segOption
segAlign
| segRO
| segAttrib
| segSize
| className
segOptionList
segOption
| segOptionList
segOption
segOrderDir
.ALPHA
| .SEQ
| .DOSSEG
| DOSSEG
segRO
READONLY
segSize
USE16
| USE32
| FLAT
shiftOp
SHR
| SHL
sign
+
| -
simdRegister
MM0
| MM1
| MM2
| MM3
| MM4
| MM5
| MM6
| MM7
| xmmRegister
| YMM0
| YMM1
| YMM2
| YMM3
| YMM4
| YMM5
| YMM6
| YMM7
| YMM8
| YMM9
| YMM10
| YMM11
| YMM12
| YMM13
| YMM14
| YMM15
simpleExpr
(
cExpr
)
| primary
simpleSegDir
segDir
;;
sizeArg
id
| type
| e10
specialChars
:
| .
| [
| ]
| (
| )
| <
| >
| {
| }
| +
| -
| /
| *
| &
| %
| !
| '
| \
| =
| ;
| ,
| "
| whiteSpaceCharacter
| endOfLine
specialRegister
CR0
| CR2
| CR3
| DR0
| DR1
| DR2
| DR3
| DR6
| DR7
| TR3
| TR4
| TR5
| TR6
| TR7
stackOption
NEARSTACK
| FARSTACK
startupDir
.STARTUP
;;
stext
stringChar
| stext
stringChar
string
quote
stext
⟦ ⟧quote
stringChar
quote
quote
| 따옴표를 제외한 모든 문자입니다.
structBody
structItem
;;
| structBody
structItem
;;
structDir
structTag
structHdr
fieldAlign
⟦ ⟧
,
NONUNIQUE
⟦ ⟧;;
structBody
structTag
ENDS
;;
structHdr
STRUC
| STRUCT
| UNION
structInstance
<
fieldInitList
⟦ ⟧>
| {
;;
⟦ ⟧ ⟦ fieldInitList
⟧ ⟦ ;;
⟧}
| constExpr
DUP
( structInstList
)
structInstList
structInstance
| structInstList
,
;;
⟦ ⟧structInstance
structItem
dataDir
| generalDir
| offsetDir
| nestedStruct
structTag
id
term
simpleExpr
| !
simpleExpr
text
textLiteral
| text
character
| !
character
text
| character
| !
character
textDir
id
textMacroDir
;;
textItem
textLiteral
| textMacroId
| %
constExpr
textLen
constExpr
textList
textItem
| textList
,
;;
⟦ ⟧textItem
textLiteral
<
text
>
;;
textMacroDir
CATSTR
textList
⟦ ⟧
| TEXTEQU
textList
⟦ ⟧
| SIZESTR
textItem
| SUBSTR
textItem
,
textStart
,
textLen
⟦ ⟧
| INSTR
textStart
,
⟦ ⟧ textItem
,
textItem
textMacroId
id
textStart
constExpr
titleDir
titleType
arbitraryText
;;
titleType
TITLE
| SUBTITLE
| SUBTTL
type
structTag
| unionTag
| recordTag
| distance
| dataType
| typeId
typedefDir
typeId
TYPEDEF
qualifier
typeId
id
unionTag
id
untilDir
.UNTIL
cExpr
;;
.UNTILCXZ
cxzExpr
⟦ ⟧;;
usesRegs
USES
regList
whileBlock
.WHILE
cExpr
;;
blockStatements
;;
.ENDW
whiteSpaceCharacter
ASCII 8, 9, 11-13, 26, 32
xmmRegister
XMM0
| XMM1
| XMM2
| XMM3
| XMM4
| XMM5
| XMM6
| XMM7
| XMM8
| XMM9
| XMM10
| XMM11
| XMM12
| XMM13
| XMM14
| XMM15