简体   繁体   中英

Compiling and linking to binary simple real mode OS in C with OpenWatcom

I have a simple (extreme simple) real mode kernel written in assembly that I am trying to port to C as much as I can. In order to do that I am using OpenWatcom compiler for 16bit binary code.

In my file "os.c", if I write this line down it works:

char msg[50];

but if I do this:

char msg[50] = "hello";

it just does not work. Everytime I write a string it just get broken. I searched everywhere, tried a lot of nonsense stuff, and nothing.

Does anyone have a clue what it might be?

I can not post more than 2 links, so all 4 links needed is in pastebin. Thanks in advance.

Example: http://pastebin.com/xz96N91A

I have installed openwatcom so I could see what it gives. Apparently it's all a big mess, the data section seems to be applied in the middle of the code and such.

I recommend you instead create a COM format file. That at least appears to work. I used the command wcl -s -zls -0 -q -ms -bcl=com os.c to create os.com which I used in place of your os.bin . I have also updated the far jump in the loader to jmp far 0x0040:0x0100 to account for the com entry point. Might need to set up some segment registers too, but for this test it worked without that.

I believe COM files had a limit of 64k, no idea if watcom enforces that. If it does, and you need more than 64k, you will have to investigate more.

Unless you are really forced to use real mode, you should probably not waste your time on it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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