Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asmpkt.asm vs asmpkt.nas question #118

Closed
Lethja opened this issue Jul 29, 2024 · 4 comments
Closed

asmpkt.asm vs asmpkt.nas question #118

Lethja opened this issue Jul 29, 2024 · 4 comments

Comments

@Lethja
Copy link

Lethja commented Jul 29, 2024

While reading watcom_f.mak I noticed this snippet of code

#
# This generated file is used for all 32-bit MSDOS targets
# (and when USE_FAST_PKT is defined). This enables a faster real-mode
# callback for the PKTDRVR receiver. Included as an array in pcpkt2.c.
#
PKT_STUB = pkt_stub.h

...

$(OBJPATH)pcpkt.obj: asmpkt.nas

$(PKT_STUB): asmpkt.nas
	$(W32_NASM) -f bin -l asmpkt.lst -o asmpkt.bin asmpkt.nas
	$(W32_BIN2C) asmpkt.bin > $@

Which shares a name with another assembly file earlier in the makefile

ASM_SOURCE = asmpkt.asm cpumodel.asm

Judging from the comments in both files it sounds like asmpkt.nas is an optional 32-bit DOS feature but requires nasm to build?

@gvanem
Copy link
Owner

gvanem commented Jul 30, 2024

asmpkt.nas is an optional 32-bit DOS feature but requires nasm to build?

Yes and on Windows, set W32_NASM=..\util\win32\nasm.exe is done by configur.bat.

It's a bit complicated:

  • asmpkt.asm is the upcall-handler for the PKTDRVR done via the pkt_enque_ptr function pointer.
    Used for real-mode (small/large) with no USE_FAST_PKT defined. And linked in directly.
  • asmpkt.nas is the upcall-handler for the PKTDRVR done by pkt_get_buffer() function.
    Used for all targets with USE_FAST_PKT defined. And used indirectly via real_stub_array[] in pcpkt2.c.

@Lethja
Copy link
Author

Lethja commented Jul 30, 2024

  • Used for all targets with USE_FAST_PKT defined.

PKT_STUB isn't defined in 16-bit or Win32 Watcom makefiles at all

--- WATCOM_L.MAK	2024-07-27 13:42:20.000000000 +1000
+++ WATCOM_F.MAK	2024-07-27 13:42:20.000000000 +1000
@@ -133,7 +133,6 @@
 #
 
 DOS_OBJS = &
-           $(OBJPATH)asmpkt.obj   &
            $(OBJPATH)country.obj  &
            $(OBJPATH)fsext.obj    &
            $(OBJPATH)pcpkt32.obj  &
@@ -157,6 +156,12 @@
 #
 OBJS = $(COMMON_OBJS) $(DOS_OBJS)
 
+#
+# This generated file is used for all 32-bit MSDOS targets
+# (and when USE_FAST_PKT is defined). This enables a faster real-mode
+# callback for the PKTDRVR receiver. Included as an array in pcpkt2.c.
+#
+PKT_STUB = pkt_stub.h
 
 ########################################################################
 
@@ -182,12 +187,12 @@
 AS = *wasm
 AR = *wlib
 
-CC       = *wcc
-CFLAGS   = -bt=dos -ml -0 -os -s -zc -zm -zlf -DWATT32_STATIC
-AFLAGS   = -bt=dos
-STAT_LIB = $(LIBPATH)wattcpwl.lib
-OBJDIR   = $(OBJROOT)large
-I_CFLAGS = -I"$(%WATCOM)/h"
+CC       = *wcc386
+CFLAGS   = -bt=dos -mf -3r -zff -zgf -oilrtfm -s -zlf -DWATT32_STATIC
+AFLAGS   = -bt=dos -3r -dDOSX -dDOS4GW
+STAT_LIB = $(LIBPATH)wattcpwf.lib
+OBJDIR   = $(OBJROOT)flat
+I_CFLAGS = -I"$(%WATCOM)/h" # -I"$(%PHARLAP)/include"
 
 
 LIB_ARGS  = $(OBJPATH)wlib.arg
@@ -308,6 +313,12 @@
 	@%append $^@ const char *w32_cc     = "$(CC)";
 
 
+$(OBJPATH)pcpkt.obj: asmpkt.nas
+
+$(PKT_STUB): asmpkt.nas
+	$(W32_NASM) -f bin -l asmpkt.lst -o asmpkt.bin asmpkt.nas
+	$(W32_BIN2C) asmpkt.bin > $@
+
--- WATCOM_F.MAK	2024-07-27 13:42:20.000000000 +1000
+++ WATCOM_W.MAK	2024-07-27 13:42:20.000000000 +1000
@@ -152,16 +152,13 @@
 SUFFIX =
 
 #
-# For all 16/32-bit DOS targets:
+# For all 32/64-bit Windows targets:
 #
-OBJS = $(COMMON_OBJS) $(DOS_OBJS)
+OBJS = $(COMMON_OBJS) $(WINDOWS_OBJS)
+
+
+
 
-#
-# This generated file is used for all 32-bit MSDOS targets
-# (and when USE_FAST_PKT is defined). This enables a faster real-mode
-# callback for the PKTDRVR receiver. Included as an array in pcpkt2.c.
-#
-PKT_STUB = pkt_stub.h
 
 ########################################################################
 
@@ -188,11 +185,15 @@
 AR = *wlib
 
 CC       = *wcc386
-CFLAGS   = -bt=dos -mf -3r -zff -zgf -oilrtfm -s -zlf -DWATT32_STATIC
-AFLAGS   = -bt=dos -3r -dDOSX -dDOS4GW
-STAT_LIB = $(LIBPATH)wattcpwf.lib
-OBJDIR   = $(OBJROOT)flat
-I_CFLAGS = -I"$(%WATCOM)/h" # -I"$(%PHARLAP)/include"
+CFLAGS   = -bt=nt -mf -3r -fp6 -oilrtfm -s -bm -zri -zlf
+AFLAGS   = -bt=nt -3s -dDOSX
+LDFLAGS  = system nt_dll
+STAT_LIB = $(LIBPATH)wattcpww.lib
+IMP_LIB  = $(LIBPATH)wattcpww_imp.lib
+WATT_DLL = $(DLLPATH)watt-32.dll
+OBJDIR   = $(OBJROOT)win32
+RESOURCE = $(OBJPATH)watt-32.res
+I_CFLAGS = -I"$(%WATCOM)/h" -I"$(%WATCOM)/h/nt"
 
 
 LIB_ARGS  = $(OBJPATH)wlib.arg
@@ -254,11 +255,16 @@
 #     s:      favour code size over execution time
 #
 
-TARGETS = $(STAT_LIB)
+TARGETS = $(STAT_LIB) $(IMP_LIB) $(WATT_DLL)
 
 all: $(PKT_STUB) $(OBJPATH)cflags.h $(OBJPATH)cflagsbf.h $(TARGETS) .SYMBOLIC
 	@echo All done
 
+$(IMP_LIB): $(WATT_DLL)
+	@%null
+
+$(WATT_DLL): $(OBJS) $(RESOURCE) $(LINK_ARGS)
+	*wlink $(LDFLAGS) name $^@ @$(LINK_ARGS)
 
 $(STAT_LIB): $(OBJS) $(LIB_ARGS)
 	$(AR) -q -b -c -pa -z=export.tmp $^@ @$(LIB_ARGS)
@@ -281,6 +287,14 @@
 	%create $^@
 	@for %f in ($(OBJS)) do @%append $^@ +- %f
 
+$(LINK_ARGS): $(__MAKEFILES__)
+	%create $^@
+	@%append $^@ option quiet, verbose
+	@%append $^@ debug all
+	@%append $^@ opt map=$(WATT_DLL:.dll=.map)
+	@%append $^@ opt implib=$(IMP_LIB), res=$(RESOURCE)
+	@%append $^@ reference __DLLstart_
+	@for %f in ($(OBJS)) do @%append $^@ file %f
 
 clean: .SYMBOLIC
 	@if exist $(OBJPATH)*.obj $(RM) $(OBJPATH)*.obj
@@ -293,6 +307,11 @@
 !ifdef PKT_STUB
 	@if exist $(PKT_STUB) $(RM) $(PKT_STUB)
 !endif
+	@if exist $(LINK_ARGS) $(RM) $(LINK_ARGS)
+	@if exist $(WATT_DLL)  $(RM) $(WATT_DLL)
+	@if exist $(IMP_LIB)   $(RM) $(IMP_LIB)
+	@if exist $(RESOURCE)  $(RM) $(RESOURCE)
+	@if exist $(WATT_DLL:.dll=.map) $(RM) $(WATT_DLL:.dll=.map)
 	@echo Cleaning done
 
 ########################################################################
@@ -313,12 +332,11 @@
 	@%append $^@ const char *w32_cc     = "$(CC)";
 
 
-$(OBJPATH)pcpkt.obj: asmpkt.nas
 
-$(PKT_STUB): asmpkt.nas
-	$(W32_NASM) -f bin -l asmpkt.lst -o asmpkt.bin asmpkt.nas
-	$(W32_BIN2C) asmpkt.bin > $@
+DEBUGRC = 0
 
+$(RESOURCE): watt-32.rc
+	*wrc -q -bt=nt -dDEBUG=0 -D__WATCOMC__ -r -zm -fo=$^@ $<

Are these shortcomings in the existing Watcom makefile generation?

@gvanem
Copy link
Owner

gvanem commented Jul 31, 2024

PKT_STUB isn't defined in 16-bit or Win32 Watcom makefiles at all

I'm a bit rusty on the details now, but....

  • For Win32, there is no PKTDRVR (but WinPcap, NPcap instead). So yes; no PKT_STUB is not needed for Win32.
  • For 16-bit real-mode (DOSX == 0), I guess USE_FAST_PKT is not possible. Ref the comment in config.h:
    #undef USE_FAST_PKT /* Use faster all real-mode PKTDRVR receiver (DOSX only) */

Besides, some code has references to a now defunct asmpkt4.asm file used for DOS4GW extenders.
It (and other stuff) should be cleaned up.

@Lethja
Copy link
Author

Lethja commented Jul 31, 2024

It (and other stuff) should be cleaned up.

That sounds like a big job for the future. For the time being I'll implement PKT_STUB in any makefile that currently has it in #114. The check for nasm has already been implemented here. In the event that nasm isn't found by configur.lua PKT_STUB will still be written to the makefile but commented out. This way a user can manually edit their makefile later if they want to enable USE_FAST_PKT without running the configur.lua script again.

@Lethja Lethja closed this as completed Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants