Skip to content

Commit

Permalink
Initial work on psx relocator
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingcom committed Jun 11, 2014
1 parent 3f65fc2 commit 374a59f
Show file tree
Hide file tree
Showing 7 changed files with 608 additions and 17 deletions.
42 changes: 25 additions & 17 deletions Archs/MIPS/Mips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "Core/Directives.h"
#include "Core/FileManager.h"
#include "MipsElfFile.h"
#include "Core/ELF/ElfRelocator.h"
#include "Commands/CDirectiveFile.h"
#include "PsxRelocator.h"

CMipsArchitecture Mips;

Expand Down Expand Up @@ -127,16 +128,6 @@ const tMipsRegister MipsPs2Cop2FpRegister[] = {
{ "vf31", 31, 4}, { "$vf31", 31, 5 }
};



class MipsElfRelocator: public IElfRelocator
{
public:
virtual bool relocateOpcode(int type, RelocationData& data);
virtual void setSymbolAddress(RelocationData& data, unsigned int symbolAddress, int symbolType);
virtual void writeCtorStub(std::vector<ElfRelocatorCtor>& ctors);
};

bool MipsElfRelocator::relocateOpcode(int type, RelocationData& data)
{
unsigned int p;
Expand Down Expand Up @@ -255,17 +246,34 @@ bool MipsDirectiveLoadElf(ArgumentList& list, int flags)
return true;
}

bool MipsDirectiveImportObj(ArgumentList& list, int flags)
{
if (Mips.GetVersion() == MARCH_PSX)
{
DirectivePsxObjImport* command = new DirectivePsxObjImport(list);
AddAssemblerCommand(command);
return true;
}

DirectiveObjImport* command = new DirectiveObjImport(list);
AddAssemblerCommand(command);
return true;
}

const tDirective MipsDirectives[] = {
{ L".resetdelay", 0, 0, &MipsDirectiveResetDelay, 0 },
{ L".fixloaddelay", 0, 0, &MipsDirectiveFixLoadDelay, 0 },
{ L".loadelf", 1, 2, &MipsDirectiveLoadElf, 0 },
{ NULL, 0, 0, NULL, 0 }
{ L".resetdelay", 0, 0, &MipsDirectiveResetDelay, 0 },
{ L".fixloaddelay", 0, 0, &MipsDirectiveFixLoadDelay, 0 },
{ L".loadelf", 1, 2, &MipsDirectiveLoadElf, 0 },
{ L".importobj", 1, 2, &MipsDirectiveImportObj, 0 },
{ L".importlib", 1, 2, &MipsDirectiveImportObj, 0 },
{ NULL, 0, 0, NULL, 0 }
};

bool CMipsArchitecture::AssembleDirective(const std::wstring& name, const std::wstring& args)
{
if (directiveAssembleGlobal(name,args) == true) return true;
return directiveAssemble(MipsDirectives,name,args);
if (directiveAssemble(MipsDirectives,name,args) == true)
return true;
return directiveAssembleGlobal(name,args);
}

CMipsArchitecture::CMipsArchitecture()
Expand Down
9 changes: 9 additions & 0 deletions Archs/MIPS/Mips.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once
#include "Util/CommonClasses.h"
#include "Core/MathParser.h"
#include "Core/ELF/ElfRelocator.h"

enum MipsArchType { MARCH_PSX = 0, MARCH_N64, MARCH_PS2, MARCH_PSP, MARCH_INVALID };

Expand Down Expand Up @@ -82,3 +83,11 @@ bool MipsGetPs2VectorRegister(char* source, int& RetLen, MipsRegisterInfo& Resul
int MipsGetFloatRegister(char* source, int& RetLen);
bool MipsCheckImmediate(char* Source, MathExpression& Dest, int& RetLen);
bool MipsGetVFPURegister(char* line, MipsVFPURegister& reg, int size);

class MipsElfRelocator: public IElfRelocator
{
public:
virtual bool relocateOpcode(int type, RelocationData& data);
virtual void setSymbolAddress(RelocationData& data, unsigned int symbolAddress, int symbolType);
virtual void writeCtorStub(std::vector<ElfRelocatorCtor>& ctors);
};
Loading

0 comments on commit 374a59f

Please sign in to comment.