In this tutorial we will learn Data types and variables in Assembly language programming. We will learn
- What are code and data segments/directives?
- Data types or Data sizes
- How to create variables in Assembly ?
Segments or Directives:
.data and .code are directives or segments which tells the assembler how to assemble code. data part holds all the variables and memory related things where as .code holds all the instructions and code which tells registers and processor what to do.
Data types or Data sizes:
In Assembly language, there are no distinct data types like char,string,int,float,double,etc Instead there are very basic data types according to their sizes. They are:
- byte – 8 bits
- word – 16 bits
- dword – 32 bits
- qword – 64 bits
- Real4 – 32 bit float
- Real8 – 64 bit float
- Real10 – 80 bit float
Variables in Assembly language:
To create variables in Assembly language, use one of the above data sizes and allocate memory for a variable. The general syntax is like this:
<identifier/variable name> <size to allocate> <value>
For creating a variable of 32 bits:
var1 DWORD ?
Note: ? is use for creating a variable with uninitialized value i.e garbage or null value
Watch this to learn more: