This is a version Small-C originally tailored to CP/M-86. I've modified it to emit NASM syntax assembler. I've designated it as CodeSet 3. Notibly, this version delineates Code and Data, expands the lval[3] expression array by another element, and modifies the parser accordingly. Reference more notes in the sources. Note that this version uses BX as the primary register, and DX as the secondary register in regards to the stack machine for expression evaluation. DI is used heavily for DS dereferencing, and SP, BP, see heavy use as you might expect, AX sees use for certain operations; CBW, and is the Value Returned Register, i.e., return(n); -> n is returned in AX. Therefore, C5LIBT.C is the modified version of the minimal I/O Library to match this register usage. This version employs name mangling, prepending cz to function names & certain identifiers (which I haven't changed), cc for generated Labels (Which I have changed to 'L_') and cs for Stack Frame Size Constants (which I have changed to AutoC, to pique my memory that these are auto class Constants to calc the relative dereferencing of auto variables on the stack frame). Purportedly, it also mangles long identifiers into 'first seven characters, then last seven characters'. I suspect I don't quite understand what is going on here, because the length of a symbol for the symbol table is 9 characters. The source self-compiles, so it is hard to argue the point. There were a number of identifier names that initially clashed with NASM, such as 'test', and other assembler instruction names, and ch for chr for another example. So anyway, C86NC5C.NSM is its own example of the code generated.

Small-C source, C86NC5C.C

The C5LIBT.C I/O Library to be %included.


NASM makefile for this project, c86nc5c.mak outputs C86NC5C.BIN Rename to C86NC5C.COM

The self-compiled output, C86NC5C.NSM ready to make. Note how the generated code differs from the other CodeSets.

NASM leading bookend code, PROLOG.NSM to C86NC5C.NSM, NASM will %include it.

NASM trailing bookend code, EPILOG.NSM to C86NC5C.NSM, NASM will %include it.


Note that if Nasm can't open an %include file, it will hang waiting. The 'NASM version 0.98.38 compiled on Sep 12 2003' was used for these projects. The dos version was used under Win XP's CMD.EXE, see 'workspace enviornment' for how CMD.EXE was utilized. Be aware that most 32-bit instructions are available in the CMD.EXE VM. Enjoy!

8:25 PM 2/6/2010