I've now hit the annoying part of the GCC port. I'm pretty much done with everything except word-to-byte conversions, multiply, divide and elimination of the frame pointer register. I'm afraid I might have to do a lot of trial-and-error since I haven't found a template I can use for the remaining instructions.
I'm currently working on the word-to-byte conversion. GCC wants to use a "subreg" expression to do this, and eventually uses "movqi" regardless of the other, more exact instruction matches. There is a "truncMN2" format which should be used for this, but it's not being used. Poop.
Monday, February 22, 2010
Sunday, February 14, 2010
I have most of the 16 and 8 bit operations working now. I'm missing mul, div, type conversion, move and set. But it looks pretty good.
I've started looking at 32-bit operations, and that is not going smoothly. The compiler bails at init_move_cost.
UPDATE:
That was caused by not respecting the difference between Rn, *Rn, and @x(Rn). The instruction was assuming a Rn, when a *Rn was actually called for. I need to update all "o" condtions with "R" and "Q" and respect the consequences of each.
I've started looking at 32-bit operations, and that is not going smoothly. The compiler bails at init_move_cost.
UPDATE:
That was caused by not respecting the difference between Rn, *Rn, and @x(Rn). The instruction was assuming a Rn, when a *Rn was actually called for. I need to update all "o" condtions with "R" and "Q" and respect the consequences of each.
Sunday, February 7, 2010
Since I last updated the worklog, I've been working on a GCC port for the TMS9900. I made up my mind on this after I realized the ton of work required to maintain the source code if it all stays as assembly. Additionally, if I fool myself into thinking anyone else would be interested in using this thing when I'm done, C programming would be much more inviting.
So here's where I'm at right now:
I've got GCC sort of ported at the moment, the TMS9900 is a valid target, the call interface is working, as are the shift instructions. I'm currently working on the conditional jumps.
Out of curiosity, I looked at Tursi's port, and it looks like he just used the PDP11 stuff, but changed the opcode names. Works OK I suppose, but suboptimal.
I used concepts from the ARM, M68HC11 and PDP11 implementations, since I wasn't sure where to start. As a result, I've had a heck of a time with the call interface, since the pieces I used didn't play well together. Tracking down the bugs is challenging, since there is a lot going on and it's still not clear to me how all the machine-specific parts get used.
I want to have parameters passed in the registers, and am trying to keep the file "tios_abi.txt" current regarding the internals of the implementation.
Back to work...
So here's where I'm at right now:
I've got GCC sort of ported at the moment, the TMS9900 is a valid target, the call interface is working, as are the shift instructions. I'm currently working on the conditional jumps.
Out of curiosity, I looked at Tursi's port, and it looks like he just used the PDP11 stuff, but changed the opcode names. Works OK I suppose, but suboptimal.
I used concepts from the ARM, M68HC11 and PDP11 implementations, since I wasn't sure where to start. As a result, I've had a heck of a time with the call interface, since the pieces I used didn't play well together. Tracking down the bugs is challenging, since there is a lot going on and it's still not clear to me how all the machine-specific parts get used.
I want to have parameters passed in the registers, and am trying to keep the file "tios_abi.txt" current regarding the internals of the implementation.
Back to work...
Thursday, December 24, 2009
There's been more planning and thinking than actual work lately. I've reached a point where I'm not sure what to work on next. I think the next items are going to be heap managent or process management, file interface or something like that.
I've changed the ABI to make R13, R14 and R15 non-volatile. This was done to make blwp and xop reasonable to use. I was working on the system call interface, and was annoyed by the amount of work needed to make the system work if those registers were kept as volatile. R12 has been made volatile to support easy CRU operation. Originally, that was a non-volatile register. using CRU instrustions incurred a similar level of annoyance. So now the register usage looks like this: R0-R8,R12 are volatile, R10,R11, R13-R15 are non-volatile. Basically, all special-purpose registers are non-volatile except R12. R9 has no special purpose, but I figured I should keep it non-volatile anyways.
As mentioned above, I've added a system call interface to the project. It doesn't actually do anything useful, but it works. I keep thinking that if I restrict the *print* calls to the system call interface, I can save 120 bytes. I'll make a final decision on this later.
I'm currently looking at heap management algorithms, so I guess that will be next.
Just for the heck of it, I've been thinking about a wolf-3d clone for the TI. I'm not sure if I'll actually do it, since I've got a lot going on right now, but it willl give me a better idea of what real-world programs will need.
I've also been thinking about writing a compiler best-practices guide as I continue working. I keep going back to Tursi's GCC port and his misguided insistance on a zero register, At some point I would like a C compliler, and I would like it to be good.
I've changed the ABI to make R13, R14 and R15 non-volatile. This was done to make blwp and xop reasonable to use. I was working on the system call interface, and was annoyed by the amount of work needed to make the system work if those registers were kept as volatile. R12 has been made volatile to support easy CRU operation. Originally, that was a non-volatile register. using CRU instrustions incurred a similar level of annoyance. So now the register usage looks like this: R0-R8,R12 are volatile, R10,R11, R13-R15 are non-volatile. Basically, all special-purpose registers are non-volatile except R12. R9 has no special purpose, but I figured I should keep it non-volatile anyways.
As mentioned above, I've added a system call interface to the project. It doesn't actually do anything useful, but it works. I keep thinking that if I restrict the *print* calls to the system call interface, I can save 120 bytes. I'll make a final decision on this later.
I'm currently looking at heap management algorithms, so I guess that will be next.
Just for the heck of it, I've been thinking about a wolf-3d clone for the TI. I'm not sure if I'll actually do it, since I've got a lot going on right now, but it willl give me a better idea of what real-world programs will need.
I've also been thinking about writing a compiler best-practices guide as I continue working. I keep going back to Tursi's GCC port and his misguided insistance on a zero register, At some point I would like a C compliler, and I would like it to be good.
Monday, December 14, 2009
Not a whole lot of work done, but I have been working on documentation lately. I've put together some notes on dynamically-loaded libraries, and system calls in general. I think it could work, and thinking down these lines is helpful for later.
I've also put together some notes for my modifications to the GAS assembler. I was thinking about the fact that I don't have an Editor/Assembler manual, and that it would probably help to ask around to get the missing pieces. In order for someone else to see my gaps, I need to document what I have so far.
The assembler documentation is very sparse, but I think it's a decent start.
While digging around for more info, I found the "nop" and "rt" pseudo-ops in example code in a couple places, so that seems legitimate. "Nop" is encoded as "jmp 0" and "rt" as "b *r11". While I was in there, I added "or" and "orb" as aliases for "soc" and "socb" since I can't ever remember the real instructions.
I had problems adding these instructions, since I made a dumb mistake in the parser. I was assuming there was an argument, and skipping the intervening space. This resulted in skipping the null terminator for the line, and getting "junk at end of line" errors. This has been fixed.
I've also put together some notes for my modifications to the GAS assembler. I was thinking about the fact that I don't have an Editor/Assembler manual, and that it would probably help to ask around to get the missing pieces. In order for someone else to see my gaps, I need to document what I have so far.
The assembler documentation is very sparse, but I think it's a decent start.
While digging around for more info, I found the "nop" and "rt" pseudo-ops in example code in a couple places, so that seems legitimate. "Nop" is encoded as "jmp 0" and "rt" as "b *r11". While I was in there, I added "or" and "orb" as aliases for "soc" and "socb" since I can't ever remember the real instructions.
I had problems adding these instructions, since I made a dumb mistake in the parser. I was assuming there was an argument, and skipping the intervening space. This resulted in skipping the null terminator for the line, and getting "junk at end of line" errors. This has been fixed.
Saturday, December 12, 2009
So last night I finally had time to finish the decimal printing routines. Along the way I found I had really misunderstood the function for the DIV instruction. I had thought that the OV flag would be set when the resulting quotient was zero. Looking back on the references, I can't see where I ever got that idea.
The *printf* routines take 446 bytes, not too bad, but I would have liked it to be smaller. Also, the stdio.asm file is a mess. It works, but there is little organization, and the layout is poor, with unnecessary B instructions.
I should start thinking about making a user-callable library for syscalls or somethihng. I don't want to go too far down the road of assuming a single-user, single-tasking environment. That works for now, but will all need to be ripped up later.
Honestly, a good chunk of the code (126 bytes) is encoding flags to discriminate the *print* forms.
The *printf* routines take 446 bytes, not too bad, but I would have liked it to be smaller. Also, the stdio.asm file is a mess. It works, but there is little organization, and the layout is poor, with unnecessary B instructions.
I should start thinking about making a user-callable library for syscalls or somethihng. I don't want to go too far down the road of assuming a single-user, single-tasking environment. That works for now, but will all need to be ripped up later.
Honestly, a good chunk of the code (126 bytes) is encoding flags to discriminate the *print* forms.
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.
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.
Subscribe to:
Posts (Atom)