Questions tagged [watcom]

Open-source C/C++ and Fortran compilers for multiple 16- and 32-bit x86 target platforms.

The Watcom compiler line originated with University of Waterloo Fortran, or WATFOR, in the 1960s, widely used at universities. WATCOM was spun off into a private company and eventually the products were open-sourced.

65 questions
2
votes
1 answer

How can I enable C99 in OpenWatcom 1.9?

I have an old project targeting DOS (yes, really) which I need to update and re-compile. The project is using the Open Watcom 1.9 C / C++ compilers and the JWasm assembler. Under no circumstances I can use other compilers or assemblers, because that…
Binarus
  • 4,005
  • 3
  • 25
  • 41
2
votes
1 answer

Extra push in OpenWatcom inline assembly

I'm compiling this C source with OpenWatcom V2 wcc: /* Writes a '\0'-terminated string to the file descriptor. */ static void fdputs(int fd, const char *s); #pragma aux fdputs = \ "push si" \ "mov cx, -1" \ "repz scasb" \ "neg cx" \ "inc cx" /* now…
pts
  • 80,836
  • 20
  • 110
  • 183
2
votes
1 answer

How to make sure interrupt can not be generated between specific Code Snippet?

I have one question about the timing of interrupt generation between code snippets... @ "example" code 1. ... 2. assign value to global variable // 0/1 means invalid/valid 3. set H/W register via memory-mapped IO method // 0 means completed @…
liaoo
  • 193
  • 2
  • 15
2
votes
1 answer

"Daylight Savings Time" in DOS

I am using the time(NULL) function in a C application to get the seconds since 1970. I've noticed that it is returning the information with 1 hour of difference. then I tried to convert the result to a tmstructure using localtime, and then I noticed…
Renan Greinert
  • 3,376
  • 3
  • 19
  • 29
2
votes
1 answer

Watcom inline assembly docs

Searching for manuals and docs about Open Watcom linker, inline assembly and C compiler, as I found official manuals not good enough. I'm focused especially on C and assembly. I would appreciate you for links to tutorials, books and etc.
hrust
  • 734
  • 1
  • 11
  • 34
1
vote
1 answer

Linking a simple DOS program (ASM), WLINK warns about no stack segment

I'm trying to assemble and link the following program (.EXE, not .COM), based on the example in the NASM manual: segment data hello: db "hello",13,10,"$" segment code ..start: mov ax,data mov ds,ax mov ax,stack mov…
Jack Kelly
  • 18,264
  • 2
  • 56
  • 81
1
vote
0 answers

How to change the default symbol mapping for variables in OpenWatcom?

https://open-watcom.github.io/open-watcom-v2-wikidocs/cguide.html explains #pragma aux default to specify default symbol name generation. For example: /* prog.c */ #pragma aux default "__*__" extern int mysym1; extern int mysym2(int x); int…
pts
  • 80,836
  • 20
  • 110
  • 183
1
vote
1 answer

Does OpenWatcom support an equivalent to ELF weak symbols?

I have two C source files: /* w1.c */ #include __attribute__((weak)) void fw(void) { printf("FW1\n"); } int main(int argc, char **argv) { (void)argc; (void)argv; fw(); return 0; } /* w2.c */ #include void fw(void) {…
pts
  • 80,836
  • 20
  • 110
  • 183
1
vote
0 answers

Hello world in 32 bits DOS assembly

I'm trying to get started in 32 bits DOS assembly programming. I've started with a simple "hello, world" program that runs great in 16 bits mode (taken from Turbo Assembler manual), and just added a couple of directives: .386 .model flat,…
airman
  • 564
  • 1
  • 4
  • 16
1
vote
1 answer

Poor C optimization in Watcom

I am using Watcom C compiler (wcc) version 2.0. I compile this simple code with many optimizations enabled, but the resulting ASM seems very unoptimized to me. int test(int x) { return x ? 1 : 2; } Compiling with 8086 as target, fastest…
Roman Hocke
  • 4,137
  • 1
  • 20
  • 34
1
vote
1 answer

Detect which function to call based on argument type in OpenWatcom C language

I have 2 implementations of the same function based on the pointer size in the argument: /* Writes a $-delimited string to stdout. */ static inline void _printmsgx(const char *msg); #pragma aux _printmsgx = "mov ah, 9" "int 0x21" parm [ dx ]…
pts
  • 80,836
  • 20
  • 110
  • 183
1
vote
1 answer

Small model DOS .exe compiled and linked by OpenWatcom crashes

I'm trying to create a small DOS .exe program. I wrote the entry point in NASM assembly ; st.nasm global _small_code_ global _printmsg_ extern _main0_ segment code _small_code_: ..start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp,…
pts
  • 80,836
  • 20
  • 110
  • 183
1
vote
3 answers

Where to find the reference of dos.h for the c programming language?

I'm looking for the reference/documentation of the dos.h API. (especially for an openwatcom specific version). Where to get the documentation?
MRalwasser
  • 15,605
  • 15
  • 101
  • 147
1
vote
1 answer

C source code, Watcom Compiler and EMU8086

How can I get the Watcom compiler (the forked version 2.0 beta which runs on 64-bit hosts) to output 8086 assembly source code in an ASM file? Running wcc -0 main.c from the command prompt produces just the OBJ file. As a side note, my main task it…
melanie93
  • 149
  • 10
1
vote
0 answers

Compile a 16-bit Windows DLL with Open Watcom

I'm trying to compile a 16-bit Windows DLL for this for this question on the reverseengineering stackexchange. Below is my absolute minimum source files: mydll.c int main (int reason) { return 0; } mydll.lnk FORMAT WINDOWS DLL LIBPATH…
Linus Unnebäck
  • 23,234
  • 15
  • 74
  • 89