亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? moon.c

?? compiler-compiler. This is a compiler-compiler with table-driven scanner, table-driven parser.
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* Moon Simulator. * * Author:			Peter Grogono * Last modified:	30 January 1995 * * This source file was created using a tab width of 4 characters. */#include <stdio.h>#include <ctype.h>#include <string.h>#include <math.h>#include <stdlib.h>/* Notes on definitions. * The memory occupies about 6 * MEMSIZE bytes.  Enlarging it may create * problems for architectures with memory restrictions, such as the PC. * * The simulator is not completely independent of the underlying * processor.  Known variations include: *    - trace output depends on whether the host is big- or little endian. *    - the MOON `sr' op uses the C `>>' operator. */#define MEMSIZE	    8191	/* Memory size in 4-byte words. */#define MAXREG		  16	/* Number of registers. */#define MAXINFILES	  20	/* Restricts # input files. */#define MAXNAMELEN	  60	/* Restricts path/file name length. */#define BUFLEN		 255	/* Scanner input buffer. */#define TOKLEN		 255	/* Scanner token buffer. */#define RANGE		  20	/* Determines size of memory dump. */#define FALSE		0#define TRUE		1#define BYTE 		unsigned char/* The following function reports syntax errors.  It is declared here so *  that it can be used by memory functions; its definition appears in the * loader section. */void syntaxerror (char *message);/* The following function reports run-time errors.  It is declared here so *  that it can be used by memory functions; its definition appears in the * execution section. */void runtimeerror (char *message);/************************ MEMORY ********************************************//* A word of memory contains an instruction (A or B format), four bytes, * or a 32-bit signed integer.  The simulated memory also contains two * flags, to tell whether the word contains an instruction and whether * it is a breakpoint. * * The simulated memory is an array of four-byte words.  Simulated * addresses are byte addresses.  Consequently, all addresses are * shifted right 2 bits before being used.  Only the memory module * should know about this.  Conventionally, <addr> is a byte address * and <wordaddr> is a word address. */typedef union {	struct {		unsigned op:6;		unsigned ri:4;		unsigned rj:4;		unsigned rk:4;		unsigned :14;		} fmta;	struct {		unsigned op:6;		unsigned ri:4;		unsigned rj:4;		unsigned   :2;		int       k:16;     /* Unsigned is not portable! */		} fmtb;	BYTE byts [4];	long data;	} wordtype;/* Each component of the memory array contains: *  -  word:		The contents of simulated memory. *  -  cont:        `a' => format A instruction *					`b' => format B instruction *					'd' => data *					`u' => undefined *  -  breakpoint:	True if this is a breakpoint. */struct {	wordtype word;	char cont;	short breakpoint;	} mem [MEMSIZE];long ic;				/* Instruction counter: contains address of							instruction that will be executed next. */wordtype ir; 			/* Instruction register: contains the instruction							that will be executed next. */long mar;				/* Memory address register;							stores word address of last access. */wordtype mdr;			/* Memory data register;							stores result of last access. */long entrypoint = -1;	/* Address of first instruction */long cycles = 0;		/* Counts memory cycles. *//* Initialize the memory: value=zero, kind=undef, no breakpoint. * Set "hardware" addresses to an illegal value. */void initmem () {	long wordaddr;	for (wordaddr = 0; wordaddr < MEMSIZE; wordaddr++) {		mem[wordaddr].word.data = 0;		mem[wordaddr].cont = 'u';		mem[wordaddr].breakpoint = FALSE;		ic = -1;		mar = -1;		}	}/* Report a run-time error if an illegal address is used. */short outofrange (long addr) {	if (addr < 0 || (addr >> 2) > MEMSIZE) {		runtimeerror("address error");		return 1;		}	return 0;	}/* Report a run-time error if a memory word access is not on a * four-byte boundary. */short misaligned (long addr) {	if (addr & 3) {		runtimeerror("alignment error");		return 1;		}	return 0;	}/* Fetch the instruction at <ic>, store it in <ir>, and increment <ic>. */short fetch () {	short cont;	if (outofrange(ic)) {		ir.data = 0;		return 0;		}	cont = mem[ic >> 2].cont;	if (!(cont == 'a' || cont == 'b')) {		runtimeerror("illegal instruction");		ir.data = 0;		return 0;		}	ir = mem[ic >> 2].word;	ic += 4;	cycles += 10;	return cont;	}/* Fetch a data word from memory and return it. */long getmemword (long addr) {	long wordaddr;	if (outofrange(addr) || misaligned(addr))		return 0;	wordaddr = addr >> 2;	if (wordaddr == mar)		cycles += 1;	else {		mar = wordaddr;		mdr = mem[wordaddr].word;		cycles += 10;		}	return mdr.data;	}/* Store a word in memory. */void putmemword (long addr, long data) {	long wordaddr;	if (outofrange(addr) || misaligned(addr))		return;	wordaddr = addr >> 2;	if (mem[wordaddr].cont == 'a' || mem[wordaddr].cont == 'b') {		runtimeerror("overwriting instructions");		return;		}	mdr.data = data;	mar = wordaddr;	mem[mar].word = mdr;	mem[mar].cont = 'd';	cycles += 10;	return;	}/* Fetch a byte from memory. */BYTE getmembyte (long addr) {	long wordaddr = addr >> 2;	short offset = addr & 3;	if (outofrange(addr))		return 0;	if (wordaddr == mar)		cycles += 1;	else {		mar = wordaddr;		cycles += 10;		}	mdr = mem[mar].word;	return mdr.byts[offset];	}/* Store a byte in memory. */void putmembyte (long addr, BYTE byt) {	long wordaddr = addr >> 2;	short offset = addr & 3;	if (outofrange(addr))		return;	if (mem[wordaddr].cont == 'a' || mem[wordaddr].cont == 'b') {		runtimeerror("overwriting instructions");		return;		}	mem[wordaddr].word.byts[offset] = byt & 255;	mem[wordaddr].cont = 'd';	return;	}/* Store an instruction in memory. Used only by loader. */void putmeminstr (long addr, wordtype word, char cont) {	if (addr & 3)		syntaxerror("alignment error");	else {		long wordaddr = addr >> 2;		mem[wordaddr].word = word;		mem[wordaddr].cont = cont;		}	}/* Store a character in memory. Used only by loader. */void putmemchar (long addr, short byte, char cont) {	long wordaddr = addr >> 2;	mem[wordaddr].word.byts[addr & 3] = byte;	mem[wordaddr].cont = cont;	}/********************** REGISTERS *******************************************//* There are sixteen registers, numbered 0 through 15.  Each register *  is a 32-bit word.  Functions check the register address although an * error would indicate a fault in the loader rather than the simulator. * Register 0 is always 0. */long regs [MAXREG];/* Fetch the value of a register. */long fetchreg (unsigned short regnum) {	if (regnum > 15) {		runtimeerror("simulator error (illegal register code)");		return 0;		}	return regs[regnum];	}/* Store a value in a register. */void storereg (unsigned short regnum, long data) {	if (regnum > 15)		runtimeerror("simulator error (illegal register code)");	if (regnum > 0)		regs[regnum] = data;	}/******************** INSTRUCTION CODES *************************************//* Instruction codes and the corresponding strings; obviously, these two * declarations should correspond.  The directives have codes although * they are not stored in the memory.  Note that 0 is an illegal * instruction. */enum optype {	bad, lw, lb, sw, sb, add, sub, mul, divr, mod,	and, or, not, ceq, cne, clt, cle, cgt, cge,	addi, subi, muli, divi, modi, andi, ori,	ceqi, cnei, clti, clei, cgti, cgei, sl, sr,	gtc, ptc, bz, bnz, j, jr, jl, jlr, nop, hlt,	entry, align, org, dw, db, res,	last	};char opnames [last] [6] = {	"", "lw", "lb", "sw", "sb", "add", "sub", "mul", "div", "mod",	"and", "or", "not", "ceq", "cne", "clt", "cle", "cgt", "cge",	"addi", "subi", "muli", "divi", "modi", "andi", "ori",	"ceqi", "cnei", "clti", "clei", "cgti", "cgei", "sl", "sr",	"getc", "putc", "bz", "bnz", "j", "jr", "jl", "jlr", "nop", "hlt",	"entry", "align", "org", "dw", "db", "res"	};void showfmta (long addr, wordtype word) {	char *opcode = opnames[word.fmta.op];	switch (word.fmta.op) {		/* Operands Ri, Rj, Rk */		case add:		case sub:		case mul:		case divr:		case mod:		case and:		case or:		case ceq:		case cne:		case clt:		case cle:		case cgt:		case cge:			printf("%5ld %-6s   r%d, r%d, r%d",				addr, opcode, word.fmta.ri,				word.fmta.rj, word.fmta.rk);			break;		/* Operands Ri, Rj */		case not:		case jlr:			printf("%5ld %-6s   r%d, r%d",				addr, opcode, word.fmta.ri, word.fmta.rj);			break;		/* No operands */		case nop:		case hlt:			printf("%5ld %-6s",				addr, opcode);			break;		}	}void showfmtb (long addr, wordtype word) {	char *opcode = opnames[word.fmtb.op];	switch (word.fmtb.op) {		/* Operands Ri, K(Rj) */		case lw:		case lb:			printf("%5ld %-6s   r%d, %d(r%d)",				addr, opcode, word.fmtb.ri,				word.fmtb.k, word.fmtb.rj);			break;		/* Operands K(Rj), Ri */		case sw:		case sb:			printf("%5ld %-6s   %d(r%d), r%d",				addr, opcode, word.fmtb.k,				word.fmtb.rj, word.fmtb.ri);			break;		/* Operands Ri, Rj, K */		case addi:		case subi:		case muli:		case divi:		case modi:		case andi:		case ori:		case ceqi:		case cnei:		case clti:		case clei:		case cgti:		case cgei:			printf("%5ld %-6s   r%d, r%d, %d",				addr, opcode, word.fmtb.ri,				word.fmtb.rj, word.fmtb.k);			break;		/* Operands Ri, K */		case sl:		case sr:		case bz:		case bnz:		case jl:			printf("%5ld %-6s   r%d, %d",				addr, opcode, word.fmtb.ri, word.fmtb.k);			break;		/* Operands Ri */		case gtc:		case ptc:		case jr:			printf("%5ld %-6s   r%d",				addr, opcode, word.fmtb.ri);			break;		/* Operands K */		case j:			printf("%5ld %-6s   %d",				addr, opcode, word.fmtb.k);			break;		}	}/* Convert a word to a string of 4 characters. Non-graphics to ".". * Exact output depends on whether the host is big-endian or * little-endian. */char *wordtochars (char *buf, wordtype word) {	int i;	for (i = 0; i < 4; i++) {		char c = word.byts[i];		if (32 <= c && c <= 126)			buf[i] = c;		else buf[i] = '.';		}	buf[4] = '\0';	return buf;	}/* Display one word of memory. */void showword (long addr) {	char charbuf [5];	long wordaddr = addr >> 2;	wordtype word = mem[wordaddr].word;	if (addr & 3) {		printf("Internal error: bad address!\n");		exit(1);		}	switch (mem[wordaddr].cont) {		case 'a':			showfmta(addr, word);			break;		case 'b':			showfmtb(addr, word);			break;		case 'd':			printf("%5ld  %08lX  %s  %4ld", addr, word.data,				wordtochars(charbuf, word), word.data);			break;		case 'u':			printf("%5ld  ??", addr);			break;		}	}/****************************** SYMBOLS *************************************//* There is one <symnode> for each symbol.  It records the name and value * of the symbol and how often it has been defined (once is correct). * The <symnode> also contains a pointer to a list of <usenodes>'s, each * of which contains an address where the value of the symbol is used. */struct symnode {	char *name;	long val;	short defs;	struct usenode *uses;	struct symnode *next;	};struct usenode {	long addr;	struct usenode *next;	};/* The base of the symbol table. */struct symnode *symbols = NULL;/* Return a pointer to a symbol entry.  This always succeeds, because * it creates a new entry if it can't find a matching entry. */struct symnode *findsymbol (char *name) {	struct symnode *p = symbols;	while (p) {		if (!strcmp(name, p->name))			return p;		p = p->next;		}	/* No entry exists, so make one. */	p = (struct symnode *) malloc (sizeof(struct symnode));	if (p == NULL) {		printf("No more memory!\n");		exit(1);		}	p->name = (char *) malloc(strlen(name) + 1);	strcpy(p->name, name);	p->val = 0;	p->defs = 0;	p->uses = NULL;	p->next = symbols;	symbols = p;	return p;	}/* Define a symbol.  That is, associate the value <val> with * the symbol <name>. */void defsymbol (char *name, long val) {	struct symnode *p = findsymbol(name);	p->val = val;	p->defs++;	}/* Use a symbol. That is, record the fact that the symbol <name> * must be stored at <addr>. */void usesymbol (char *name, long addr) {	struct symnode *p = findsymbol(name);	struct usenode *u = (struct usenode *) malloc (sizeof (struct usenode));	if (u == NULL) {		printf("No more memory!\n");		exit(1);		}	u->addr = addr;	u->next = p->uses;	p->uses = u;	}/* Return the value of a symbol, or -1 if it doesn't exist. */long getsymbolval (char *name) {	struct symnode *p = symbols;	while (p) {		if (!strcmp(name, p->name))			return (p->val);		p = p->next;		}	return -1;	}/* Display all symbols and their uses. */void showsymbols () {	short count = 0;	struct symnode *p = symbols;	while (p) {		struct usenode *u = p->uses;		printf("%-8s = %4ld  Used at: ", p->name, p->val);		while (u) {			printf("%ld ", u->addr);			u = u->next;			}		printf("\n");		p = p->next;		if (++count > 20) {			printf("Press enter to continue");			getchar();			count = 0;			}		}	}/* Check symbol list for errors and return error count. */int checksymbols () {	int errors = 0;	struct symnode *p = symbols;	while (p) {		if (p->defs == 0) {			printf("Undefined symbol: %s.\n", p->name);			errors++;			}		else if (p->defs > 1) {			printf("Redefined symbol: %s.\n", p->name);			errors++;			}		p = p->next;		}	return errors;	}/* Store symbols at their respective locations. */void storesymbols () {	struct symnode *p = symbols;	while (p) {		struct usenode *u = p->uses;		while (u) {			long wordaddr = (u -> addr) >> 2;			switch (mem[wordaddr].cont) {				case 'b':					mem[wordaddr].word.fmtb.k = (int) p->val;					break;				case 'd':					mem[wordaddr].word.data = p->val;					break;				default:					printf("Symbol storage error!\n");					break;				}			u = u->next;			}		p = p->next;		}	}/***************************** EXECUTION ************************************/short newreg;		/* Address of a register that has changed */long newmem;		/* Address of a memory location that has changed */short running;		/* True if the processor is running, false after errors */long numsteps;		/* Number of instructions executed in trace mode. *//* Report a run-time error and stop the program. */void runtimeerror (char *message) {	printf("\n%5ld Run-time error: %s.\n", ic, message);	running = FALSE;	}/* Execute the instruction at address <ic>. */void execinstr (short tracing) {	long w1, w2, k, rk;	short cont = fetch();		/* Move next instruction to `ir'. */	int ch;	if (!running)		return;	newreg = -1;	newmem = -1;	switch (cont) {		/* Format A instructions with register operands. */		case 'a':			switch (ir.fmta.op) {				/* add Ri, Rj, Rk */				case add:					storereg(ir.fmta.ri,						fetchreg(ir.fmta.rj) + fetchreg(ir.fmta.rk));					newreg = ir.fmta.ri;					break;				/* sub Ri, Rj, Rk */				case sub:					storereg(ir.fmta.ri,						fetchreg(ir.fmta.rj) - fetchreg(ir.fmta.rk));					newreg = ir.fmta.ri;					break;				/* mul Ri, Rj, Rk */				case mul:					storereg(ir.fmta.ri,						fetchreg(ir.fmta.rj) * fetchreg(ir.fmta.rk));					newreg = ir.fmta.ri;					break;				/* divr Ri, Rj, Rk */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久一二三国产| 奇米精品一区二区三区在线观看| 亚洲欧美日韩人成在线播放| 免费人成黄页网站在线一区二区 | 日韩欧美一区二区不卡| 欧美激情一区二区三区在线| 午夜精品123| 91色在线porny| 欧美精品一区二区三区很污很色的| 亚洲欧美一区二区久久| 国产伦精一区二区三区| 4hu四虎永久在线影院成人| 国产精品久久久久久久久免费丝袜| 男人的天堂久久精品| 92国产精品观看| 久久精品亚洲乱码伦伦中文| 日韩国产欧美在线视频| 色婷婷激情久久| 国产精品久久久久久久久果冻传媒| 日本 国产 欧美色综合| 欧美性一区二区| ...xxx性欧美| 国产91在线看| 国产丝袜在线精品| 国产一区二区主播在线| 欧美美女网站色| 一区二区欧美精品| 91在线国内视频| 欧美国产日韩亚洲一区| 国产一区二区主播在线| 久久综合狠狠综合久久综合88| 日日摸夜夜添夜夜添国产精品| 欧美综合一区二区三区| 一区二区三区欧美日| 91丨porny丨首页| 亚洲欧美日韩中文字幕一区二区三区| 在线观看亚洲成人| 亚洲成人av在线电影| 欧美三级乱人伦电影| 亚洲国产一区二区在线播放| 欧美在线观看视频在线| 一区二区三区在线观看视频| 在线中文字幕一区二区| 亚洲一区二区三区美女| 欧美日韩亚洲国产综合| 亚洲v日本v欧美v久久精品| 欧美日韩国产高清一区二区| 日韩精品亚洲专区| 欧美精品一区二区三区蜜桃| 国产精品小仙女| 国产精品人人做人人爽人人添| yourporn久久国产精品| 悠悠色在线精品| 欧美电影影音先锋| 激情综合网最新| 国产欧美精品日韩区二区麻豆天美 | 亚洲欧美日韩国产一区二区三区| 99天天综合性| 亚洲妇女屁股眼交7| 欧美一级爆毛片| 国产精品影视网| 亚洲欧美福利一区二区| 欧美日韩国产综合久久| 极品少妇一区二区| 中文字幕一区二区三区在线观看| 欧美三级电影在线看| 狠狠色狠狠色合久久伊人| 国产精品毛片高清在线完整版| 欧美视频一区二| 久久99最新地址| 亚洲精品高清在线| 日韩欧美成人一区二区| 成人动漫一区二区在线| 亚洲成人午夜影院| 中文字幕高清一区| 欧美人狂配大交3d怪物一区 | 欧美色手机在线观看| 久久精品国产亚洲一区二区三区| 中文字幕不卡在线播放| 欧美日韩精品福利| 成人av在线观| 美女高潮久久久| 亚洲精品v日韩精品| 久久综合色一综合色88| 欧美无砖专区一中文字| 国产成人免费视频精品含羞草妖精| 夜夜精品视频一区二区 | 日本成人中文字幕在线视频| 国产精品不卡视频| 日韩欧美成人一区| 精品视频全国免费看| 国产成人午夜高潮毛片| 日本视频一区二区| 亚洲久本草在线中文字幕| 国产人成亚洲第一网站在线播放| 精品视频1区2区3区| 北岛玲一区二区三区四区| 狠狠色综合日日| 五月婷婷另类国产| 亚洲综合视频在线观看| 国产精品毛片久久久久久久| 久久亚洲精华国产精华液| 日韩一级大片在线| 欧美蜜桃一区二区三区| 色婷婷综合久久久久中文 | 精品美女一区二区| 欧美三片在线视频观看| 色老头久久综合| 不卡一区二区三区四区| 丁香婷婷综合色啪| 国产在线看一区| 久久国产精品区| 91性感美女视频| 国产精品88av| 国产精品123| 国产jizzjizz一区二区| 国产乱妇无码大片在线观看| 国产一区二区三区高清播放| 久久av中文字幕片| 国内精品伊人久久久久av一坑| 全国精品久久少妇| 久久99久久久欧美国产| 久久99国产精品久久99果冻传媒| 日日欢夜夜爽一区| 蜜乳av一区二区三区| 久久99国内精品| 国产一区二区不卡在线| 国产成人亚洲综合a∨猫咪| 粉嫩av一区二区三区在线播放| 国产精品18久久久久久vr| 国产盗摄一区二区| 成人免费电影视频| 91在线观看高清| 欧美午夜影院一区| 欧美日韩久久一区二区| 欧美一级片在线看| 国产午夜亚洲精品不卡 | 91精品国产入口| 精品国产成人在线影院| 久久久激情视频| 国产精品成人免费精品自在线观看| 中文字幕日韩一区| 亚洲va韩国va欧美va精品| 免费在线看一区| 国产福利一区二区三区视频| 成人精品gif动图一区| 一本大道综合伊人精品热热| 欧美久久一二区| 久久亚洲精品小早川怜子| 一色屋精品亚洲香蕉网站| 夜夜嗨av一区二区三区| 亚洲电影激情视频网站| 国产在线视频一区二区三区| 91视频观看免费| 91精品综合久久久久久| 国产日本亚洲高清| 午夜影院在线观看欧美| 国产黄色精品网站| 91国偷自产一区二区三区观看 | 久久亚洲精品国产精品紫薇| 成人免费小视频| 老司机精品视频线观看86| 成人h动漫精品一区二| 欧美日韩精品高清| 亚洲国产精品二十页| 亚洲成人你懂的| 大尺度一区二区| 欧美巨大另类极品videosbest| 国产欧美日产一区| 日韩精品视频网站| 99精品欧美一区二区蜜桃免费| 欧美精品亚洲二区| 国产精品久久久久久久浪潮网站| 丝袜美腿成人在线| 一本久久a久久精品亚洲| 日韩一区二区三区电影| 一区2区3区在线看| 国产不卡在线一区| 91精品免费在线| 亚洲黄色录像片| 粉嫩av一区二区三区粉嫩| 日韩欧美国产不卡| 亚洲专区一二三| 成人国产精品免费观看动漫| 欧美大片国产精品| 亚洲一卡二卡三卡四卡五卡| 成人开心网精品视频| 日韩免费高清av| 日韩不卡手机在线v区| 91久久香蕉国产日韩欧美9色| 国产视频一区二区三区在线观看| 日韩高清不卡一区| 欧美三级一区二区| 国产福利一区二区三区在线视频| 69堂国产成人免费视频| 亚洲一区二区综合| 色久优优欧美色久优优| 亚洲欧美一区二区三区久本道91 | 欧美巨大另类极品videosbest| 最新久久zyz资源站|