Compiling and Linking

From AMC-OS Developers
Revision as of 21:38, 14 August 2012 by Kindman (talk | contribs) (→‎AMC-OS Kernel, drivers and applications)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Building everything

A Makefile is present for building everything, and should work with any available make tool (VC, TASM...). Compilation can be done in DOS or Windows without problems as soon as environment variables are set correctly. Then just type :

>SRC> make

All object files are moved in OBJ\ directory. Complete listing is written in LST\ directory. After linkage, final binary files are stored in BIN\directory.

Assembly Code

AMC-OS code written in ASM is to be compiled with Turbo Assembler v4 (TASM). It has not yet been tested with free Lazy Assembler. Typical command for compiling ASM source code is :

TASM32 /c/m5/ml/w2/la/z /I$INC $ASM,$OBJ,$LST

/c  : Compile only (no link)
/m5 : Make up to 5 passes to solve forward references
/ml : Case sensitivity on all symbols
/w2 : Set all warnings
/la : Generate expanded listing
/z  : Display source line with error message
/I  : Specified directory used as include directory

C Code

AMC-OS code written in C is to be compiled with Watcom C/C++. Typical command for compiling S source code is :

wcc386 -3r -ecd -we -wx -zl -obhkmrtl+ -zz -ms -s -i=$INC -fo=$OBJ $C

-3r  : Compile for 386 architecture
-ecd : Default calling convention to __syscall
-we  : Warning treated as errors
-wx  : Maximum warning level
-zl  : Remove default library information
-o*  : Optimization levels (optimize for speed)
-zz  : Remove @size for __stdcall function names (for compatibility with ASM)
-ms  : Small memory model (only 1 code segment and 1 data segment)
-s   : Remove stack overflow checks

Listing is then produced with OBJ2ASM tool :

OBJ2ASM -o -x $OBJ > $LST


Source OBJ files are combined together using the LIB tool (with VC, VBDOS, TASM...) which build a LIB file to simplify rebuilding and command lignes in DOS. Usage is :



AMC-OS Loader, boot sector and raw data

AMC-OS Loader, boot sector writer and raw data are linked with standard Turbo Linker (TLINK) bundled with TASM. Typical command for linking with TLINK is :

TLINK /d/m/3/s/c/C

/d : Warn if duplicate symbol
/m : Map including public names
/3 : 32-bit processing
/s : Map plus detailed segment map
/c : Case sensitive symbols
/C : Case sensitive import/export

For pure code without header (eg AMC-OS Loader, keyboard layout, ...), EXE2SYS is used to strip EXE header and generate a SYS file :


AMC-OS Kernel, drivers and applications

All other code for AMC-OS is linked with specific AMC-OS Linker which produces AMCX files.