C语言和arm汇编求阶乘,C语言和ARM汇编混合编程实现阶乘运算

{

j = 0;

while(j++<30)

;

}

}

struct __FILE

{

int handle;

};

FILE __stdout, __stdin;

void UART_Init(int baud)

{

rUFCON0=0x0; // FIFO disable

rUFCON1=0x0;

rUMCON0=0x0;

rUMCON1=0x0;

rULCON0=0x3; // UART0

rUCON0=0x245;

rUBRDIV0=( (int)(MCLK/16./baud + 0.5) -1 );

rULCON1=0x3; // UART1

rUCON1=0x245;

rUBRDIV1=( (int)(MCLK/16./baud + 0.5) -1 );

Delay(10);

}

#define SemiSWI 0x123456

__swi(SemiSWI) void _WriteC(unsigned op, char *c);

#define WriteC(c) _WriteC(0x3,c)

__swi(SemiSWI) unsigned char _ReadC(unsigned op, char val);

#define ReadC() _ReadC(0x7,0)

__swi(SemiSWI) void _Exit(unsigned op, unsigned except);

#define Exit() _Exit(0x18,0x20026)

void UART_PutChar(unsigned char data)

{

rUTXH0=data;

while(!(rUTRSTAT0 & 0x2))

;

}

char UART_GetChar(void)

{

while(!(rUTRSTAT0 & 0x1))

;

return rURXH0;

}

extern void LCD_PutChar(unsigned char data);

int fputc(int ch, FILE *f)

{

char tempch = ch;

WriteC( &tempch );

return ch;

}

int fgetc(FILE *f)

{

unsigned char tempch;

tempch = ReadC();

return tempch;

}

int ferror(FILE *f)

{

return EOF;

}

void _sys_exit(int return_code)

{

Exit(); /* for debugging */

label: goto label; /* endless loop */

}

int main(void)

{

int a;

int b;

Port_Init();

IO82C55A_Init();

UART_Init(115200);

LCD_Init();

LCD_ChangeMode(DspTxtMode);

LCD_Printf("Hello World!\n");

while(1)

{

printf("Hello! Please Input N: \n\n");

LCD_Printf("Hello! Please Input N: \n\n");

scanf("%d",&a);

b=asmDouble(a);

printf("%d!=%d\n",a,b);

LCD_Printf("%d!=%d\n",a,b);

}

}

(4) 调试观察结果:

显示:Hello! Please Input N:

输入5

显示5!=120;

输入3!=6;

结果正确。

你可能感兴趣的:(C语言和arm汇编求阶乘)