Skip to content

Commit

Permalink
Use CPU register A for single byte parameter and returns
Browse files Browse the repository at this point in the history
  • Loading branch information
drmortalwombat committed Jan 10, 2023
1 parent 9a64bcc commit d6fcb5f
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 32 deletions.
6 changes: 3 additions & 3 deletions oscar64/Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LinkerRegion::LinkerRegion(void)
{}

LinkerSection::LinkerSection(void)
: mObjects(nullptr), mSections(nullptr)
: mObjects(nullptr), mSections(nullptr), mFlags(0)
{}


Expand Down Expand Up @@ -248,7 +248,7 @@ bool LinkerRegion::Allocate(Linker * linker, LinkerObject* lobj)
int start = (mFreeChunks[i].mStart + lobj->mAlignment - 1) & ~(lobj->mAlignment - 1);
int end = start + lobj->mSize;

if (!(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && (lobj->mFlags & LOBJF_NO_CROSS) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00))
if (!(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && (lobj->mFlags & LOBJF_NO_CROSS) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00) && !(lobj->mSection->mFlags & LSECF_PACKED))
;
else if (end <= mFreeChunks[i].mEnd)
{
Expand Down Expand Up @@ -282,7 +282,7 @@ bool LinkerRegion::Allocate(Linker * linker, LinkerObject* lobj)
int start = (mStart + mUsed + lobj->mAlignment - 1) & ~(lobj->mAlignment - 1);
int end = start + lobj->mSize;

if (!(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && (lobj->mFlags & LOBJF_NO_CROSS) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00))
if (!(linker->mCompilerOptions & COPT_OPTIMIZE_CODE_SIZE) && (lobj->mFlags & LOBJF_NO_CROSS) && !(lobj->mFlags & LOBJF_FORCE_ALIGN) && lobj->mSize <= 256 && (start & 0xff00) != ((end - 1) & 0xff00) && !(lobj->mSection->mFlags & LSECF_PACKED))
{
start = (start + 0x00ff) & 0xff00;
end = start + lobj->mSize;
Expand Down
12 changes: 12 additions & 0 deletions oscar64/Linker.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class LinkerReference
uint32 mFlags;
};

static const uint32 LSECF_PACKED = 0x00000001;

class LinkerSection
{
public:
Expand All @@ -121,6 +123,7 @@ class LinkerSection

int mStart, mEnd, mSize;
LinkerSectionType mType;
uint32 mFlags;

LinkerSection(void);

Expand All @@ -137,6 +140,15 @@ static const uint32 LOBJF_RELEVANT = 0x00000020;
static const uint32 LOBJF_STATIC_STACK = 0x00000040;
static const uint32 LOBJF_NO_CROSS = 0x00000080;
static const uint32 LOBJF_ZEROPAGE = 0x00000100;
static const uint32 LOBJF_FORCE_ALIGN = 0x00000200;

static const uint32 LOBJF_ARG_REG_A = 0x00001000;
static const uint32 LOBJF_ARG_REG_X = 0x00002000;
static const uint32 LOBJF_ARG_REG_Y = 0x00004000;

static const uint32 LOBJF_RET_REG_A = 0x00010000;
static const uint32 LOBJF_RET_REG_X = 0x00020000;


class LinkerObject
{
Expand Down
Loading

0 comments on commit d6fcb5f

Please sign in to comment.