utile.c

来自「第三届飞思卡尔智能车竞赛华东赛一等奖的程序」· C语言 代码 · 共 59 行

C
59
字号
#include <mc9s12dg128.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"

char inch() //input a char via the SCI
{
	asm
	{
		BRCLR $00cc,#$20,*
	}
	return SCI0DRL;
}

void outch(char ch) //output a char
{
	asm
	{
		BRCLR $00cc,#$80,*
	}
	SCI0DRL=ch;
}

void main_exit(void)  //jump out to the monitor program
{
	_asm JSR $0fe80
}


void print_int(int n) //print a integer via the SCI
{
	char bits,ch[5];
	if(n==0)
	{
	  outch('0');
	  return;
	}
	bits=0;
	if(n<0)
	{
		outch('-');
		n=-n;
	}
	while(n>0)
	{
		ch[bits]=n%10+'0';
		n/=10;
		bits++;
	}
	bits--;
	while(bits>=0)
	{
		outch(ch[bits]);
		bits--;
	}
}

void print_string(char s[])
{
  for(;*s!='\0';s++) outch(*s);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?