Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create Constant Types.md

Abdul Wahab Junaid164293a23721
diff --git a/Assembly language/New Assembly Work/Assembly Language/Constant Types.md b/Assembly language/New Assembly Work/Assembly Language/Constant Types.md
new file mode 100644
index 0000000..2b89142
--- /dev/null
+++ b/Assembly language/New Assembly Work/Assembly Language/Constant Types.md
@@ -0,0 +1,100 @@
+In assembly language, **constants** are fixed values that do not change during the execution of a program. They are often used to represent values that are known at compile-time, such as numbers, characters, or addresses. Understanding the different types of constants is essential for effective programming in assembly. Here are the main types of constants commonly used in assembly language:
+
+### 1. **Numeric Constants**
+
+These represent fixed numeric values and can be expressed in various number systems.
+
+#### **A. Decimal Constants**
+
+- **Definition**: Represented in base 10.
+- **Example**: `42`, `-23`
+
+#### **B. Binary Constants**
+
+- **Definition**: Represented in base 2, typically prefixed with `0b` or `b`.
+- **Example**: `0b101010`, `0b1111` (equivalent to 42 and 15 in decimal)
+
+#### **C. Octal Constants**
+
+- **Definition**: Represented in base 8, usually prefixed with `0` or `0o`.
+- **Example**: `052` (which is 42 in decimal)
+
+#### **D. Hexadecimal Constants**
+
+- **Definition**: Represented in base 16, often prefixed with `0x` or `h`.
+- **Example**: `0x2A` or `2Ah` (both are equivalent to 42 in decimal)
+
+### 2. **Character Constants**
+
+These represent individual characters and are often enclosed in single quotes or double quotes, depending on the assembler syntax.
+
+- **Example**: `'A'`, `'b'`, `'\n'` (newline character)
+
+### 3. **String Constants**
+
+String constants represent a sequence of characters and are usually enclosed in double quotes. They can be used for display messages or data.
+
+- **Example**: `"Hello, World!"`, `"Assembly Language"`
+
+### 4. **Boolean Constants**
+
+Boolean constants represent truth values and are often denoted as `true` and `false`, `1` and `0`, or `True` and `False`.
+
+- **Example**: `TRUE` (1), `FALSE` (0)
+
+### 5. **Special Constants**
+
+Some assembly languages define special constants for specific purposes, such as:
+
+- **Null Constant**: Represents a zero or empty value, often used in pointer contexts.
+ - **Example**: `NULL` (0)
+
+- **Predefined Constants**: Some assemblers provide predefined constants, like the size of types (e.g., `SIZEOF_INT`, `MAX_BUFFER_SIZE`).
+
+### 6. **Defining Constants in Assembly Language**
+
+Constants can be defined using directives, which may vary depending on the assembler used. Here are common ways to define constants in assembly:
+
+#### **A. EQU Directive**
+
+The `EQU` directive defines a constant symbolically.
+
+```assembly
+MAX_VALUE EQU 100 ; Define MAX_VALUE as 100
+```
+
+#### **B. CONSTANT Directive (or similar)**
+
+Some assemblers provide a specific directive to define constants.
+
+```assembly
+const_value CONSTANT 42 ; Define const_value as 42
+```
+
+### 7. **Examples of Using Constants**
+
+Here’s a simple example in x86 assembly demonstrating the use of constants:
+
+```assembly
+section .data
+ message db 'Hello, World!', 0 ; String constant
+ number db 10 ; Decimal constant
+
+section .text
+global _start
+
+_start:
+ ; Example of using constants
+ mov eax, number ; Move the constant 10 into EAX
+ add eax, 5 ; Add 5 to EAX
+ ; Now EAX = 15
+
+ ; Exit program
+ mov eax, 1 ; Syscall number for exit
+ xor ebx, ebx ; Return code 0
+ int 0x80 ; Call kernel
+```
+
+### 8. **Conclusion**
+
+Constants are fundamental in assembly language programming, allowing for better code readability, maintainability, and efficiency. By using various types of constants—numeric, character, string, boolean, and special constants—programmers can represent data meaningfully and effectively manage their programs. Understanding how to define and utilize constants is key to writing clear and effective assembly code.