# Variables

# Types

The data types in p8086 are actually the same as in 8086. Type Name is what you write while declaring a variable. 8086 directive is what it will get translated to.

# Basic types

Type Name Description 8086 directive
db Byte DB
var, int Word DW
dw Word DW
dd Double word DD

# Special types

These types aren't directly available otherwise.

Type Name Description 8086 directive
String A string for printing DB

# Example

Types
var a;
db b;
dw c;
string s = "Hello world!";

# Initialising and assigning

This is exactly as you would do in any other language.

typeName identifier = constant

Initialising
var a = 1; // immediate
string s = "A string here";

a = 23H; // assign value
b = 45; // allowed, but the assembler won't be happy (b is not defined)
db c = 'c';

# Strings

Right now no string operations are supported. You can only define them or print them.

A string used "on-the-fly" for the print statement gets automatically added the DATA segment.

Two equal string literals will not generate two redundant DATA declarations!

print "abc";
print "abc";
Compiled
.DATA
str1 DB "abc$"
.CODE
PUSH OFFSET str1
POP DX
MOV AH, 09
INT 21H
PUSH OFFSET str1
POP DX
MOV AH, 09
INT 21H