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

📄 arithmetic.h

📁 简单的虚拟机
💻 H
字号:
/* opcode r/m8 r8| op r8 r/m8 */#define handle_arith_rm8(opstr, op1,op2) \{\	word __dest = get_op_val(op1); \	word __src = get_op_val(op2); \	__asm__("push %%edx\n\t" \		 "popfl \n\t" \		 #opstr" %%bl,%%al\n\t" \		 "pushfl \n\t" \		 "pop %%edx\n\t" \		 :"=a"(__dest),"=d"(cpu.flags) \		 :"a"(__dest),"b"(__src),"d"(cpu.flags)); \	set_op_val(op1,__dest); \}/* opcode r/m16 r16 | op r16 r/m16 */#define handle_arith_rm16(opstr,op1,op2) \{ \	word __dest = get_op_val(op1); \	word __src = get_op_val(op2); \	__asm__("push %%edx\n\t" \		 "popfl\n\t" \		 #opstr" %%bx,%%ax\n\t" \		 "pushfl\n\t" \		 "pop %%edx\n\t" \		 :"=a"(__dest),"=d"(cpu.flags) \		 :"a"(__dest),"b"(__src),"d"(cpu.flags)); \	set_op_val(op1,__dest); \}#define handle_arith_rm(opstr,op1,op2,wFlag) \	if(wFlag) \	{ \		handle_arith_rm16(opstr,op1,op2) \	} \	else \	{ \		handle_arith_rm8(opstr,op1,op2) \	}/****************************************************************************//* opcode r/m8 imm8 */#define handle_arith_rm8_imm(opstr, op, imm) \{ \	word __dest = get_op_val(op); \	__asm__("push %%edx\n\t" \		 "popfl\n\t" \		 #opstr" %%bl,%%al\n\t" \		 "pushfl\n\t" \		 "pop %%edx\n\t" \		 :"=a"(__dest),"=d"(cpu.flags) \		 :"a"(__dest),"d"(cpu.flags),"b"(imm)); \	set_op_val(op,__dest); \}/* opcode r/m16 imm16 */#define handle_arith_rm16_imm(opstr,op,imm) \{ \	word __dest = get_op_val(op); \	__asm__("push %%edx\n\t" \		 "popfl\n\t" \		 #opstr" %%bx,%%ax\n\t" \		 "pushfl\n\t" \		 "pop %%edx\n\t" \		 :"=a"(__dest),"=d"(cpu.flags) \		 :"a"(__dest),"d"(cpu.flags),"b"(imm)); \	set_op_val(op,__dest); \}#define handle_arith_rm_imm(opstr,op,imm,wFlag) \	if(wFlag) \	{ \		handle_arith_rm16_imm(opstr,op,imm) \	} \	else \	{ \		handle_arith_rm8_imm(opstr,op,imm) \	}/****************************************************************************/#define handle_bcdadjust(opstr) \{ \	__asm__("push %%edx\n\t" \		 "popfl\n\t" \		 #opstr"\n\t" \		 "pushfl\n\t" \		 "pop %%edx\n\t" \		 :"=d"(cpu.flags),"=a"(cpu.greg.ax) \		 :"d"(cpu.flags),"a"(cpu.greg.ax)); \}/*****************************************************************************/#define handle_incdec16(opstr,op) \{ \	word __dest = get_op_val(op); \	__asm__("push %%edx\n\t" \		 "popfl\n\t" \		 #opstr" %%ax\n\t" \		 "pushfl\n\t" \		 "pop %%edx\n\t" \		 :"=a"(__dest),"=d"(cpu.flags) \		 :"a"(__dest),"d"(cpu.flags)); \	set_op_val(op,__dest); \}#define handle_incdec8(opstr,op) \{ \	word __dest = get_op_val(op); \	__asm__("push %%edx\n\t" \		 "popfl\n\t" \		 #opstr" %%al\n\t" \		 "pushfl\n\t" \		 "pop %%edx\n\t" \		 :"=a"(__dest),"=d"(cpu.flags) \		 :"a"(__dest),"d"(cpu.flags)); \	set_op_val(op,__dest); \}#define handle_incdec(opstr,op,wFlag) \	if(wFlag) \	{ \		handle_incdec16(opstr,op) \	} \	else \	{ \		handle_incdec8(opstr,op) \	}

⌨️ 快捷键说明

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