Monday, August 30, 2010

So I've finished up the string.h functions, and I'm piecing together the printf forms (again). Sadly, this will be the third time I've done this.

I've also found another problem with the string constants. Embedded quotes cause problem with the assembler. Here's some notes from the E/A manual about character constants:

'A' -> 0x41
'AB' -> 0x4142
'''D' -> 0x2744

Text strings are contained within single quotes, single quotes escaped by duplication.

I want to support TI-style quotes, and make the compiler use those, but allow the assembler to use TI or C style strings.

Sunday, August 22, 2010

I've been busy since the last update working on libc functions. I think I'm about 20% to 30% done with that so far. Sadly, I've found two more problems in the compiler.

The first was a missing comma in the 16-bit "+=4" optimization. That was just a dumb mistake, easily fixed.

The second was a bit trickier. When using constant strings, it was possible to cause a code misalignment, resulting in a non-working image. The problem here was that the ASM_OUTPUT_ALIGN macro, which I copied from some other archetecture, was no good for the TMS9900. I needed two-byte alignemts, but the macro ignored all alignments less than four. This effectively turned off all code alignment, which caused this problem. All working now. Yay!

Monday, August 16, 2010

Control code handling for screen output is complete. Now, all control codes are silently handled as part of screen_write_string. There is an easy way to add a hook later for raw vs. cooked screen mode. That would allow selective handlaing of control code processing. I've also managed to squeeze out 26 bytes from that function. Nothing exciting, but it makes me happy, and I suppose every byte counts.

The plan from here is to get printf finished, and move on to other stuff.

Thursday, August 12, 2010

OK, I'm officially done with DIV stuff, but I've learned a few things while working on this. I tried everything I could think of to try to get the register location to work properly on argument 1 and the outputs. No luck. Every attempt using subregs, or direct register assignment resulted in working code, but seperate blocks for DIV and MOD. Apparently, the optimizer is not smart enough to deal with this properly. If any modification is done to argument 1, the blocks get split again. Also, I can't find a way to specify one argument as a subreg of another argument.

So, in order to make the best of this situation, I'm using a form which does not tie output registers to argument one. This allows the optimizer to group DIV and MOD operations with common terms. On the other hand, this allows the outputs to be located in inconvenient registers. Code has been added to move the results to the registers selected by the compiler. In the worst case, the DIV and MOD results are in the opposite registers (MOD result rgister chosen to hold DIV, and vice versa). This case is handled by swapping values using XOR, which eliminates the need for a temp register, but is no faster than just using MOVs. In a perfect world, this work would be unnecessary, but this is better than having seperate DIV and MOD blocks. With careful ordering in the C code, the compiler can be encouraged to use the correct registers, omitting all the extra MOVs.

So now, unless something else pops up, I can put the compiler to rest, and continue with the LIBC code.

Sunday, August 8, 2010

It's taken way, way too long, but I've finally got some optimization for the DIV instruction. There's the possibility for two extra MOVs which might be optimized away, but this is way better than seperate DIV and MOD calculations. Now that I've finally got this working, I can move on to something else.

Somehow there are ".comm" directives in the output. This must be fixed.