I can't call the function in the C file from my ASM file, why? - TCP-IP
This is a discussion on I can't call the function in the C file from my ASM file, why? - TCP-IP ; I wrote a program consist of one ASM file and one C file. I compiled
them with masm613
and msvc152. But I can't call the function in the C file from my ASM
file.
The expected output is:
hello1
hello2
...
-
I can't call the function in the C file from my ASM file, why?
I wrote a program consist of one ASM file and one C file. I compiled
them with masm613
and msvc152. But I can't call the function in the C file from my ASM
file.
The expected output is:
hello1
hello2
testing...
hello3
0080
But the output is:
hello1
hello2
[some kind of messy code]
hello3
0090
It seemed that I called some other unknown address when I called
_DriverInit. Why?
What's wrong with my sourcecode or makefile? And why my offset
cs
hd_dioa is 0090h not 0080h ?Following I list my sourcecode and
makefile. Thank you very much.
;[main.asm]
..386p
_TEXT SEGMENT WORD USE16 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT WORD USE16 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT WORD USE16 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT WORD USE16 PUBLIC 'BSS'
_BSS ENDS
DGROUP GROUP CONST, _BSS, _DATA
ASSUME DS: DGROUP
ASSUME SS: NOTHING
..list
..xlist
_TEXT segment word USE16 public 'CODE'
ASSUNE CS:_TEXT
public phd_dioa
org 80h
phd_dioa label byte
org 100h
start:
jmp start_1
db "PK"
dw '$'
hello1 db 'hello1', 0dh, 0ah, 0
hello2 db 'hello2', 0dh, 0ah, 0
hello3 db 'hello3', 0dh, 0ah, 0
start_1:
push cs
push offset cs:hello1
call _BIOSputs
add sp, 4
push cs
push offset cs:hello2
call _BIOSputs
add sp, 4
call _DriverInit
extrn _DriverInit: near
push cs
push offset cs:hello3
call _BIOSputs
add sp, 4
push offset cs
hd_dioa
call _BIOSputh4
add sp, 2
......
_TEXT ends
end
/*[test.c]:*/
#include ...
void DriverInit()
{
BIOSputs("testing...\r\n");
}
#[build.bat]:
set TOOLDIR=D:
call %TOOLDIR%\masm611\binr\new-vars
call %TOOLDIR%\msvc\bin\msvcvars
@echo off
rm -fr bin
mkdir bin
if [%1] == [clean] goto clean
nmake -nologo -f Stub.mak BUILD_FL=%1%
if errorlevel 1 echo !!!!!!!!!!!!!!!!!!!!!!! ERROR ERROR
!!!!!!!!!!!!!!!!!!!!!!
goto done
:clean
nmake -nologo -f Stub.mak clean
:done
if exist dos\make.err type dos\make.err
#[stub.mak]:
DEBUG=/DDEBUG=1
#DEBUG=/DDEBUG=0
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Tools
#
CC=cl
AS=ml
LD=link
LB=lib
ECHO=echo
RM=rm
CP=cp
MV=mv
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Variables
#
OBJDIR = BIN
OUTEXE = $(OBJDIR)\test.exe
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Flags
#
CFLAGS=/AT /Asw /Fc /G3 /Gf /Gd /Gs /Gx- /Od /W3 /WX /Zl /Zp1 /c /f-
/nologo /D__FAR=far
/D__CDECL=cdecl $(DEBUG)
AFLAGS= /c /W3 /WX /Zp1 /nologo /Cp /DDOS /Fl $(DEBUG)
LFLAGS= /NOE /MAP /NOI /NOL /NOD /NOPACKC /ONERROR:NOEXE /stack:2048
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Rules
#
#
-----------------------------------------------------------------------
# Rule for generating object files from assembly files (replace
built-ins).
#
-----------------------------------------------------------------------
..SUFFIXES: .obj .asm .c .lrf
{.}.c{$(OBJDIR)\}.obj:
$(CC) $(CFLAGS) /Fo$(OBJDIR)\$(@B).obj $(@B).c >> $(OBJDIR)\make.err
{.}.asm{$(OBJDIR)\}.obj:
$(AS) $(AFLAGS) /Fo$(OBJDIR)\$(@B).obj $(@B).asm >>
$(OBJDIR)\make.err
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Dependencies
#
CINC=
AINC=
OBJS=$(OBJDIR)\main.obj \
$(OBJDIR)\test.obj
#
-----------------------------------------------------------------------
# create driver for DOS
#
-----------------------------------------------------------------------
all : $(OUTEXE)
$(OUTEXE): $(OBJS)
$(LD) $(LFLAGS) >> $(OBJDIR)\make.err @<
$(OBJS: = +^
)
$(OBJDIR)\test.exe
$(OBJDIR)\test.map
;
<
$(OBJS) : $(CINC) $(AINC)
# Use this command to create a Soft-Ice Map file:
clean:
$(RM) -f *.obj *.lst *.bak *.bin *.map *.cod *.lrf error.out
$(RM) -rf dos
-
Re: I can't call the function in the C file from my ASM file, why?
In article <1164767562.175971.140770@16g2000cwy.googlegroups.c om>,
wrote:
>I wrote a program consist of one ASM file and one C file. I compiled
>them with masm613
>and msvc152. But I can't call the function in the C file from my ASM
>file.
That's not a TCP-IP question; that's a question about the ABI of your
specific development environment. You should tae it to a Windows
developers newsgroup.
-
Re: I can't call the function in the C file from my ASM file, why?
Walter Roberson wrote:
> In article <1164767562.175971.140770@16g2000cwy.googlegroups.c om>,
> wrote:
>
>>I wrote a program consist of one ASM file and one C file. I compiled
>>them with masm613
>>and msvc152. But I can't call the function in the C file from my ASM
>>file.
>
> That's not a TCP-IP question; that's a question about the ABI of your
> specific development environment. You should tae it to a Windows
> developers newsgroup.
Actually, he is creating a DOS application.....
--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com
-
Re: I can't call the function in the C file from my ASM file, why?
Yes, I'm creating a DOS application. Sorry to paste it here.
>
> Actually, he is creating a DOS application.....
>
-
Re: I can't call the function in the C file from my ASM file, why?
zhangandfei@126.com wrote:
> Yes, I'm creating a DOS application. Sorry to paste it here.
> >
> > Actually, he is creating a DOS application.....
> >
Correct the spelling of ASSUME: ASSUNE CS:_TEXT
Try changing the call model of _DriverInit from NEAR to FAR and moving
the declaration up before the call.
Not sure if any of this will help.
Why are you doing this? Is this homework?
-Le Chaud Lapin-
-
Re: I can't call the function in the C file from my ASM file, why?
>
> Correct the spelling of ASSUME: ASSUNE CS:_TEXT
>
> Try changing the call model of _DriverInit from NEAR to FAR and moving
> the declaration up before the call.
>
> Not sure if any of this will help.
>
It didn't work yet. Thank you very much. I download one example
stub.mak from internet and it does work now. My new stub.mak is like
following:
DEBUG=/DDEBUG=1
#DEBUG=/DDEBUG=0
CC=cl.exe
AS=ml.exe
LD=link.exe
LB=lib.exe
RM=rm.exe
CP=cp.exe
MV=mv.exe
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Variables
#
OBJDIR = BIN
OUTEXE = $(OBJDIR)\test.exe
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Flags
#
CFLAGS= /AS /Fc /G3 /Gf /Od /Zp1 /f- /c /nologo $(DEBUG)
AFLAGS=/Cp /Fl /W3 /WX /Zf /Zp1 /c /nologo $(DEBUG)
LFLAGS=/map /nologo /onerr:noexe /stack:2048
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Rules
#
..SUFFIXES: .exe .obj .asm .c .lib .com .lrf
{.}.c{$(OBJDIR)\}.obj:
$(CC) $(CFLAGS) /Fo$(OBJDIR)\$(@B).obj $(@B).c >> $(OBJDIR)\make.err
{.}.asm{$(OBJDIR)\}.obj:
$(AS) $(AFLAGS) /Fo$(OBJDIR)\$(@B).obj $(@B).asm >>
$(OBJDIR)\make.err
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Dependencies
#
OBJS=$(OBJDIR)\main.obj \
$(OBJDIR)\test.obj
all : $(OUTEXE)
$(OUTEXE): $(OBJS)
$(LD) $(LFLAGS) >> $(OBJDIR)\make.err @<
$(OBJS: = +^
)
$(OBJDIR)\test.exe
$(OBJDIR)\test.map
;
<
main.obj : main.asm
test.obj : test.c
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
= = = =
# Cleanup
#
clean:
$(RM) -f *.obj *.lst *.bak *.bin *.map *.cod *.lrf error.out
$(RM) -rf dos
> Why are you doing this? Is this homework?
>
I'm writing a packet driver for one 10M/100M NIC. This is my part-time
job. Thanks again for your reply.
zhangandfei@126.com