/* * Copyright (C) 2010 Tobias Klauser * * This file is part of nios2sim-ng. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #include "nios2sim-ng.h" #include "instruction.h" #include "nios2.h" /* * J-Type instructions */ uint32_t call(struct nios2 *cpu, uint32_t opcode) { J_TYPE(instr, opcode); return PC_INC_BY_INSTR; } uint32_t jmpi(struct nios2 *cpu, uint32_t opcode) { J_TYPE(instr, opcode); return PC_INC_BY_INSTR; } /* * I-Type instructions */ uint32_t ldbu(struct nios2 *cpu, uint32_t opcode) { I_TYPE(instr, opcode); return PC_INC_NORMAL; } uint32_t addi(struct nios2 *cpu, uint32_t opcode) { I_TYPE(instr, opcode); /* rB <- rA + IMM16 */ cpu->gp_regs[instr->b] = cpu->gp_regs[instr->a] + (int16_t) (instr->imm16); return PC_INC_NORMAL; } instruction_handler i_type_inst_handlers[I_TYPE_COUNT] = { [CALL] = call, [JMPI] = jmpi, [LDBU] = ldbu, [ADDI] = addi, };