⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdlib.c

📁 一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,
💻 C
字号:
/*	strlen(s)	isspace(c)	putchar(c)	puts(s)	bcmp(s1, s2, n)	bcopy(src, dst, n)	--------------------------------------------------------------	Simple implementations  of the corresponding  ISO C functions.	putc() does  not print the  final newline, and  some functions	use  ints instead  of  size_t, and  don't  return values  like	they're supposed to. bcmp() and bcopy() comes from BSD.*/#include "termio.h"unsigned long strlen(    const char* s){    int n = 0;    for (; *s != '\0'; ++s)	++n;    return n;}int isspace(    int c){    return c == ' ' || c == '\t' || c == '\n' || c == '\r';}void putchar(    int c){#if 0    *(volatile char *)(0xFFFFFFFFBF400008 ^ 7) = c;#else    while(!pzscc(OP_TXRDY, 0xFFFFFFFFBC800030, 0, 0));    pzscc(OP_TX, 0xFFFFFFFFBC800032, 0, c);#endif}void puts(    const char* s){    while (*s)	putchar(*s++);}int bcmp(    const void* src,    const void* dst,    int n){    const char* p = src;    const char* q = dst;    while (n > 0) {	if (*p != *q)	    break;	++p, ++q, --n;    }    return 0;}void bcopy(    const void* src,    void* dst,    int n){    if (((long)src & 3) == 0 && ((long)dst & 3) == 0 && (n & 3) == 0) {	/* Fast aligned copy. */	const int* p = src;	int* q = dst;	for (; n > 0; n -= 4)	    *q++ = *p++;    }    else {	/* Slow byte copy. */	const char* p = src;	char* q = dst;;	for (; n > 0; --n)	    *q++ = *p++;    }}void put_hex(    unsigned long x,    int padding,    int width,    int nice,    int hex_case){    int flush_left;    char buffer[sizeof(x) * 8 / 4 + 2];    char* p = buffer;    /* Align left if width is negative. */    if (width >= 0)	flush_left = 0;    else {	flush_left = 1;	width = -width;    }    /* Generate the digits (least-signficant one first.) */    do {	int digit = x & 15;	*p++ = digit + ((digit < 10) ? '0' : hex_case - 10);    } while (x >>= 4);    /* Print the 'nice' 0x. */    if (nice) {	*p++ = 'x' - 'a' + hex_case;	*p++ = '0';    }    /* Adjust the width by the number of already-generated characters. */    width -= (p - buffer);    /* Print the left padding. */    if (!flush_left) {	for (; width > 0; --width)	    putchar(padding);    }    /* Print the generated digits in a reversed order. */    do {	putchar(*--p);    } while (p > buffer);    /* Print the right padding. */    for (; width > 0; --width)	putchar(' ');}

⌨️ 快捷键说明

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