x86 Assembly Language Syntax
.model small .stack 100h .data .code main proc end main
The usage of each segment is described below:
.Model define the size of data and code a program can have. In the above example, we have use .model small which means we will be having one segment of code and one segment of data. some other model directives are:
- Medium # more than one code and one data segment
- Compact # one code and more than one data segment
- Large # more than one code and data segment (Array not greater than 64k bytes)
- Huge # more than one code and data segment (Array can be greater than 64k bytes)
In Stack segment, we set aside a block of memory to store stack. Its size is considered in kb. In the above example, we have given the size of 100h which means 1kb.
In Data segment, all the variables are declared or initialized. For example:
.DATA WORDl DW2 WORD2 DW7 MSG DB 'THIS IS A MESSAGE'
The Code segment, contain program instructions. In the above example, we have a main procedure in the .code section.
Proc stands for “procedure” so main proc means main procedure. Here we will write our further instruction and the we will end our main proc with following statements:
main endp end main
Hope the above tutorial helped you understand the basic syntax of x86 instruction set. If you have any problem let us know in the comment box.