Assembly or ....

Stephan Pasche pasche at ethz.UUCP
Tue Dec 6 05:15:08 AEST 1988


In article <1388 at aucs.UUCP> 861087p at aucs.UUCP (A N D R E A S) writes:
>
>I've been told also that there are some low-level operations
>that you just can't do in C or any other high level language.

for example : I don't know a high-level language where you have control of
	      the CPU status flags. These can be very useful for some 
	      applications. One example is an operation you need for a
	      fft program. There you have to reverse the bitorder of a word.
	      In assembly language there's a very elegant and fast solution :
	      You can shift the source operand via the carry bit into the
	      destination operand. For a 680xx CPU :

		Entry: move.l Source,d0  get source operand
		       moveq #31,d2	 init bit counter for a longword
		Loop:  lsr.l #1,d0	 shift source, one bit goes into x-bit 
		       roxl.l #1,d1      shift bit from x-bit into destination
		       dbra d2,Loop	 loop until last bit is shifted
		       move.l d1,Dest    save result (reverse bit-order) 

	      The x-bit of the 680xx has in this example about the same
	      function as the carry bit of other CPUs.
	      If you want to write the same program in a high-level language
	      you have to work with bit-masks and test operations, which
	      is (compared to the program above) very slow and complicated.

==============================================================================
OS/2 & PS/2 : half an operating system for half a computer
 
Stephan Paschedag           pachedag at strati.ethz.ch  or  pasche at bernina.UUCP
Federal Institute Of Technology Zurich
______________________________________________________________________________



More information about the Comp.lang.c mailing list