📄 integer_load_instruction.cpp
字号:
/* -*- C++ -*- */
/**
* Copyright (c) 2005 Zhejiang University, P.R.China
*
* 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; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
///==================================================
/**
* @file Integer_Load_Instruction.h
* @brief
* @author Chenfeng Zhou <ini_autumn@163.com>
*
* Created : <2005-02-24 12:58:27 by Cheney Chow>
* Last update: <2005-05-26 20:41:06 by Cheney Chow>
*
* $Id: Integer_Load_Instruction.cpp,v 1.1 2005/06/16 06:01:46 qilj Exp $
*/
///==================================================
#include "Instr_Flag.h"
#include "Instr_Declare.h"
#include "Parser.h"
#include "Register.h"
#include "Types.h"
#include "Reg_Utils.h"
#include "Utils/Debug.h"
#include "MMU.h"
/**
* If there's a data page fault, we exit immediately;
* including the multi-load instructions;
*/
namespace PPC {
PPC_INSTRUCTION_IMPL(op_lbz)
{
PPC_s32 D, A;
PPC_u32 imm;
D_Form_Parser::parse_simm (instr, D, A, imm);
PPC_Address_T start = (A? REG_TO_INT(REG(A)) : 0) + imm;
Core::Bytecode_Type buffer;
Core::u8 val;
PPC_TRACE_1("lbz", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 1, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(D).convert_from_int(val);
}
PPC_INSTRUCTION_IMPL(op_lbzu)
{
PPC_s32 D, A;
PPC_u32 imm;
D_Form_Parser::parse_simm (instr, D, A, imm);
PPC_ASSERT( (A != 0) && (A != D) );
PPC_Address_T start = REG_TO_INT(REG(A)) + imm;
Core::Bytecode_Type buffer;
Core::u8 val;
PPC_TRACE_1("lbzu", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 1, buffer) )
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(A).convert_from_int(REG_TO_INT(REG(A)) + imm);
REG(D).convert_from_int(val);
}
PPC_INSTRUCTION_IMPL(op_lbzux)
{
PPC_s32 D, A, B;
X_Form_Parser::parse_x(instr, D, A, B);
PPC_ASSERT( (A != 0) && (A != D) );
PPC_Address_T start = REG_TO_INT(REG(A)) + REG_TO_INT(REG(B));
Core::Bytecode_Type buffer;
Core::u8 val;
PPC_TRACE_1("lbzux", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 1, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(A).convert_from_int(REG_TO_INT(REG(A)) + REG_TO_INT(REG(B)));
REG(D).convert_from_int(val);
}
PPC_INSTRUCTION_IMPL(op_lbzx)
{
PPC_s32 D, A, B;
X_Form_Parser::parse_x(instr, D, A, B);
PPC_Address_T start = (A? REG_TO_INT(REG(A)) : 0) + REG_TO_INT(REG(B));
Core::Bytecode_Type buffer;
Core::u8 val;
PPC_TRACE_1("lbzx", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 1, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(D).convert_from_int(val);
}
PPC_INSTRUCTION_IMPL(op_lha)
{
PPC_s32 D, A;
PPC_u32 imm;
D_Form_Parser::parse_simm (instr, D, A, imm);
PPC_Address_T start = (A? REG_TO_INT(REG(A)) : 0) + imm;
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lha", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
// REG(D)'s high 16 bit is filled with the most significant bit of val
REG(D).convert_from_int( (val & 0x8000)? (val | 0xffff0000) : val );
}
PPC_INSTRUCTION_IMPL(op_lhau)
{
PPC_s32 D, A;
PPC_u32 imm;
D_Form_Parser::parse_simm (instr, D, A, imm);
PPC_ASSERT(A != 0);
PPC_Address_T start = REG_TO_INT(REG(A)) + imm;
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lhau", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(A).convert_from_int(REG_TO_INT(REG(A)) + imm);
REG(D).convert_from_int( (val & 0x8000)? (val | 0xffff0000) : val );
}
PPC_INSTRUCTION_IMPL(op_lhaux)
{
PPC_s32 D, A, B;
X_Form_Parser::parse_x(instr, D, A, B);
PPC_ASSERT(A != 0);
PPC_Address_T start = REG_TO_INT(REG(A)) + REG_TO_INT(REG(B));
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lhaux", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(A).convert_from_int(REG_TO_INT(REG(A)) + REG_TO_INT(REG(B)));
REG(D).convert_from_int( (val & 0x8000)? (val | 0xffff0000) : val );
}
PPC_INSTRUCTION_IMPL(op_lhax)
{
PPC_s32 D, A, B;
X_Form_Parser::parse_x(instr, D, A, B);
PPC_ASSERT(A != 0);
PPC_Address_T start = (A? REG_TO_INT(REG(A)) : 0) + REG_TO_INT(REG(B));
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lhax", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(D).convert_from_int( (val & 0x8000)? (val | 0xffff0000) : val );
}
PPC_INSTRUCTION_IMPL(op_lhz)
{
PPC_s32 D, A;
PPC_u32 imm;
D_Form_Parser::parse_simm (instr, D, A, imm);
PPC_Address_T start = (A? REG_TO_INT(REG(A)) : 0) + imm;
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lhz", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(D).convert_from_int(val);
}
PPC_INSTRUCTION_IMPL(op_lhzu)
{
PPC_s32 D, A;
PPC_u32 imm;
D_Form_Parser::parse_simm (instr, D, A, imm);
PPC_ASSERT(A != 0);
PPC_Address_T start = REG_TO_INT(REG(A)) + imm;
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lhzu", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
PPC_TRACE_RETURN("mmu access fault\n");
Core::Wukong_Get_System().convert_from_bytecode(buffer, val);
REG(A).convert_from_int(REG_TO_INT(REG(A)) + imm);
REG(D).convert_from_int(val);
}
PPC_INSTRUCTION_IMPL(op_lhzux)
{
PPC_s32 D, A, B;
X_Form_Parser::parse_x(instr, D, A, B);
PPC_ASSERT(A != 0);
PPC_Address_T start = REG_TO_INT(REG(A)) + REG_TO_INT(REG(B));
Core::Bytecode_Type buffer;
Core::u16 val;
PPC_TRACE_1("lhzux", (Core::u32*)start);
if (MMU::ACCESS_FAULT == GET_MMU().access(Core::Memory_32Bit::MEMORY_READ, start, 2, buffer))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -