# Numeric Data in Assembly Language

Numeric data in assembly language is manipulated through a combination of instructions that perform arithmetic operations, load and store values, and manage data in registers and memory.

## Numeric Data Types

Numeric data in assembly language is represented in binary form. The most common representations are signed integers, unsigned integers, and floating-point numbers.

**Signed integers**are represented using a two's complement representation. This means that the sign bit of the integer is located in the most significant bit position. For example, the signed integer -128 is represented in two's complement as 10000000.**Unsigned integers**are represented using a straight binary representation. This means that all of the bits of the integer are used to represent the magnitude of the value. For example, the unsigned integer 128 is represented in binary as 01000000.**Floating-point numbers**are represented using an IEEE 754 double-precision format. This format uses 64 bits to represent a floating-point number. The first bit is the sign bit, the next 11 bits are the exponent, and the remaining 52 bits are the significand.

**Examples:**

The .word directive tells the assembler that the variable is a 32-bit integer, and the .double directive tells the assembler that the variable is a 64-bit floating-point number.

## Integers

Integers are whole numbers without fractional components. They can be represented in various sizes such as 8-bit, 16-bit, 32-bit, or 64-bit depending on the architecture.

## Floating-point Numbers

These represent real numbers with a fractional component. They are typically manipulated using specific floating-point instructions.

## Binary Representation

Numeric data, whether integers or floating-point numbers, is ultimately represented in binary form. Binary operations such as addition, subtraction, multiplication, and division are performed directly on this binary representation.

## Registers

Registers play a crucial role in numeric data manipulation. For example, the AX register is often used for 16-bit integer operations, and the FPU registers (ST0, ST1, etc.) are used for floating-point operations.

## Arithmetic Operations

Assembly language provides instructions for various arithmetic operations like addition, subtraction, multiplication, and division.

## Logical Operations

Assembly language programmers can also use numeric data in logical operations. For example, the following assembly instruction compares two signed integers and sets the flags register based on the result of the comparison:

The cmp instruction compares the values of the registers eax and ebx. The flags register is a special register that contains information about the result of the last arithmetic or logical operation.

## Memory Operations

Numeric data can be stored in and retrieved from memory using load (e.g., MOV) and store (e.g., MOV or PUSH/POP) instructions.

### Conclusion

Numeric data in assembly language is manipulated through registers and memory **using binary representation.** Assembly instructions facilitate operations such as addition, subtraction, and multiplication, catering to various data types, including integers and floating-point numbers.

**Related Topics**