Skip to content

Commit 3c13a5c

Browse files
committed
support building with OW (not yet functional)
1 parent a31a793 commit 3c13a5c

File tree

3 files changed

+65
-15
lines changed

3 files changed

+65
-15
lines changed

build.bat

+22-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ ECHO.
1818
ECHO Note: ensure UPX is in your path, optionally make in C:\bin
1919
goto end
2020

21+
:clean
22+
%MAKE% -C src RM=del clean
23+
goto end
24+
25+
:clobber
26+
%MAKE% -C src RM=del clobber
27+
goto end
28+
2129
:tcc2
2230
rem ############# Turbo C 2.01 ########################
2331
IF [%BASEPATH%]==[] set BASEPATH=C:\tc201
@@ -33,17 +41,25 @@ goto tcshared
3341

3442
:tcshared
3543
rem ############# TURBO_C shared ########################
36-
set LIBS=%BASEPATH%\lib
37-
set INCLUDE=%BASEPATH%/include
3844
set CC=tcc
3945
set LD=tlink
40-
set LDFLAGS=/m /s /c /t $(LIBS)\c0t.obj $(EXTRA_OBJS) share.obj,share.com,,$(LIBS)\cs.lib
41-
set CFLAGS=-I../kitten -I../tnyprntf -I%INCLUDE% -mt -1 -c -o
46+
set LDFLAGS=/m /s /c /t %BASEPATH%\lib\c0t.obj $(EXTRA_OBJS) share.obj,share.com,,%BASEPATH%\lib\cs.lib
47+
set CFLAGS=-I../kitten -I../tnyprntf -I%BASEPATH%/include -mt -1 -c -o
48+
set EXTRA_OBJS=
4249
goto doit
4350

44-
:doit
45-
set EXTRA_OBJS=
51+
:ow
52+
IF [%BASEPATH%]==[] set BASEPATH=D:\ow19
53+
set CC=wcc
54+
set LD=wlink
55+
56+
set LDFLAGS=system com name share.com file share,kitten,tnyprntf,amishelp option quiet,map,statics,verbose,artificial,symfile
57+
set CFLAGS=-I..\kitten -I..\tnyprntf -q -0 -ms -btdos -os -fo=
58+
set EXTRA_OBJS=amishelp.obj
59+
goto doit
4660

61+
62+
:doit
4763
set EXTRA_OBJS=%EXTRA_OBJS% kitten.obj
4864
rem # if you want to build without kitten comment the above and uncomment
4965
rem the following
@@ -70,8 +86,6 @@ rem cleanup
7086
set PATH=%OLD_PATH%
7187
set MAKE=
7288
set BASEPATH=
73-
set INCLUDE=
74-
set LIBS=
7589
set CC=
7690
set CFLAGS=
7791
set LD=

src/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ else
2828
amishelp.obj: amishelp.asm
2929
nasm -f obj -I ../lmacros/ -I lmacros/ $< -o $@
3030

31-
kitten.obj: ../kitten/kitten.c
31+
kitten.obj: ..\kitten\kitten.c
3232
$(CC) $(CFLAGS)$@ $^
3333

34-
tnyprntf.obj: ../tnyprntf/tnyprntf.c
34+
tnyprntf.obj: ..\tnyprntf\tnyprntf.c
3535
$(CC) $(CFLAGS)$@ $^
3636
endif
3737

src/share.c

+41-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/* freemem, keep */
1212
#include <string.h> /* strchr, strlen, memset */
1313

14-
#ifdef __TURBOC__
14+
#if defined(__TURBOC__) || (__WATCOMC__)
1515
#include <io.h> /* write (what else?) */
1616
#include <stdlib.h> /* _psp, NULL, malloc, free, atol */
1717
#define NON_RES_TEXT
@@ -21,6 +21,16 @@
2121
typedef unsigned char uint8_t;
2222
typedef unsigned short uint16_t;
2323

24+
#if (__WATCOMC__)
25+
//void far * getvect(unsigned char intno);
26+
//void setvect(unsigned char intno, void far * vector);
27+
#define getvect(x) _dos_getvect(x)
28+
#define setvect(x, y) _dos_setvect(x, y)
29+
#define freemem(x) _dos_freemem(x)
30+
#define keep(x, y) _dos_keep(x, y)
31+
#define __attribute__(x)
32+
#endif
33+
2434
#elif defined(__GNUC__)
2535
#include <libi86/stdlib.h>
2636
#include <unistd.h>
@@ -156,7 +166,31 @@ typedef struct {
156166

157167
/* ------------- GLOBALS ------------- */
158168
static char progname[9] NON_RES_BSS;
159-
#if defined(__GNUC__)
169+
#if defined (__WATCOMC__)
170+
#pragma aux file_table_size "*"
171+
#pragma aux file_table_size_bytes "*"
172+
#pragma aux file_table_free "*"
173+
#pragma aux file_table_offset "*"
174+
#pragma aux lock_table_size "*"
175+
#pragma aux lock_table_size_bytes "*"
176+
#pragma aux lock_table_free "*"
177+
#pragma aux lock_table_offset "*"
178+
#pragma aux iregs "*"
179+
180+
#pragma aux need_to_chain "*"
181+
182+
#pragma aux old_handler2f "*"
183+
#pragma aux handler2f "*"
184+
185+
/* same as __cdecl except don't preceed with _ underscore */
186+
#pragma aux __gcc16 "*" \
187+
__parm __caller [] \
188+
__value __struct __float __struct __routine [__ax] \
189+
__modify [__ax __bx __cx __dx __es]
190+
#pragma aux (__gcc16) inner_handler
191+
192+
#endif
193+
#if defined(__GNUC__) || defined(__WATCOMC__)
160194
extern uint16_t file_table_size; /* # of file_t we can have */
161195
extern uint16_t file_table_size_bytes; /* amount bytes */
162196
extern uint16_t file_table_free;
@@ -259,7 +293,7 @@ static void interrupt far handler2f(intregs_t iregs) {
259293
/* would have been better to link a NASM handler core: */
260294
/* nasm -fobj -o foo.obj foo.asm ... */
261295

262-
#elif defined(__GNUC__)
296+
#elif defined(__GNUC__) || defined(__WATCOMC__)
263297
/* Within IBM Interrupt Sharing Protocol header */
264298
extern void __far __interrupt (*i2D_next)(void);
265299
/* Prototype for NASM interrupt handler function */
@@ -356,7 +390,7 @@ void inner_handler(void) {
356390
/* Chain to the next handler. */
357391
#if defined(__TURBOC__)
358392
chain_old_handler2f;
359-
#elif defined(__GNUC__)
393+
#elif defined(__GNUC__) || defined(__WATCOMC__)
360394
need_to_chain = 1;
361395
#endif
362396
}
@@ -1169,7 +1203,9 @@ int main(int argc, char **argv) {
11691203
void (near *isr)() = FP_OFF(handler2f);
11701204
setvect(MUX_INT_NO,(void (interrupt far *)())MK_FP(_DS,isr));
11711205
}
1172-
#else /* causes relocations when built with Turbo C/C++ 3 */
1206+
#elif defined(__WATCOMC__)
1207+
setvect(MUX_INT_NO,handler2f); // TODO get handler2f without relocation
1208+
#else /* causes relocations when built with Turbo C/C++ 3 and OW */
11731209
setvect(MUX_INT_NO,handler2f);
11741210
#endif
11751211
/* enable(); */

0 commit comments

Comments
 (0)