2 years ago

#46370

test-img

MiMiMiEnot

SyntaxError while assembling .asm file becouse of .def file

I need to create .dll file and import it into .asm file to use.

The problem (i suppose) is with .def file, but I can`t find correct way to do that.

The .def file content is:

LIBRARY lab18_dll
EXPORTS arrCompare
EXPORTS arr2str
EXPORTS msgResult
EXPORTS msgAuthor

dll assemble&link script is:

\masm32\bin\ml.exe /c /coff "lab18_dll.asm"
\masm32\bin\link.exe /DLL /DEF:lab18_dll.def /SUBSYSTEM:WINDOWS "lab18_dll.obj"
pause

main asm file assemble&link script is:

\masm32\bin\ml.exe /c /coff "lab18.asm"
\masm32\bin\link.exe /subsystem:console "lab18.obj"
pause

main .asm file is:

.386 ; директива визначення типу мікропроцесора
.model flat,stdcall ; задання лінійної моделі пам’яті та угоди ОС Windows
option casemap:none ; відмінність малих та великих літер
include \masm32\include\\user32.inc ; файли інтерфейсу …
include\masm32\include\kernel32.inc; файли систем. функцій застосувань…

; прототипи функцій бібліотеки, що підключаються:
include lab18_dll.def ; бібліотека констант
includelib \masm32\lib\kernel32.lib
includelib lab18_dll.lib ; динамічна бібліотека, що підключається

.data
_A dd 8, 7, 6, 5, 4, 3, 2, 1 ; масив з початковими даними
_B dd 1, 2, 3, 4, 5, 6, 7, 8 ; масив з початковими даними
_C dd 8 dup(0) ; масив для занесення результату

_str db "Масив _A:",9, 8 dup(" %d "),10, 13, "Масив _B:",9, 8 dup(" %d "),\
10,13,"Массив _C:",9,8 dup(" %d "),0 ; перетворення ; 9 – символ табуляції

.code ; директива початку сегмента даних
_start:

invoke arrCompare, addr _A, addr _B, addr _C ;формування
invoke arr2str,addr _A, addr _B, addr _C, addr _str ; конвертація в рядок
invoke msgResult, addr _str ; виведення вікна з результатами
invoke msgAuthor ; виведення відомостей про автора
invoke ExitProcess, 0 ; коректний вихід з програми

end _start ; закінчення програми з ім’ям start

While build .dll I receive output:

C:\lab_work\lab18>\masm32\bin\link.exe /DLL /DEF:lab18_dll.def /SUBSYSTEM:WINDOWS 
"lab18_dll.obj"
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Creating library lab18_dll.lib and object lab18_dll.exp

C:\lab_work\lab18>pause

But when execute lab18.bat (main .asm file assemble&link) output is:

C:\lab_work\lab18>\masm32\bin\ml.exe /c /coff "lab18.asm"
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: lab18.asm
lab18_dll.def(1) : error A2008: syntax error : LIBRARY
lab18_dll.def(2) : error A2008: syntax error : EXPORTS
lab18_dll.def(3) : error A2008: syntax error : EXPORTS
lab18_dll.def(4) : error A2008: syntax error : EXPORTS
lab18_dll.def(5) : error A2008: syntax error : EXPORTS
lab18.asm(23) : error A2006: undefined symbol : arrCompare
lab18.asm(24) : error A2006: undefined symbol : arr2str
lab18.asm(25) : error A2006: undefined symbol : msgResult
lab18.asm(26) : error A2006: undefined symbol : msgAuthor

C:\lab_work\lab18>\masm32\bin\link.exe /subsystem:console "lab18.obj"
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LINK : fatal error LNK1181: cannot open input file "lab18.obj"

C:\lab_work\lab18>pause

I checked masm32 examples, where found some .def files and copy their syntax correspond to my data, but error still the same

p.s. I`m new to assembler

assembly

dll

masm

0 Answers

Your Answer

Accepted video resources