Skip to content

Instantly share code, notes, and snippets.

@hawkw
Last active December 16, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hawkw/5493266 to your computer and use it in GitHub Desktop.
Save hawkw/5493266 to your computer and use it in GitHub Desktop.
I feel bad that I wrote this. Also featuring a sad attempt at injecting comments into terrible code.
while (!filterQueue.empty()) {
// if we find a comment-closing character...
if (filterQueue.front().contains("(")) {
// ...pop until we find a comment character
while (!filterQueue.empty()
&& !filterQueue.front().contains(")")) {
filterQueue.dequeue();
}
if (!filterQueue.empty())
filterQueue.dequeue();
// if we don't find a comment opening character...
} else if (filterQueue.front().contains("S\"")) { // ...but we find a string...
s = new StringBuilder();
filterQueue.dequeue();
do {
s.append(filterQueue.dequeue() + " ");
} while (!filterQueue.empty()
&& !filterQueue.front().contains("\""));
filterQueue.dequeue();
currentAddress = Integer.parseInt(filterQueue.dequeue(), 16);
if (verboseMode)
System.out.println("-> fillRAM " + Word.wordBuilder(0x14, currentAddress));
engine.fillRAM(Word.wordBuilder(0x14, currentAddress));
engine.writeToRAM(Word.wordBuilder(s.toString()), engine.parseHex(Integer.toHexString(currentAddress)));
} else {
// ...everything is fine and good!
if (getReqArgs(filterQueue.front()) == 1) {
currentInstruction = getOpcode(filterQueue.dequeue());
currentAddress = Integer.parseInt(filterQueue.dequeue(), 16);
if (verboseMode)
System.out.println("-> fillRAM " + Word.wordBuilder(currentInstruction, currentAddress));
engine.fillRAM(Word.wordBuilder(currentInstruction, currentAddress));
} else if (getReqArgs(filterQueue.front()) == 0) {
currentInstruction = getOpcode(filterQueue.dequeue());
if (verboseMode) {
System.out.println("-> fillRAM "+ Word.wordBuilder(currentInstruction));
engine.fillRAM(Word.wordBuilder(currentInstruction));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment