我想生成一个 16 位可执行的 BINARY RAW 格式Watcom C compiler
。类似于在实模式下运行的没有任何标题的 EXE 文件。
我使用Large
内存模型,因此代码段和数据段可能不同,可以增加超过 64K 字节。
我喜欢这样:
// kernel.c
void kernel(void)
{
/* Print Hello! */
__asm
{
mov ah, 0x0E;
mov bl, 7
mov al, 'H'
int 0x10
mov al, 'e'
int 0x10
mov al, 'l'
int 0x10
mov al, 'l'
int 0x10
mov al, 'o'
int 0x10
mov al, '!'
int 0x10
}
return;
}
为了编译上面的代码,我在批处理文件下面运行:
@rem build.bat
@rem Cleaning.
del *.obj
del *.bin
cls
@rem Compiling.
@rem 0: 8088 and 8086 instructions.
@rem d0: No debugging information.
@rem ml: The "large" memory model (big code, big data) is selected.
@rem s: Remove stack overflow checks.
@rem wx: Set the warning level to its maximum setting.
@rem zl: Suppress generation of library file names and references in object file.
wcc -0 -d0 -ml -s -wx -zl kernel.c
@rem Linking.
@rem FILE: Specify the object files.
@rem FORMAT: Specify the format of the executable file.
@rem NAME: Name for the executable file.
@rem OPTION: Specify options.
@rem Note startup function (kernel_) implemented in kernel.c.
wlink FILE kernel.obj FORMAT RAW BIN NAME kernel.bin OPTION NODEFAULTLIBS, START=kernel_
del *.obj
运行build.bat
Watcom 编译器和链接器生成的以下消息后:
D:\Amir-OS\ckernel>wcc -0 -d0 -ml -s -wx -zl kernel.c
Open Watcom C16 Optimizing Compiler Version 1.9
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
kernel.c: 28 lines, included 35, 0 warnings, 0 errors
Code size: 39
D:\Amir-OS\ckernel>wlink FILE kernel.obj FORMAT RAW BIN NAME kernel.bin OPTION N
ODEFAULTLIBS, START=kernel_
Open Watcom Linker Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
loading object files
Warning! W1014: stack segment not found
creating a RAW Binary Image executable
输出文件成功生成。
但我的问题是:
如何解决W1014
警告?
有没有办法指定初始 CS 值?