Skip to content

Commit

Permalink
Change SP++ and --SP arguments to require brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
niligulmohar committed Aug 23, 2012
1 parent a0a56f6 commit feb6227
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion lib/assembler.js
Expand Up @@ -362,8 +362,14 @@ Assembler.prototype = {

//0x18: POP / [SP++], PUSH / [--SP]
case 'sp++':
case 'pop':
case '--sp':
if(pointer) {
pack(0x18);
} else {
throw new Error("Argument " + arg + " not allowed without pointer brackets");
}
break;
case 'pop':
case 'push':
pack(0x18);
break;
Expand Down
6 changes: 3 additions & 3 deletions test/assembler_test.js
Expand Up @@ -204,9 +204,9 @@ module.exports = {
'[SP++]/[--SP] values should also be encoded as 18': function() {
assert.eql(memoryForAssembly("SET [sp++], [--sp]"), [0x18 << 10 | 0x18 << 5 | 1]);
},
// 'SP++/--SP values should not be allowed without pointer brackets': function() {
// assert.throws(function () { memoryForAssembly("SET sp++, --sp"); });
// },
'SP++/--SP values should not be allowed without pointer brackets': function() {
assert.throws(function () { memoryForAssembly("SET sp++, --sp"); });
},
'PEEK values should be encoded as 19': function() {
assert.eql(memoryForAssembly("SET peek, peek"), [0x19 << 10 | 0x19 << 5 | 1]);
},
Expand Down

0 comments on commit feb6227

Please sign in to comment.