This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:papc:chapter_6_9 [2026/02/20 13:08] – [Dynamic memory management considerations] pczekalski | en:multiasm:papc:chapter_6_9 [2026/05/13 09:06] (current) – [Programming in Assembler for Linux] ktokarz | ||
|---|---|---|---|
| Line 36: | Line 36: | ||
| <figure dynamicmemory> | <figure dynamicmemory> | ||
| - | {{: | + | {{ : |
| < | < | ||
| </ | </ | ||
| Line 68: | Line 68: | ||
| Calling system functions, such as the system message box, requires understanding the arguments passed to them. As there is no direct assembler help, documentation of the Windows system API for C++ is helpful. | Calling system functions, such as the system message box, requires understanding the arguments passed to them. As there is no direct assembler help, documentation of the Windows system API for C++ is helpful. | ||
| Code below presents the necessary components of the assembler app to call system functions (library includes are configured on the project level): | Code below presents the necessary components of the assembler app to call system functions (library includes are configured on the project level): | ||
| - | < | + | < |
| .data | .data | ||
| STD_INPUT_HANDLE = -10 | STD_INPUT_HANDLE = -10 | ||
| Line 132: | Line 132: | ||
| int main() | int main() | ||
| { | { | ||
| - | dllHandle = LoadLibrary(TEXT(" | + | |
| - | if (!dllHandle) | + | if (!dllHandle) |
| - | { | + | { |
| - | std::cerr << " | + | std::cerr << " |
| - | return 1; | + | return 1; |
| - | } | + | } |
| - | MyProc myAsmProcedure = (MyProc)GetProcAddress(dllHandle, | + | MyProc myAsmProcedure = (MyProc)GetProcAddress(dllHandle, |
| - | if (!myAsmProcedure) | + | if (!myAsmProcedure) |
| - | { | + | { |
| - | std::cerr << " | + | std::cerr << " |
| - | FreeLibrary(dllHandle); | + | FreeLibrary(dllHandle); |
| - | return 2; | + | return 2; |
| - | } | + | } |
| - | std::cout << myAsmProcedure(); | + | std::cout << myAsmProcedure(); |
| - | FreeLibrary(dllHandle); | + | FreeLibrary(dllHandle); |
| - | return 0; | + | return 0; |
| } | } | ||
| Line 247: | Line 247: | ||
| Assembler code exposes functions to the linker using the '' | Assembler code exposes functions to the linker using the '' | ||
| - | < | + | < |
| section .data | section .data | ||
| section .bss | section .bss | ||
| Line 274: | Line 274: | ||
| std::cout << " | std::cout << " | ||
| returnValue = addInAsm(a, | returnValue = addInAsm(a, | ||
| - | std::cout << "Sum of " << a << " and " << b << " is " << returnValue << std::endl; | + | std::cout << "Sum of " << a << " and " << b << " is " << returnValue |
| + | | ||
| return 0; | return 0; | ||
| } | } | ||
| </ | </ | ||