繁体   English   中英

如何使用 OpenWatcom `owcc` 创建 DOS.com 文件,但没有 OpenWatcom libc?

[英]How to create DOS .com file with OpenWatcom `owcc`, but without the OpenWatcom libc?

这是一个简短的 C 文件cu.c

int main(int argc, char **argv) {
  (void)argc; (void)argv;
  return 0;
}

当我使用 OpenWatcom 将其编译为 DOS.com 文件时,结果几乎是 3 KiB:

$ owcc -bcom -mcmodel=t -fno-stack-check -Os -s -march=i86 -W -Wall -Wextra -o cu.com cu.c
$ ls -l cu.com
-rwxr-x--- 1 pts pts 2938 Jun 20 19:26 cu.com

执行相同操作(只是退出)的最小可能 DOS.com 文件是 1 字节长:它包含单个ret指令(字节 0xc3)。

How can I compile my cu.c file (with possibly some modifications, I don't care about argc or argv) to a smaller DOS.com file, without the OpenWatcom C library (libc), preferably less than 100 bytes? 我将直接从我的程序中调用 DOS API 函数( int 0x21 ),因此我不需要任何 OpenWatcom C 库函数。

请注意, 带有 Open Watcom 的 COM 可执行文件不能回答我的问题,因为那里提供的解决方案都包括 OpenWatcom C 库。

我能够通过在我的 custom.lnk 文件中使用format dos com而不是system com来解决它。 通过这样做,系统中的lib文件libfile cstart_t.objlink.lnksystem begin com没有被使用,因此OpenWatcom C库中的启动代码没有被引用。

结果 .com 文件只有 3 个字节( xor ax, eax ; ret ),我很满意。 为了让它真正运行,我必须准备并添加我的.obj文件,其中包含..start:并设置段。

我仍在寻找不需要 custom.lnk 文件的解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM