Hi,
I'm having trouble compiling a c program which calls a simple assembly procedure.
This is intended as a medium 16-bit exe.
asm code: ADDINT.ASM
%define xparam [bp+6] ; using medium memory model
%define yparam [bp+8]
segment _TEXT public class=CODE
global add_int
add_int:
push bp
mov bp,sp
sub sp, 0x40 ; 64 bytes of local stack space
mov ax, xparam
add ax, yparam
mov sp, bp ; undo "sub sp, 0x40"
pop bp
retf ; medium model ret
C code: EXT.C
#include <stdio.h>
extern int add_int(int x, int y);
void main(void)
{
int third = add_int(9, 1);
printf("third = %d\n", third);
}
compilation:
nasm -f obj ADDINT.ASM
wcl -mm ADDINT.OBJ EXT.C
Errors:
Open Watcom C/C++ x86 16-bit Compile and Link Utility
Version 2.0 beta Jul 16 2019 17:31:29 (16-bit)
Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
wcc EXT.C -mm
Open Watcom C x86 16-bit Optimizing Compiler
Version 2.0 beta Jul 16 2019 17:23:09 (32-bit)
Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
EXT.C: 9 lines, included 799, 0 warnings, 0 errors
Code size: 35
wlink @__wcl__.lnk
Open Watcom Linker Version 2.0 beta Jul 16 2019 17:20:15 (32-bit)
Copyright (c) 2002-2019 The Open Watcom Contributors. All Rights Reserved.
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.
loading object files
searching libraries
Error! E2028: add_int_ is an undefined reference
creating a DOS executable
file EXT.obj(C:\DOS\DEV\TRICKS\EXT\EXT.C): undefined symbol add_int_
Error: Linker returned a bad status
I'm running on dosbox