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 Local and Global Symbol Types.md
Abdul Wahab Junaid6fb5e64108f8
diff --git a/Assembly language/New Assembly Work/Assembly Language/Local and Global Symbol Types.md b/Assembly language/New Assembly Work/Assembly Language/Local and Global Symbol Types.mdnew file mode 100644index 0000000..e805fa7--- /dev/null+++ b/Assembly language/New Assembly Work/Assembly Language/Local and Global Symbol Types.md@@ -0,0 +1,86 @@+In assembly language programming, especially in environments like High-Level Assembly (HLA), understanding local and global symbol types is crucial for managing variable scope, visibility, and lifetime. Here’s an overview of these concepts:++### 1. **Global Symbols**++**Global symbols** are identifiers that can be accessed from anywhere in the program. They have a global scope and are typically declared outside of any procedures or functions. Global symbols can be used by multiple procedures and are useful for data that needs to be shared across different parts of a program.++#### Characteristics of Global Symbols:+- **Accessibility**: Global symbols can be accessed from any part of the program, including all procedures.+- **Lifetime**: The lifetime of a global symbol spans the entire execution of the program.+- **Memory**: Global symbols are usually allocated in the data segment or initialized at the start of the program.++#### Example of Global Symbols in HLA++```assembly+program GlobalSymbolExample;++#include("stdlib.hhf")++// Global symbol declaration+globalVariable: int := 10; // A global variable++begin GlobalSymbolExample;++ // Accessing the global variable+ stdout.put("Global Variable: ", globalVariable, nl);++ // Modifying the global variable+ globalVariable := globalVariable + 5;+ stdout.put("Modified Global Variable: ", globalVariable, nl);++end GlobalSymbolExample;+```++### 2. **Local Symbols**++**Local symbols** are identifiers that are declared within a specific procedure or function. They have a local scope and can only be accessed within that procedure. Once the procedure finishes executing, the local symbols are no longer accessible, and their memory is typically freed.++#### Characteristics of Local Symbols:+- **Accessibility**: Local symbols can only be accessed within the procedure in which they are declared.+- **Lifetime**: The lifetime of a local symbol lasts only as long as the procedure is executing.+- **Memory**: Local symbols are usually allocated on the stack, which allows for automatic cleanup when the procedure returns.++#### Example of Local Symbols in HLA++```assembly+program LocalSymbolExample;++#include("stdlib.hhf")++begin LocalSymbolExample;++ // A procedure that uses local variables+ procedure Calculate;+ begin Calculate;+ // Local symbol declaration+ localVariable: int := 5; // A local variable+ localVariable := localVariable * 2;+ stdout.put("Local Variable: ", localVariable, nl);+ end Calculate;++ // Call the Calculate procedure+ Calculate();++ // Trying to access localVariable here will cause an error+ // stdout.put("Trying to access Local Variable: ", localVariable, nl); // This line would cause a compile error++end LocalSymbolExample;+```++### 3. **Key Differences Between Local and Global Symbols**++| Feature | Global Symbols | Local Symbols |+|---------------------|------------------------------|---------------------------|+| **Scope** | Accessible throughout the program | Accessible only within the procedure where declared |+| **Lifetime** | Exists for the entire program execution | Exists only during the procedure execution |+| **Memory Location** | Usually in the data segment | Usually on the stack |+| **Use Case** | Data shared across procedures | Temporary data for a specific procedure |++### 4. **Best Practices**++- **Use Local Symbols When Possible**: Local symbols are generally preferred for temporary variables and calculations within procedures because they minimize the risk of unintended side effects.+- **Limit Global Symbols**: Use global symbols sparingly to avoid naming conflicts and maintain cleaner code.++### 5. **Conclusion**++Understanding local and global symbol types is essential for effective assembly language programming. Local symbols help manage temporary data and minimize scope, while global symbols facilitate data sharing across procedures.