Fix a bug in dcpu_skip, add a test program.#15
Open
aaronferrucci wants to merge 5 commits intoswetland:masterfrom
Open
Fix a bug in dcpu_skip, add a test program.#15aaronferrucci wants to merge 5 commits intoswetland:masterfrom
aaronferrucci wants to merge 5 commits intoswetland:masterfrom
Conversation
added 5 commits
April 17, 2012 22:33
misses the pc increment for the b operand in a basic instruction. The test shows that a 3-word instruction is not properly skipped. The 3rd word of the instruction (SET [0x1000], [0xEEE0]), when mistakenly interpreted as the 1st word of the next instruction, causes an illegal opcode bailout in the monitor.
…l non-basic opcodes to use as an emulator success code.
… for non-basic opcodes) could overflow skiptable, when used as an index. Masking the operand to force it within the table size has its own problem, as it causes aliasing from some constant operands to operands which "advance pc". Example: c00d 009c: IFN A, 16 fc03 009d: SUB A, 31 The constant 31 in the second instruction is 'b' operand value 0x3F. If masked with 31 (0x1F) to stay within the table, it becomes 0x1F, which has value 1 within skiptable - that's incorrect, the constant does not require another instruction word. The solution in this commit tries to perturb the existing code as little as possible; I just bump skiptable up to 64-locations, so there's no need to mask the operand before using it as an index. The other change is to update the mask on the basic-opcode 'a' operand so that literals are handled correcty for that operand as well. I've included a test case, "testskip3.s", which fails before the fix and passes after the fix. All 32 literal operand values for the 'b' operand are tested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've found and fixed a big in dcpu_skip, have a look and see if you think it's worth merging with your main branch. I've included a test which fails with the bug, and passes with my fix.