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.

  1. 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.
  2. 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.
  3. 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.
; Signed integer my_integer: .word -128
; Unsigned integer my_uint: .word 128
; Floating-point number my_float: .double 1234.56789

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 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.

; Example: Loading and adding 16-bit integers MOV AX, 5 ; Load the value 5 into the AX register ADD AX, 10 ; Add 10 to the value in AX

Floating-point Numbers

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

; Example: Loading and adding 32-bit floating-point numbers FLD DWORD PTR [Float1] ; Load a 32-bit floating-point number from memory FADD DWORD PTR [Float2] ; Add another 32-bit floating-point number

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.

; Example: Binary addition of 8-bit integers MOV AL, 1101b ; Binary representation of 13 ADD AL, 0010b ; Binary representation of 2


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.

; Example: Using registers for integer addition MOV AX, 1000h ; Load a 16-bit hexadecimal value into AX ADD AX, 2000h ; Add another hexadecimal value to AX

Arithmetic Operations

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

; Example: Multiplying two 32-bit integers MOV EAX, 5 ; Load the first integer into EAX IMUL EAX, 10 ; Multiply EAX by 10

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:

cmp eax, ebx

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.

; Example: Storing and retrieving integers from memory MOV DWORD PTR [MemoryLocation], 42 ; Store a 32-bit integer in memory MOV EBX, DWORD PTR [MemoryLocation] ; Load the value from memory into EBX


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.