[英]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.obj
在link.lnk
中system begin com
沒有被使用,因此OpenWatcom C庫中的啟動代碼沒有被引用。
結果 .com 文件只有 3 個字節( xor ax, eax
; ret
),我很滿意。 為了讓它真正運行,我必須准備並添加我的.obj
文件,其中包含..start:
並設置段。
我仍在尋找不需要 custom.lnk 文件的解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.