Basic Elements of Assembly Language: - Integer Constants
Basic Elements of Assembly Language: - Integer Constants
• Integer Constants
1/2002 JNM 1
Basic Elements of Assembly Language
• Character and String Constants
1/2002 JNM 2
Basic Elements of Assembly Language
• Reserved Words
– Instruction Mnemonics
– Directives
– Attributes (BYTE or WORD)
– Operators
– Predefined Symbols
1/2002 JNM 4
Examples
• Mystring db “this is a string”,0
– Mystring is the name
• Length = $ - mystring
– Length is a reserved word (can not use)
• Loop1:
– Loop1 is the label for a loop instruction
1/2002 JNM 5
Assembly Language
Statements
1/2002 JNM 8
Standard Assembler Directives
Directive Description
title Title of the listing file
.model Specify the program's memory model
.stack Set the size of the stack segment
.data Mark the beginning of the data segment
.code Mark the beginning of the code segment
proc Begin procedure
endp End of procedure
end End of program assembly
1/2002 JNM 9
Data Allocation Directives
Directive Description Bytes
DB Define byte 1
DW Define word 2
DD Define Doubleword 4
DF,DP Define far pointer 6
DQ Define quadword 8
DT Define tenbytes 10
1/2002 JNM 11
Instructions
• A statement that is executed by the
processor at runtime
• Fall into five general categories
– Data transfer (mov ax, 5)
– Arithmetic (add ax, 20)
– Transfer of control (call MySub)
– Logical (Jz next1)
– Input/output (In al, 20)
1/2002 JNM 12
General Format of an Instruction
Label: Mnemonic Operand(s) ;Comment
• Label (optional)
• Instruction mnemonic (required)
• Operand(s) (usually required)
• Comment (optional)
1/2002 JNM 14
Instruction Mnemonics
• A short word that identifies the operation
carried out by an instruction
Mov assign one value to another
Add add two values
Sub subtract one value from another
Call call a procedure
1/2002 JNM 15
Formatting of Instructions and
Number of Operands Needed
Mnemonic destination operand, source operand
HLT ; zero operands
INC AX ; one operand
MOV AX, 100 ; two operands
SHLD DX, AX, 4 ; three operands
1/2002 JNM 18