Saturday, November 21, 2009

I found a bug in the compiler. There is an overflow problem in the displacement calculation for jmp instructions. I found a case where I have a "jmp -310" which is not caught by the linker. This case compiles to 1064 -> "jmp 200".

6484: 10 64 jmp 200 # jmp print_final
Destination: 0000634e :

So this should be jmp -0x136 (-310) which is too big...
-0x136/2 = -0x9B = -155 =0xFF65

This seems to be fixed by making changs to binutils/bfc/elf32-tms99900.c. I'm now using "complain_overflow_signed" for these relocations.

Friday, November 20, 2009

It's been a while since I've had a chance to work on this project, so I took a while to get up to speed on wheere I left things last. This log has been a huge help and it's ben good to go back through it. One thing that's been missing in earlier updates has been the lack of details. These help better describe the day-to-day development.

I decided to basially rework a big chunk of stdio.asm, specifically the *print*_* routines. The original code was compact, but inflexible. and making extensions for formatted output was completely screwed up. Adding 32-bit support was impossible as well.

The hex routines seemed a good place to start. 32-bit hex conversion is now complete, and a new strlen routine is working. I've started putting together the framework for formatted output (for exmaple "%08X" or "%-12d"). It's incomplete and sketcky right now, but it should be ok.

I think there may still a problem with signed 32-bit support for the math.asm routines, but I haven't looked into it yet. Signed division is a big question, it's not obvious how that should work.