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.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Create ASM program - moving immediate data.md
Abdul Wahab Junaid731f48e13f85
diff --git a/Assembly language/New Assembly Work/Assembly Language/ASM program - moving immediate data.md b/Assembly language/New Assembly Work/Assembly Language/ASM program - moving immediate data.mdnew file mode 100644index 0000000..13f6e64--- /dev/null+++ b/Assembly language/New Assembly Work/Assembly Language/ASM program - moving immediate data.md@@ -0,0 +1,119 @@+In **Assembly Language (ASM)**, moving immediate data into a register or memory is a common operation. The **`MOV`** instruction is used for this purpose. This instruction transfers data from one place (source) to another (destination).++### **Basic Syntax of `MOV` Instruction:**++```assembly+MOV destination, source+```++- **`destination`**: Where the data will be moved to (e.g., a register or memory location).+- **`source`**: The data to be moved (this can be a register, memory location, or immediate value).++In the case of **moving immediate data**, the source will be an **immediate value** (a constant value), and the destination will typically be a **register** or **memory**.++---++### **Example 1: Moving Immediate Data into a Register (x86 Architecture)**++```assembly+section .data ; Data segment (if needed)+ ; You can define variables here++section .text ; Code segment+ global _start ; Make the entry point visible to the linker++_start:+ MOV EAX, 10 ; Move the immediate value 10 into the EAX register+ MOV EBX, 20 ; Move the immediate value 20 into the EBX register++ ; Exit the program (Linux syscall example)+ MOV EAX, 60 ; Syscall number for exit (in x86-64 Linux)+ MOV EDI, 0 ; Exit code 0+ syscall ; Invoke the syscall to exit+```++### **Explanation:**+- **`MOV EAX, 10`**: Moves the immediate value **10** into the **EAX** register.+- **`MOV EBX, 20`**: Moves the immediate value **20** into the **EBX** register.+- The final lines show how the program exits gracefully using a Linux syscall (`syscall`).++---++### **Example 2: Moving Immediate Data into Memory**++```assembly+section .data+ result db 0 ; Reserve a byte of memory initialized to 0++section .text+ global _start++_start:+ MOV BYTE [result], 100 ; Move immediate value 100 into the memory location 'result'++ ; Exit the program (Linux syscall example)+ MOV EAX, 60 ; Syscall number for exit+ MOV EDI, 0 ; Exit code 0+ syscall ; Invoke the syscall to exit+```++### **Explanation:**+- **`MOV BYTE [result], 100`**: Moves the immediate value **100** into the **memory location** labeled as `result`.+- Here, **`result`** is a variable (byte-sized) declared in the **`.data`** section.++---++### **Example 3: Moving Immediate Data into 16-bit and 8-bit Registers**++```assembly+section .text+ global _start++_start:+ MOV AX, 1234h ; Move the immediate value 1234h (hexadecimal) into the 16-bit register AX+ MOV AL, 56h ; Move the immediate value 56h into the 8-bit register AL++ ; Exit the program (Linux syscall example)+ MOV EAX, 60 ; Syscall number for exit+ MOV EDI, 0 ; Exit code 0+ syscall ; Invoke the syscall to exit+```++### **Explanation:**+- **`MOV AX, 1234h`**: Moves the hexadecimal value `1234h` into the 16-bit **AX** register.+- **`MOV AL, 56h`**: Moves the hexadecimal value `56h` into the 8-bit **AL** register.++---++### **Immediate Data Sizes:**+- **8-bit data**: Can be moved into 8-bit registers (e.g., `AL`, `BL`).+- **16-bit data**: Can be moved into 16-bit registers (e.g., `AX`, `BX`).+- **32-bit data**: Can be moved into 32-bit registers (e.g., `EAX`, `EBX`).+- **64-bit data**: Can be moved into 64-bit registers (e.g., `RAX`, `RBX` in x86-64).++---++### **More Examples of Moving Immediate Data:**++1. **Move Immediate Data to a 32-bit Register:**+ ```assembly+ MOV EAX, 0x12345678 ; Move the hexadecimal value 0x12345678 into the 32-bit register EAX+ ```++2. **Move Immediate Data to a 64-bit Register (x86-64 Architecture):**+ ```assembly+ MOV RAX, 0x1122334455667788 ; Move the 64-bit value into the 64-bit register RAX+ ```++3. **Move Immediate Data to a Variable in Memory:**+ ```assembly+ MOV DWORD [some_memory], 0xDEADBEEF ; Move the value 0xDEADBEEF into the memory location 'some_memory'+ ```++---++### **Important Notes:**+- The **size of the immediate value** and the **destination** must be compatible. For example, an 8-bit value can't be moved into a 16-bit register without truncation or explicit type casting.+- **Addressing modes**: When dealing with memory, you can use various addressing modes to specify the exact memory location.++---