Wednesday , December 19 2018

Assembly #04 – Data types and Variables

Share on WhatsApp
Share via email Share

In this tutorial we will learn Data types and variables in Assembly language programming. We will learn

  1. What are code and data segments/directives?
  2. Data types or Data sizes
  3. 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:

  1. byte – 8 bits
  2. word – 16 bits
  3. dword – 32 bits
  4. qword – 64 bits
  5. Real4 – 32 bit float
  6. Real8 – 64 bit float
  7. 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:

Share on WhatsApp
Share via email Share

About Waleed Baig

Waleed Baig
I am doing BS Computer Science. I have a passion to learn new technology and spread it. I am more enthusiastic about learning complex algorithm and making creative and efficient solution to a problem.

Check Also

general purpose register

Assembly #2 – What are Registers?

In this tutorial we will learn What are registers? Size of registers and their subdivisions Related

Leave a Reply

Your email address will not be published.