TRS-80 Model 100 library for Small-C 85
Willard Goosey
4/16/2017

Requirements:
Small-C 85 : https://github.com/ncb85/SmallC-85
ASxxxx : http://shop-pdp.net
hex2co : From Chris Osburn's personal library at club100.org
	http://club100.org/memfiles/index.php?&direction=0&order=&directory=Chris%20Osburn/RBASIC%20Support
GNU Make: Standard GNU util 
objcopy: Standard GNU binutil

I do not know how to compile any of this under Windows. From the
SmallC README: SmallC compiled for win32 can be downloaded here:
https://drive.google.com/file/d/0B2TmWnRjWCj2alRqZHM1VEgwNFE/edit?usp=sharing

Windows binaries for ASX are available at shop-pdp.net. Cygwin is
apparently required, but you'd need that for GNU make anyway...

So here it is, a minimal Model-100 runtime for Small-C on the Model
100. Real docs are in m100smallc.txt and all source is here. Also
included is minihowto.txt, a short discussion of using ASxxxx for
general Model 100 assembly.

I am aware that this is not stdio. That is... part of the point. Yes,
I miss printf() too.

I am declaring this as an ALPHA release. Among other things that means
that Linus's Law ("Don't break userspace") is NOT in effect. If later
changes break your code, well sorry about that.

Many of these functions are labeled UNTESTED, and that means exactly
what it sounds like. The wrapper functions may have bugs, might be
setting the wrong registers, and may even calling completely
incorrect ROM routines. Please send me test code!


NOTEs on Compiler Quirks:

The compiler is not mine. In fact I'm trying hard to stay OUT of the
compiler. I'm way too rusty at serious programming to be mucking around
in a compiler!

That said, SmallC-85 has some quirks. Most of them concern STRUCTs,
which aren't part of traditional Small-C.

*)Small-C has grown considerably over the years. Its preprocessor
 hasn't. Only simple "#define FOO 4" macros are supported.

*)The compiler thinks \n should be linefeed. For the M100, carriage
return would be a better fit.

*)SIZEOF() is very strange. sizeof(char) or sizeof(int) works as
 expected, but sizeof(decleared variable) returns the size multiplied
 by the pointer. ???

*)Octal and hex string escapes ("\x80 \0777") are not supported.

*)SIZEOF(struct...) not supported, and sizeof(declared struct)
 returns the size times pointer as above. 

*)Can't have struct pointers as formal arguements. 
	foo(struct baz *bar) isn't allowed.
 
*)STRUCTs are quirky in general. Smallc apparently can't handle
 multiple  structs that are defined but not globally declared. If you
 have a single struct, it can be globally defined but locally
 declared, but if you have multiple globally-defined structs there
 must be a globally declared instance of each. ????

*)In addition, globally declared structs that contain arrays or
 pointers are not allocated correctly. If declared locally, they are
 allocated correctly.

*)Can't take the address of a struct (& operator). You can, however,
 take the address of the first element. 

*)No stack-checking code is generated. On most 8080 boxes this isn't a
 huge concern but on the m100 a runaway stack could clobber user files
 and that's bad.



TO-DO

The makefile rules could use some help. Currently, to link a program
with multiple user-generated object files, the object file-> .ihx step
has to be explicitly defined. :-(

More test code needs to be done.

I do not believe the documented ROM routines for cassette I/O are
sufficient to actually USE the cassette port.

I want printf() too!




