C to ASM
Milan MCM
magixe@volny.cz
Sobota Srpen 13 10:32:47 CEST 2005
Dobrý den , chtěl jsem poprosit nějakou dobrou duši co umí a dělá v C a
má na to nějaký SW
zda by mě přeložil tento kousek kodu C do ASM podoby - pro X51 ( 89C51ED2 ).
Děkuji
Kod >>
//Sine wave table used for 4-bit microstepping.
//The absolute values are left-shifted by one bit, and bit 0 is the sign
bit (phase direction bit).
//Bit 5 is the mixed decay bit. It is set when the absolute value is
falling.
UCHAR sinus_tab[64]={0x00, 0x02, 0x06, 0x08, 0x0c, 0x0e, 0x10, 0x14,
0x16, 0x18, 0x18, 0x1a, 0x1c, 0x1c, 0x1e, 0x1e,
0x3e, 0x3e, 0x3e, 0x3c, 0x3c, 0x3a, 0x38, 0x38,
0x36, 0x34, 0x30, 0x2e, 0x2c, 0x28, 0x26, 0x22,
0x01, 0x03, 0x07, 0x09, 0x0d, 0x0f, 0x11, 0x15,
0x17, 0x19, 0x19, 0x1b, 0x1d, 0x1d, 0x1f, 0x1f,
0x3f, 0x3f, 0x3f, 0x3d, 0x3d, 0x3b, 0x39, 0x39,
0x37, 0x35, 0x31, 0x2f, 0x2d, 0x29, 0x27, 0x23};
volatile UCHAR PhaseCount=0;
/**********************************************************
This function generates the
microsteps. The values are read from the
table and output to the TMC236 or TMC239
via the SPI interface.
Call this function with the "ccw" parameter set to 1
to step in negative direction,
or with "ccw" set to 0 to step in positive direction.
Callthis function for example in a timer interrupt.
***********************************************************/
void step(char ccw)
{
UINT MixedDecayXOR=0, io;
if(!ccw)
{
PhaseCount++;
}
else
{ //The "Mixed Decay" bits must be reversed when running in CCW
direction
PhaseCount--;
MixedDecayXOR=0x820;
}
io=((sinus_tab[PhaseCount & 63]<<6 | sinus_tab[(PhaseCount+16) &
63]) ^ MixedDecayXOR);
//Now, set the CS line of the TMC236/239 low and send out the value of
"io" by SPI
//(MSB first).
//After that, set the CS line high again.
}
}
Další informace o konferenci Hw-list