I am trying to compile a C program with an ASM procedure. It must be 16-bit, so I use Visual C ++ 1.0 and MASM 6.11.
ASM Code:
.MODEL MEDIUM
EXTRN first:WORD, second:WORD, third:WORD
.CODE
_Add_Ext PROC FAR
mov AX, first
add AX, second
mov third, AX
_Add_Ext ENDP
END
I compiled it in a .obj file
ml.exe -c -Cx -FoC:\prjcts\2_6\2_7.obj C:\prjcts\2_6\2_7.asm
and included in the project.
C code:
#include <stdio.h>
int first = 1, second = 2, third = 0;
void main (void)
{
printf("\nBefore adding third = %d", third);
Add_Ext();
printf("\nAfter adding third = %d", third);
}
When I try to compile it, it gives me:
Compiling...
c:\prjcts\2_6\2_6.c
Linking...
C:\PRJCTS\2_6\2_7.OBJ(C:\prjcts\2_6\2_7.asm) : error L2029: 'first' : unresolved external
C:\PRJCTS\2_6\2_7.OBJ(C:\prjcts\2_6\2_7.asm) : error L2029: 'third' : unresolved external
C:\PRJCTS\2_6\2_7.OBJ(C:\prjcts\2_6\2_7.asm) : error L2029: 'second' : unresolved external
LINK returned error code 2.
Creating browser database...
2_6.EXE - 3 error(s), 0 warning(s)
So, he sees mine .obj, understands what it is, but cannot understand, take variables from C-code? I do not want to use the built-in assembler, but I tried it before and it worked.