ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6
part 7
part 8
part 9


8 - Caller vs. Callee

Unlike the sort comparisons, the sort calling routines handle the function call via the parent side. From their point of view, setup is no different, but all work must be done in the upper registers, or else we'll have to save and restore around subroutine calls. Parameters are passed exactly as a C function expects them, meaning that the functions can call C and assembly equally easily.

Rather than show the code (it's about 80 lines), I've commented it liberally and encourage you to download it and look it over. The C function BadSort() was the basis of the assembly version, and the comments show how the code was translated. By comparing the two, you can get an idea how ASM can be more easily written after the C is created and debugged (as Part Two of this series illustrated).

As these examples show, integrating C and ASM is quite straightforward, and of course the assembly code still outperforms C in every case - in these examples, switching the parent sort routine from C to ASM roughly doubled the speed, while switching the calling routine from C to ASM almost doubled it again. Together, an all-assembly version was over three times as fast as the C-only combination.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice