Files
Brian Holman 5534005799 Sync VCC Plus 3.7.1 build 67 source
Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
2026-11-17 08:42:27 -07:00

39 lines
1.8 KiB
C++

// SPDX-License-Identifier: GPL-3.0-or-later
// Exercise the actual built compiler rule; expose its private entry only in
// this test translation unit. Vendor sources and normal objects stay unchanged.
#include "util.h"
#include <utility>
#include <functional>
#define private public
#include "ASMText.h"
#undef private
#include <iostream>
#include <stdexcept>
void check(const char* first, const char* middleOp, const char* middle, const char* last, bool expectRemoval) {
ASMText text(true, false); // Standard optimization; experimental DCE stays off.
text.ins("LDB", first); text.ins(middleOp, middle); text.ins("LDB", last);
const bool removed = text.removeUselessLdaOrLdb(0);
if (removed != expectRemoval) throw std::runtime_error(std::string(first) + "; " + middleOp + " " + middle + "; LDB " + last);
}
int main() {
try {
check("5,U", "LDX", "#array", "D,X", false);
check("5,U", "LDX", "#array", "B,X", false);
check("5,U", "LDX", "#array", "[D,X]", false);
check("5,U", "LDX", "#array", "[B,X]", false);
check("5,U", "LDX", "D,Y", ",X", false);
check("5,U", "LDX", "B,Y", ",X", false);
check("5,U", "LDX", "[D,Y]", ",X", false);
check("5,U", "LEAX", "D,Y", ",X", false);
check("5,U", "LEAX", "B,Y", ",X", false);
check(",S+", "LDX", "#array", ",X", false);
check(",--X", "LDX", "#array", ",X", false);
check("[,Y++]", "LDX", "#array", ",X", false);
check("[,--U]", "LDX", "#array", ",X", false);
check("5,U", "LDX", "#array", ",X", true);
check("5,U", "LEAX", "4,Y", "4,X", true);
std::cout << "PASS indexed-load rule: 13 dependency/side-effect guards, 2 safe removals\n";
return 0;
} catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 1; }
}