FDOS/fdisk

Port FDISK to I16-GCC and GNU make

Closed this issue · 13 comments

Main cause of trouble porting it should be the inline assemly.

This is further complicated by the fact that I16-GCC crashes under my DosBox-X development environment.

Perhaps some of the inline asm can be replaced with library calls? @tkchia has done good job of replicating Watcom (and Borland) calls for use in gcc-ia16, see https://codeberg.org/tkchia/libi86. There are pretty simple things like _dos_open() that are essentially implemented in gcc's assembler.

tkchia commented

Hello @boeckmann,

Perhaps you can tell us a bit more about the crashes you were experiencing. Meanwhile, my build-ia16 releases page discusses some ways to work around some of gcc-ia16's error messages.

(Incidentally the Amsterdam Compiler Kit is another compiler that can compile x86-16 programs, using the tiny memory model. But nobody has got around to porting it to the DJGPP (or DOS DPMI) host yet. And, it only has support for out-of-line assembly.)

Thank you!

@tkchia yes I will do that. Give me some time finishing some other stuff. I call you back when I tried it again.

@tkchia perhaps you can give me a hint. I managed to setup I16GCC under DosBox and it is able to compile programs.

BUT: when I try to link against libi86, the lib is found but the symbols are not resolved a link time (see screenshot). Did I miss a step here?

link_error

tkchia commented

Hello @boeckmann,

Try putting -li86 after the names of the source files that use it. Thank you!

Hello @boeckmann,

Try putting -li86 after the names of the source files that use it. Thank you!

Thanks! This works.

I am making progress with the port to I16-GCC. @tkchia perhaps you can give me one more advice? I have to link the objects produced by NASM into the binary. To me it seems, that the GNU linker does not support the OMF file format.

As a general solution to the problem, which should be compiler agnostic, I would like to switch the NASM output to plain binary, convert the binaries to a C files and add them to the build process. Would you agree that this is a viable solution, or are there better ways to do it? Thanks :-)

Additional info: the files bootnorm.asm etc. contain the bootsector code. There is no ASM code that gets called by the C code. It is only memcpyd to its destination buffers before writing the boot sectors.

Status update: FDISK LITE (the command line only version) now compiles with I16-GCC. There is no Makefile yet.

During the process I replaced all inline assembly with calls to intr and friends. I also changed the build process to include the NASM output files as C code (binary output gets converted to C file). NASM output was previously OMF object files, but GNU LD did not like it.

I had not much time to test it, but already found a few bugs in the new ansicon code triggered by char being signed.

The I16-GCC build has the drawback, that the binary is significantly larger. I am not that familiar with GCC, and compiled with default settings. I am sure that with optimized build settings, this can be improved.

Roadmap

  • create a GNU Makefile (one for DOS, one for Linux)
  • compile the full version
  • reduce binary size
  • testing, testing, testing
tkchia commented

@boeckmann : you can try using -O1, -O2, or -O3 to optimize for speed — or -Os to optimize for size. Thank you!

Full version of FDISK now builds with I16-GCC (DOS). Binary size is down to 79k. Thats ~9k larger than the Open Watcom binary. All in all seems to be a little bit more responsive / faster on an emulated 8088 XT. Perhaps the binary can still be reduced by a few k.

My initial tests indicate, that the build is mostly functional. I found one bug regarding the translation file, which does not get loaded. Maybe this has to do with the environment search functions. Nothing that shouldn't be fixable.

I was able to build FDISK with IA16-GCC from my Mac.

I made a note with the required changess to successfully build IA16-GCC on MacOS: https://github.com/tkchia/build-ia16/issues/28

The software is now ported to I16-GCC. I updated the build instructions accordingly. The Makefile.gcc is currently targeted at Mac, should work under Linux (if anyone can test?). I close this issue. Should problems arise feel free to open an issue.