First post, by Exploit
I have three assembler files for DOS, these are:
; Note: Quit with CTRL+C; Program name: MAIN.ASMEXTRN WAIT_X:FAR.MODEL SMALL.STACK 256.CODESTART:MOV DL, 00hM1:MOV AH, 02hINT 21h ; Shows value of DL registerINC DLCALL WAIT_X ; subroutine call of WAIT_XJMP M1MOV AH, 4Ch ; return to DOSINT 21hEND START
; Note: With manual register saving; Program name: WAIT_A.ASMPUBLIC WAIT_X.MODEL SMALL.STACK 256.CODEWAIT_X PROC FAR ; subroutinePUSH BXPUSH CXMOV BL, 80H ; delay loopM2: MOV CX, 0FFFFh ; outer loopM1: DEC CX ; inner loopJNZ M1DEC BLJNZ M2POP CXPOP BXRET ; return to mainWAIT_X ENDPEND
and
; Note: With USES directive and language type C; Program name: WAIT_B.ASMPUBLIC WAIT_X.MODEL SMALL, C.STACK 256.CODEWAIT_X PROC FAR USES BX CX ; subroutineMOV BL, 80H ; delay loopM2: MOV CX, 0FFFFh ; outer loopM1: DEC CX ; inner loopJNZ M1DEC BLJNZ M2RET ; return to mainWAIT_X ENDPEND
WAIT_A.ASM and WAIT_B.ASM use both the same public routine name WAIT_X which is called by MAIN.ASM
The only difference is, that WAIT_B does make use of the USES assembler directive and this directive expects to have a language type set in the directive .MODEL
diff WAIT_A.ASM WAIT_B.ASM1,2c1,2< ; Note: With manual register saving< ; Program name: WAIT_A.ASM---> ; Note: With USES directive and language type C> ; Program name: WAIT_B.ASM4c4< .MODEL SMALL---> .MODEL SMALL, C8,10c8< WAIT_X PROC FAR ; subroutine< PUSH BX< PUSH CX---> WAIT_X PROC FAR USES BX CX ; subroutine18,19d15< POP CX< POP BX
When i use the following comands:
jwasmr -0 MAIN.ASM WAIT_A.ASM WAIT_B.ASMwlink name main_a file main,wait_awlink name main_b file main,wait_b
The assembly of the files works without erros:
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.MAIN.ASM: 20 lines, 2 passes, 0 ms, 0 warnings, 0 errorsWAIT_A.ASM: 23 lines, 2 passes, 0 ms, 0 warnings, 0 errorsWAIT_B.ASM: 19 lines, 2 passes, 0 ms, 0 warnings, 0 errors
And wlink works with the WAIT_A.OBJ file but it fails with the similar but not identical WAIT_B.OBJ file.
It gives the following error message when using WAIT_B.OBJ:
Error! E2028: WAIT_X is an undefined referencecreating a DOS executablefile main.obj(MAIN.ASM): undefined symbol WAIT_X
Can anyone tell me how to fix this and why this error occurs?
Both WAIT* files use the PUBLIC directive to make the WAIT_X function public.
And MAIN.ASM has a EXTRN WAIT_X:FAR directive, thus it should know that WAIT_X function.
But still, it fails.
Personally i assume, that the set language type C in the .MODEL directive is the problem. At least the same error will occur, if i set the same language type in WAIT_A.ASM to C.
But i don't know, how to solve that.
I also tried other language types, like FASTCALL
.MAIN SMALL, FASTCALL
but this didn't solve it.