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 How are memory addresses represented in Assembly language.md

Abdul Wahab Junaid53ed5cb002b7
diff --git a/Assembly language/Basics of Assembly language/How are memory addresses represented in Assembly language.md b/Assembly language/Basics of Assembly language/How are memory addresses represented in Assembly language.md
new file mode 100644
index 0000000..75769a9
--- /dev/null
+++ b/Assembly language/Basics of Assembly language/How are memory addresses represented in Assembly language.md
@@ -0,0 +1,66 @@
+In assembly language, memory addresses are represented using various conventions and notations to specify locations in the computer's memory. Here are the key aspects of how memory addresses are represented in assembly language:
+
+## 1. **Numeric Representation:**
+- **Hexadecimal Notation:** Memory addresses are commonly expressed in hexadecimal notation. This is because hexadecimal provides a concise representation for binary data and aligns well with the underlying binary nature of memory addresses.
+
+ ```assembly
+ MOV AX, 0x1000 ; Move data to the memory address 0x1000
+ ```
+
+## 2. **Direct and Indirect Addressing:**
+- **Direct Addressing:** The memory address is specified directly in the instruction.
+
+ ```assembly
+ MOV AX, [0x1000] ; Move data from the memory address 0x1000 to AX
+ ```
+
+- **Indirect Addressing:** The memory address is stored in a register or another memory location, and its value is used as the actual address.
+
+ ```assembly
+ MOV BX, 0x2000 ; Store the memory address 0x2000 in register BX
+ MOV AX, [BX] ; Move data from the memory address stored in BX to AX
+ ```
+
+## 3. **Symbolic Representation:**
+- **Labels:** Assembly language allows the use of labels to represent memory addresses symbolically. Labels are user-defined identifiers for specific locations in the code.
+
+ ```assembly
+ START:
+ MOV AX, [DATA] ; Move data from the memory address represented by the label DATA
+ DATA:
+ DW 1234 ; Data stored at the memory address labeled DATA
+ ```
+
+## 4. **Segmentation (x86 Architecture):**
+- In x86 architecture, memory addresses are often represented as a combination of a segment and an offset.
+
+ ```assembly
+ MOV AX, [0x1000] ; In this case, 0x1000 is the offset.
+ MOV AX, [CS:0x1000] ; In this case, CS is the segment register.
+ ```
+
+## 5. **Pointer Variables:**
+- **Pointers:** Assembly language allows the use of pointers, which are variables that store memory addresses. Pointers are commonly used for dynamic memory allocation.
+
+ ```assembly
+ MOV SI, OFFSET DATA ; SI is now a pointer to the memory address of the label DATA
+ MOV AX, [SI] ; Move data from the memory address stored in SI to AX
+ ```
+
+## 6. **Immediate Values:**
+- **Immediate Values:** In some instructions, immediate values (constants) may represent memory addresses directly.
+
+ ```assembly
+ MOV AX, 0x3000 ; Move the immediate value 0x3000 to register AX
+ ```
+
+## 7. **Size of Data:**
+- The size of data being accessed (byte, word, double word, etc.) can affect the representation of memory addresses and the instructions used.
+
+ ```assembly
+ MOV AL, [0x2000] ; Move a byte from the memory address 0x2000 to AL
+ MOV AX, [0x2000] ; Move a word from the memory address 0x2000 to AX
+ ```
+
+## Conclusion:
+Understanding how memory addresses are represented in assembly language is crucial for writing code that manipulates data in different parts of the computer's memory. Whether using direct addressing, indirect addressing, labels, or pointers, programmers must be able to navigate and manipulate memory effectively to create efficient and functional assembly code.