VOGONS


First post, by Exploit

User metadata
Rank Newbie
Rank
Newbie

When i try to link some object files with WLINK.EXE i get the following error message:

Error! E3033: directive error near

That is my code:
ONE.ASM

; PROG ONE.ASM
EXTRN TWO:FAR
.MODEL SMALL
.STACK 256
.CODE

MAIN:
MOV AH, 00
MOV DL, 34h
MOV AH, 02h
INT 21h
CALL TWO
MOV AH, 4Ch
INT 21h
END MAIN

TWO.ASM

; PROG: TWO.ASM
PUBLIC TWO
.MODEL SMALL
.STACK 256
.CODE

TWO PROC FAR
PUSH BX
PUSH CX
MOV DL, 32h
MOV AH, 02h
INT 21h
POP CX
POP BX
RET
TWO ENDP
END

JWASMR.EXE does assemble the code without errors to obj files.
The -0 option is for 8086.

C:\>jwasmr -0 one.asm two.asm
JWasm v2.14, Dec 20 2020, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

ONE.ASM: 18 lines, 2 passes, 0 ms, 0 warnings, 0 errors
TWO.ASM: 19 lines, 2 passes, 0 ms, 0 warnings, 0 errors
C:\>dir *.obj
...
ONE.OBJ
TWO.OBJ
...

But WLINK.EXE can't link them:

C:\>wlink one.asm two.asm 
Open Watcom Linker Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
Error! E3033: directive error near 'one.asm'
C:\>

I also tried

wlink one.obj two.obj

but this didn't help either.

It might be possible, that wlink needs other paramters, but the linker command example (ot the code) is from a book that is written for MASM
and there it says i have to use:

ML  CODE1.ASM CODE2.ASM

Thus i tried to adapt to WLINK.EXE but without success.

Reply 1 of 9, by Exploit

User metadata
Rank Newbie
Rank
Newbie

Okay, i solved it.

WLINK.EXE does need different parameter options:

In this example it works with the following command line:

wlink name test.exe format dos file one.obj , two.obj

The "name" options followed by a file name defines how the resulting executable should be called.
TEST.EXE can be changed to whatever you want to use and is the resulting executable name.

The "format" option followed by "DOS" defines, that this is an executable for DOS.

The "file" option followed by an object file, that was created with JWASMR defines what obj files to use.
Each object file must be separated with a comma.

The linker seems to not be able to use *.asm code files and pass them to jwasmr automatically.

Reply 3 of 9, by Exploit

User metadata
Rank Newbie
Rank
Newbie
pan069 wrote on 2022-08-21, 09:45:
Try this: […]
Show full quote

Try this:

wlink name final.exe file one.obj,two.obj

Note the comma between the object files.

Edit: You beat me to it. 😀

😀

I also found out, that it is not required to add the file extension.

This:

wlink name final file one,two

will work too. At least in DOS, it might be different on other systems but i need wlink only for DOS.

The file extension is automatically determined.

Reply 6 of 9, by mkarcher

User metadata
Rank l33t
Rank
l33t
Exploit wrote on 2022-08-21, 12:55:
Ringding wrote on 2022-08-21, 12:50:

Why do you create a FAR proc when using model SMALL?

Because it's in another object file and thus very likely another segment.

The idea of MODEL SMALL is that the code segments of all source files gets combined by the linker into a single 64K code segments, so all CALLs and function pointers can be near. If you want different code segments for different object files, you should use MODEL MEDIUM (near data pointers) or MODEL LARGE (far data pointers). Even in MODEL LARGE, all data segments from the object files get combined into a single data segment, and DS is intended to point to this "primary data segment". Standard data pointers are allowed to point anywhere, even outside of the primary data segment. (e.g. segments allocated from DOS using INT 21h/AH=48h, video memory or the EMS page frame).

Reply 7 of 9, by Exploit

User metadata
Rank Newbie
Rank
Newbie
mkarcher wrote on 2022-08-21, 13:39:
Exploit wrote on 2022-08-21, 12:55:
Ringding wrote on 2022-08-21, 12:50:

Why do you create a FAR proc when using model SMALL?

Because it's in another object file and thus very likely another segment.

The idea of MODEL SMALL is that the code segments of all source files gets combined by the linker into a single 64K code segments, so all CALLs and function pointers can be near.

Well, I was just repeating what's in the book. And it seems to make sense for library purposes.

Reply 8 of 9, by BloodyCactus

User metadata
Rank Oldbie
Rank
Oldbie
Exploit wrote on 2022-08-21, 09:04:
But WLINK.EXE can't link them: […]
Show full quote

But WLINK.EXE can't link them:

C:\>wlink one.asm two.asm 
Open Watcom Linker Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
Error! E3033: directive error near 'one.asm'
C:\>

well, you cant link assembler files before assembling them... and as you noted, wlink has a formatted command line. easier to just wcl/wcl386 if you want one step compile+link.

--/\-[ Stu : Bloody Cactus :: [ https://bloodycactus.com :: http://kråketær.com ]-/\--

Reply 9 of 9, by Exploit

User metadata
Rank Newbie
Rank
Newbie
BloodyCactus wrote on 2022-08-21, 14:58:

well, you cant link assembler files before assembling them...

That was not the point. I also said, i used wlink *.obj ... etc.

And ml.exe can do exactly that. It assembles and links in one go.
Also you're too late, the problem is already solved.