Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:multiasm:papc:chapter_6_9 [2026/02/20 11:05] – [Compatibility with HLL Compilers (C++, C#) and Operating Systems] pczekalskien:multiasm:papc:chapter_6_9 [2026/02/27 02:50] (current) – [Merging of the High-Level Languages and Assembler Code] jtokarz
Line 13: Line 13:
 <caption>Static merging (linking) of the assembler code and high-level application</caption> <caption>Static merging (linking) of the assembler code and high-level application</caption>
 </figure> </figure>
-<figure staticlinking>+<figure dynamiclinking>
 {{ :en:multiasm:papc:dynamic_linking.png?600 |Dynamic merging (loading) of the assembler code and high-level application}} {{ :en:multiasm:papc:dynamic_linking.png?600 |Dynamic merging (loading) of the assembler code and high-level application}}
 <caption>Dynamic merging (loading) of the assembler code and high-level application</caption> <caption>Dynamic merging (loading) of the assembler code and high-level application</caption>
Line 31: Line 31:
  
 ==== Dynamic memory management considerations ==== ==== Dynamic memory management considerations ====
-Using dynamic memory management at the level of the assembler code is troublesome: allocating and releasing memory require calls to the hosting operating system. It is possible, but complex. Moreover, there is no dynamic, automated memory management, as in .NET, Java, and Python, so the developer is on their own, similar to programming in C++. For this reason, it is common to allocate adequate memory resources on the high-level code, e.g., the GUI front-end and pass them to the assembler code as pointers. Note, however, that for some higher-level languages, such as C#, it is necessary to follow a strict pattern to ensure correct and persistent memory allocation, as described in the following sections.+Using dynamic memory management at the assembler level is troublesome: allocating and releasing memory require calls to the host operating system. It is possible, but complex. Moreover, there is no dynamic, automated memory management, as in .NET, Java, and Python, so the developer is on their own, much like in C++. For this reason, it is common to allocate adequate memory resources on the high-level code, e.g., the GUI front-end and pass them to the assembler code as pointers (figure {{ref>dynamicmemory}}). Note, however, that for some higher-level languages, such as C#, it is necessary to follow a strict pattern to ensure correct and persistent memory allocation, as described in the following sections.
  
 <note tip>Using dynamic memory management at the level of the assembler code is troublesome. Common practice is to dynamically allocate memory resources in the scope of the calling (high-level) application and pass them to the assembler code via pointers.</note> <note tip>Using dynamic memory management at the level of the assembler code is troublesome. Common practice is to dynamically allocate memory resources in the scope of the calling (high-level) application and pass them to the assembler code via pointers.</note>
  
 +<figure dynamicmemory>
 +{{ :en:multiasm:papc:hll_and_assembler-dynamic_memory_allocation.drawio.png?600 | Dynamic Memory Allocation Model for Assembler Code Integration}}
 +<caption>Dynamic Memory Allocation Model for Assembler Code Integration</caption>
 +</figure>
 ==== Pure Assembler Applications for Windows CMD ==== ==== Pure Assembler Applications for Windows CMD ====
 It is possible to write an application for Windows solely in assembler. While the reason to do it is doubtful, some hints presented below, such as calling system functions, may be helpful. It is possible to write an application for Windows solely in assembler. While the reason to do it is doubtful, some hints presented below, such as calling system functions, may be helpful.
Line 128: Line 132:
 int main() int main()
 { {
- dllHandle = LoadLibrary(TEXT("AssemblerDll.dll")); +    dllHandle = LoadLibrary(TEXT("AssemblerDll.dll")); 
- if (!dllHandle) +    if (!dllHandle) 
-+    
- std::cerr << "Failed to load DLL library\n"; +        std::cerr << "Failed to load DLL library\n"; 
- return 1; +        return 1; 
-+    
- MyProc myAsmProcedure = (MyProc)GetProcAddress(dllHandle, "MyAsmProc"); +    MyProc myAsmProcedure = (MyProc)GetProcAddress(dllHandle, "MyAsmProc"); 
- if (!myAsmProcedure) +    if (!myAsmProcedure) 
-+    
- std::cerr << "Failed to find assembler procedure\n"; +        std::cerr << "Failed to find assembler procedure\n"; 
- FreeLibrary(dllHandle); +        FreeLibrary(dllHandle); 
- return 2; +        return 2; 
-+    
- std::cout << myAsmProcedure(); +    std::cout << myAsmProcedure(); 
- FreeLibrary(dllHandle); +    FreeLibrary(dllHandle); 
- return 0;+    return 0;
 } }
  
Line 270: Line 274:
     std::cout << "Hello, Assembler!" << std::endl;     std::cout << "Hello, Assembler!" << std::endl;
     returnValue = addInAsm(a,b);     returnValue = addInAsm(a,b);
-    std::cout << "Sum of " << a << " and " << b << " is " << returnValue << std::endl;+    std::cout << "Sum of " << a << " and " << b << " is " << returnValue  
 +              << std::endl;
     return 0;     return 0;
 } }
 </code> </code>
en/multiasm/papc/chapter_6_9.1771578344.txt.gz · Last modified: by pczekalski
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0