No ACL setup yet! Denying access to everyone.
en:edu:zmitac:s1:apl:lab:lab2
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:edu:zmitac:s1:apl:lab:lab2 [2024/11/25 12:01] – [Wykorzystanie biblioteki dll napisanej w asemblerze] ktokarz | en:edu:zmitac:s1:apl:lab:lab2 [2024/11/26 13:26] (current) – [Laboratory2] ktokarz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| + | ===== Laboratory | ||
| + | Configuration of the Visual Studio Community 2019 for dll libraries written in MASM. | ||
| ===== Creating the project with dll library written in assembler ===== | ===== Creating the project with dll library written in assembler ===== | ||
| Line 126: | Line 128: | ||
| ===== Using a dll library written in assembler ===== | ===== Using a dll library written in assembler ===== | ||
| - | ==== Biblioteka asemblerowa | + | ==== dll library written in assembler |
| - | Biblioteka | + | |
| + | The dll library contains functions that can be used in other programs. The first version of our library will provide one function that returns | ||
| < | < | ||
| Line 138: | Line 141: | ||
| </ | </ | ||
| - | Z plikiem kodu programu nierozerwalnie związany jest plik definicji | + | The program code file is inextricably linked to the definition file (JaDll.def). |
| < | < | ||
| Line 145: | Line 148: | ||
| </ | </ | ||
| - | Często chcemy wykorzystać przekazane do funkcji parametry. Przypomnijmy, | + | We often want to use the parameters passed to the function. Recall that in the 64-bit calling convention, the first four parameters are placed directly in the processor registers. The details were provided during lectures and are described in the instructions for the first lab exercise. Thus, two integer-type parameters are placed in the RCX and RDX registers. A function that returns the sum of two integer arguments would look like this. |
| < | < | ||
| Line 157: | Line 160: | ||
| </ | </ | ||
| - | Argumenty typu zmiennoprzecinkowego należy przekazać przez rejestry | + | Floating point arguments should be passed through registers |
| < | < | ||
| Line 167: | Line 170: | ||
| ... | ... | ||
| </ | </ | ||
| - | ==== Odwołanie do biblioteki | + | ==== Calling functions in dll from C++ program |
| - | Aby program | + | In order for a program |
| - | - Przygotować typ funkcji zgodny z jej późniejszym wywołaniem, | + | - Prepare the type of the function that is compatible with its later call, |
| - | - Załadować bibliotekę funkcją | + | - Load the library using the LoadLibrary |
| - | - Odczytać aktualny adres interesującej nas funkcji wywołując | + | - Read the current address of the function of interest to us by calling |
| - | - Użyć funkcji odwołując się do jej adresu. | + | - Use the function by referring to its address. |
| - | Przykładowy kod mógłby wyglądać tak: | + | The sample code could look like this: |
| < | < | ||
| Line 190: | Line 193: | ||
| </ | </ | ||
| - | Użycie funkcji z parametrami wymaga nieco zmodyfikowanych definicji typu. Należy także zwrócić uwagę na typ wartości zwracanej przez funkcję. Pamiętać należy, że w przypadku liczb zmiennoprzecinkowych, | + | Using a function with parameters requires slightly modified type definitions. You should also pay attention to the type of the value returned by the function. Remember that in the case of floating-point numbers, the size of the XMM0, XMM1 registers is 64 bits. This corresponds |
| < | < | ||
| Line 199: | Line 202: | ||
| </ | </ | ||
| - | ==== Zadanie do zrealizowania w ramach laboratorium | + | ==== Task to be completed in the laboratory |
| - | Należy napisać bibliotekę | + | You should write a DLL in assembler and a C++ program that demonstrates how the DLL works.\\ |
| - | **Biblioteka | + | **The DLL** should provide functions that perform and return the result of basic arithmetic calculations |
| - | **Program w C++** ma wywoływać wszystkie funkcje przekazując przykładowe wartości parametrów i wyświetlić wyniki na ekranie. Nie jest wymagany interfejs użytkownika | + | **The C++ program** should call all functions, pass sample parameter values, and display the results on the screen. No input user interface is required |
| + | |||
| + | ==== For the report ==== | ||
| + | Include the code of your C++ file and assembler source file WITH COMMENTS. Also, add a screenshot of the window with the results displayed. | ||
en/edu/zmitac/s1/apl/lab/lab2.1732532499.txt.gz · Last modified: by ktokarz
