struct tty_queue {
long head;
long tail;
char buf[64];
}read_q = { 0,0,""} ;
static int in = 0;
long volatile timerc;
void printf(char *fmt, ...)
{
__asm__ __volatile__ (
"movl $7, %%eax\n\t"
"int $0x80\n\t"
::"b" (fmt)
);
}
void delay(void)
{
int time_delay;
time_delay = timerc;
while((timerc - time_delay ) < 6);
}
unsigned char getchar(void)
{
unsigned char ch;
if(read_q.tail == read_q.head)
{
while(input == 0 ) {
delay();
}
in = 0 ;
}
ch = read_q.buf[read_q.tail];
read_q.tail = (read_q.tail + 1) & (64 - 1);
return ch;
}
int main()
{
char a;
a=getchar();
printf("1jjk give you a message !the char is %c\n", a);
}
$gcc a.c
$./a.out
阅读(1580) | 评论(0) | 转发(0) |