Skip to content
Permalink
Browse files

Merge pull request #150 from Prof9/initial-negative-headersize

Allow negative virtual addresses with a warning, as long as the physical address is still non-negative.
  • Loading branch information...
sp1187 committed May 19, 2019
2 parents 8de6978 + 9fb1eae commit 4ccd15a1217c203407498cb717d242ee06ec6012
Showing with 8 additions and 4 deletions.
  1. +8 −4 Core/FileManager.cpp
@@ -166,11 +166,13 @@ bool GenericAssemblerFile::write(void* data, size_t length)

bool GenericAssemblerFile::seekVirtual(int64_t virtualAddress)
{
if (virtualAddress - headerSize < 0 || virtualAddress < 0)
if (virtualAddress - headerSize < 0)
{
Logger::queueError(Logger::Error,L"Seeking to invalid address");
Logger::queueError(Logger::Error,L"Seeking to virtual address with negative physical address");
return false;
}
if (virtualAddress < 0)
Logger::queueError(Logger::Warning,L"Seeking to negative virtual address");

this->virtualAddress = virtualAddress;
int64_t physicalAddress = virtualAddress-headerSize;
@@ -183,11 +185,13 @@ bool GenericAssemblerFile::seekVirtual(int64_t virtualAddress)

bool GenericAssemblerFile::seekPhysical(int64_t physicalAddress)
{
if (physicalAddress < 0 || physicalAddress + headerSize < 0)
if (physicalAddress < 0)
{
Logger::queueError(Logger::Error,L"Seeking to invalid address");
Logger::queueError(Logger::Error,L"Seeking to negative physical address");
return false;
}
if (physicalAddress + headerSize < 0)
Logger::queueError(Logger::Warning,L"Seeking to physical address with negative virtual address");

virtualAddress = physicalAddress+headerSize;

0 comments on commit 4ccd15a

Please sign in to comment.
You can’t perform that action at this time.