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

📄 opcode.c

📁 开发源代码的CPU卡的COS源程序。
💻 C
字号:
/* ============================================================================   Project Name : jayaCard   Module Name  : proto/bios/patch/opcode.c   Version : $Id: opcode.c,v 1.12 2004/01/11 09:56:31 dgil Exp $	Description: opcode management    The Original Code is jayaCard code.    The Initial Developer of the Original Code is Gilles Dumortier.	Portions created by the Initial Developer are Copyright (C) 2002-2004 the    Initial Developer. All Rights Reserved.    Contributor(s):    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; see http://www.gnu.org/licenses/gpl.html	History Rev	Description   012603 dgil	wrote it from scratch - today we have an entry point !   ============================================================================*/#include "precomp.h"/* ============================================================================	Given the opcode number OPCODE_x, tab_opcode_ind[OPCODE_x] -> executable 	code address ADDR_OPCODE_x in EEPROM   ========================================================================= */extern jword code tab_opcode_ind[NUM_OPCODES];/* ============================================================================	__bios_call_opcode()	Given the opcode number, check the opcode and jump to only if it is a	valid executable address.	Return		JSEC_FAIL	invalid opcode or opcode can't do the work		JSEC_OK		valid opcode then opcode have done the work   ========================================================================= */struct {	jword	aexec;	jword	crc;} xdata exec;jbyte __bios_call_opcode(jbyte nexec){	/* check opcode number */	if (nexec>sizeof(tab_opcode_ind)/sizeof(tab_opcode_ind[0])) {		LOG1("ATTACK","__bios_call_opcode() opcode=%d invalid !",nexec);		HAL_HALT();		return JSEC_FAIL;	}	/* read address of opcode from memory */	HAL_EEPROM_READ((jbyte xdata*)&exec,tab_opcode_ind[nexec],4);	HAL_CRC_INIT();	HAL_CRC_COMPUTE(HIBYTE(exec.aexec));	HAL_CRC_COMPUTE(LOBYTE(exec.aexec));	if ( (HAL_CRC_LO()!=LOBYTE(exec.crc)) || (HAL_CRC_HI()!=HIBYTE(exec.crc)) ) {		/* no optional code */		return JSEC_FAIL;	}	/* optional code / jump to */	return HAL_CALL(exec.aexec);}/* =========================================================================	That's all folks !   ========================================================================= */

⌨️ 快捷键说明

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