Ok, I hope this is the last major question I have here after putting low of rudimentary question. I tried to do a correct usage of extern and public in two different files and both of them compiles and generates obj files but during link the proc declared as public (lib.asm) and imported into second file (asmfile.asm) with extern directive is causing issue. I re-checked everything and corrected but still it is giving a grief. Can someone help on this?
After compilation, I am not sure if the code segment of lib.asm were included in the binary (need to check that) but for sure, data segment of lib.asm was included by dumping the area with debugger.
Thanks in advance!
C:\git\minix.dev>dir
Volume in drive C has no label.
Volume Serial Number is FC76-C34F
Directory of C:\git\minix.dev
09/17/2015 10:43 PM <DIR> .
09/17/2015 10:43 PM <DIR> ..
09/18/2015 12:05 AM <DIR> exp
0 File(s) 0 bytes
3 Dir(s) 46,058,704,896 bytes free
C:\git\minix.dev>cdexp
C:\git\minix.dev\exp>dir
Volume in drive C has no label.
Volume Serial Number is FC76-C34F
Directory of C:\git\minix.dev\exp
09/18/2015 12:05 AM <DIR> .
09/18/2015 12:05 AM <DIR> ..
09/17/2015 11:53 PM 941 asmfile.asm
09/18/2015 12:05 AM 882 asmfile.exe
09/18/2015 12:05 AM 3,750 asmfile.lst
09/18/2015 12:05 AM 320 asmfile.map
09/18/2015 12:05 AM 718 asmfile.obj
09/17/2015 10:43 PM 240 cfile.c
09/17/2015 10:43 PM 44 del1.bat
09/17/2015 11:50 PM 524 lib.asm
09/17/2015 10:43 PM 239 lib.inc
09/18/2015 12:05 AM 1,844 lib.lst
09/18/2015 12:05 AM 537 lib.obj
09/17/2015 10:43 PM 599 macros.inc
09/17/2015 11:37 PM 194 masm.cmpl.bat
13 File(s) 10,832 bytes
2 Dir(s) 46,058,704,896 bytes free
C:\git\minix.dev\exp>typeasmfile.asm
.586
;.model flat, stdcall
include macros.inc
extern extFnc:near
;extrn extFcn1:near
sta segment para stack use16 'stack'
db 100h dup(0)
sta ends
data segment para public 'data'
str0 db 'test string in asmfile.asm$'
str1 db 'str1$'
data ends
code segment para public use16 'code'
assume cs:code, ds:data,ss:sta
main proc far
mov ax, DATA
mov ds, ax
; PRINTF "macrostring"
; PRINTF "2ndMacroString"
; call extFcn
; lea bp, str0
; call printStr
mov ax, 4c00h
int 21h
main endp
; input
; DS:BP - pointer to string ($) terminated.
printStr proc far
printLoop:
mov dl, ds:[bp]
cmp dl, '$'
je quit
mov ah, 02h
int 21h
inc bp
jmp printLoop
quit:
ret
printStr endp
code ends
end main
C:\git\minix.dev\exp>typelib.asm
.586
public extFcn, extFcn1
sta segment para stack use16 'stack'
sta ends
data segment para public 'data'
str1 db 'test string in lib.asm'
data ends
code segment para public use16 'code'
assume cs:code, ds:code, ss:sta
extFcn1 proc near
xor dl, dl
mov dl, 36h
mov ah, 02h
int 21h
ret
extFcn1 endp
extFcn proc near
xor dh, dh
mov dl, 35h
mov ah, 02h
int 21h
ret
extFcn endp
code ends
end
C:\git\minix.dev\exp>del1.bat
C:\git\minix.dev\exp>del *.obj
C:\git\minix.dev\exp>del *.exe
C:\git\minix.dev\exp>del *.lst
C:\git\minix.dev\exp>del *.map
C:\git\minix.dev\exp>masm.cmpl.bat
C:\git\minix.dev\exp>del *.exe
Could Not Find C:\git\minix.dev\exp\*.exe
C:\git\minix.dev\exp>del *.obj
Could Not Find C:\git\minix.dev\exp\*.obj
C:\git\minix.dev\exp>del *.lst
Could Not Find C:\git\minix.dev\exp\*.lst
C:\git\minix.dev\exp>del *.map
Could Not Find C:\git\minix.dev\exp\*.map
C:\git\minix.dev\exp>rem ml /c /coff /Cp /Fm /Fl asmfile.asm
C:\git\minix.dev\exp>rem ml /omf /c /Fl /Zi /Zd lib.asm
C:\git\minix.dev\exp>ml /c /Fl /Zi /Zd asmfile.asm lib.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: asmfile.asm
sta segment para stack use16 'stack'ends data segment para public 'data' str1 db 'test string in lib.asm'data ends code segment para public use16 'code'assume cs:code, ds:code, ss:sta extFcn1 proc near xor dl, dl mov dl, 36hah, 02int 21h ret extFcn1 endp extFcn proc near xor dh, dh mov dl, 35hah, 02int 21h ret extFcn endpcode ends end C:\git\minix.dev\exp>del1.bat C:\git\minix.dev\exp>del *.obj C:\git\minix.dev\exp>del *.exe C:\git\minix.dev\exp>del *.lst C:\git\minix.dev\exp>del *.map C:\git\minix.dev\exp>masm.cmpl.bat C:\git\minix.dev\exp>del *.exeould Not Find C:\git\minix.dev\exp\*.exe C:\git\minix.dev\exp>del *.objould Not Find C:\git\minix.dev\exp\*.obj C:\git\minix.dev\exp>del *.lstould Not Find C:\git\minix.dev\exp\*.lst C:\git\minix.dev\exp>del *.mapould Not Find C:\git\minix.dev\exp\*.map C:\git\minix.dev\exp>rem ml /c /coff /Cp /Fm /Fl asmfile.asm C:\git\minix.dev\exp>rem ml /omf /c /Fl /Zi /Zd lib.asm C:\git\minix.dev\exp>ml /c /Fl /Zi /Zd asmfile.asm lib.asmMicrosoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: asmfile.asmlib.asm
C:\git\minix.dev\exp>link16 asmfile.obj lib.obj,,,,,
Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994
Copyright (C) Microsoft Corp 1984-1993. All rights reserved.
asmfile.obj(asmfile.asm) : error L2029: 'extFnc' : unresolved external
There was 1 error detected
C:\git\minix.dev\exp>