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

📄 instr.c

📁 DM64+系列 interpreter 程序
💻 C
字号:
/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
 
#include "instr.h"
#include "utils.h"

/* 
The following functions contain the implementation 
of all the instructions supported by the interpreter
*/


void add(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = get_index(src);

	REG(i) = REG(i) + REG(j);
}


void addi(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = strtol(src,NULL,10);

	REG(i) = REG(i) + j;
}

void sub(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = get_index(src);

	REG(i) = REG(i) - REG(j);
}

void subi(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = strtol(src,NULL,10);

	REG(i) = REG(i) - j;
}


void mult(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = get_index(src);

	REG(i) = REG(i) * REG(j);
}


void multi(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = strtol(src,NULL,10);

	REG(i) = REG(i) * j;
}


void my_div(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = get_index(src);
	
	if (REG(j)){
		REG(i) = REG(i) / REG(j);
	}
	else{
		fprintf(stderr,"Divide by zero error\n");
	}
}


void divi(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = strtol(src,NULL,10);

	if (j){
		REG(i) = REG(i) / j;
	}
	else{
		fprintf(stderr,"Divide by zero error\n");
	}
}


void mov(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = get_index(src);

	REG(i) = REG(j);
}


void movi(char * dest, char * src){
	int i = 0;
	int j = 0;
	i = get_index(dest);
	j = strtol(src,NULL,10);

	REG(i) =  j;
}


void read_src(char * src){
	int i = 0;
	i = get_index(src);
	scanf("%d",&REG(i));
}

void write_dest(char * dest){
	int i = 0;
	i = get_index(dest);
	printf("%s = %d\n",dest,REG(i));
}




⌨️ 快捷键说明

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