Jump to content

C -> Assembler


Recommended Posts

Guest spacemonkey
Posted

In EVc you can set up the compiler (CLARM.exe) to output an assembler file of your compiled code. I would hope that it is possible to compile this assembler code and then use it...

What I am thinking of doing is compiling C to assembler, then tuning some of the fundamental slow bits, then compiling the assembler.

This doesn't seem to work tho, I'm getting lots of complaints about .pdata and things which to me look like they are part of the function declarations etc.

Anyone have experience with this? I am not the most knowledgable about assembler so I'm just feeling my way around at the moment.

Guest paulperkins
Posted

Spacemonkey,

FWIW, I seem to remember contemplating going through the same excercise some years ago when working on a 3D engine. The conclusion we came to was that, in fact, that the MS compiler (MSVC 4.5 and 5) generated as near as spot-on code every time.

Admittedly, this was a completely difference C/Asm engine, but I would imagine that MS transfer learned lessons from one compiler to the next.*

Just my $0.02 worth,

Paul.

*and I may be talking complete rubbish here!

Guest benjymous
Posted

It might be better just working out which bits of your code need optimising, and either using inline asm (assuming that's supported), or just manually code your functions in asm, and make a .lib

It'll make debugging a nightmare, though

Guest spacemonkey
Posted

Yeah, inline asm was my first though, but it doesn't seem to be supported in eVC++...

I've gone down another track now tho anyway :)

Found a nive little Z80 cpu emulator written entirely in ARM ASM, and with only minor syntax tweaks got it to compile. So I'll try plugging that into my code instead.

Paul- While I agree that the compilers are usually pretty good about things it's more a question of shortcuts that I can make that C won't even let me write down.

The cpu loop I'm looking at doesn't do anything too complicated on each run through the loop, the problem is that it HAS to do it efficiently. Ie. If we say the SPV has a 84Mhz processor. My overall program (gnuboy) spends 2/3 of it's time just in the cpu loop. So I've got about 55Mhz in that loop. Now the Z80 it's emulating runs at 8Mhz, so that give's me 6.875 Cycles on the ARM to process each simulated Z80 instruction on average. When your talking stuff like that, knocking a few instructions off the loop will make a significant difference (I hope).

Looking at the C-> ASM code for instance, a no-op instruction was taking about 10 lines of ASM all up, I should be able to reduce that to about 3 still working in largely the same structure.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.