From 509b04ea184ff8a27af11aeb94977b19319737fb Mon Sep 17 00:00:00 2001 From: Ethan Lafrenais Date: Sun, 31 Dec 2017 18:22:31 -0500 Subject: [PATCH] Add editor support for PUSHF and POPF --- mar/ace/mode-mar.js | 2 +- mar/ace/mode-mar.min.js | 5 +---- mar/editor.js | 4 ++-- mar/editor.min.js | 18 +----------------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/mar/ace/mode-mar.js b/mar/ace/mode-mar.js index 922b5a6..4fc68ca 100755 --- a/mar/ace/mode-mar.js +++ b/mar/ace/mode-mar.js @@ -47,7 +47,7 @@ define("ace/mode/mar_rules", ["require", "exports", "module", "ace/lib/oop", "ac start: [{ token: 'keyword.function.assembly', - regex: '\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|dw|nop|equ|neg|hwq|not|ror|rol|sal|sar)\\b', + regex: '\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|dw|nop|equ|neg|hwq|not|ror|rol|sal|sar|pushf|popf)\\b', caseInsensitive: true }, { diff --git a/mar/ace/mode-mar.min.js b/mar/ace/mode-mar.min.js index 4dbaece..e70564d 100644 --- a/mar/ace/mode-mar.min.js +++ b/mar/ace/mode-mar.min.js @@ -1,4 +1 @@ -define("ace/mode/mar_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(a,d,b){b=a("../lib/oop");a=a("./text_highlight_rules").TextHighlightRules;var c=function(){this.$rules={start:[{token:"keyword.function.assembly",regex:"\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|dw|nop|equ|neg|hwq|not|ror|rol|sal|sar)\\b",caseInsensitive:!0},{token:"keyword.operator.assembly",regex:"\\b(?:call|ret|jmp|jnz|jg|jl|jge|jle|hwi|jz|js|jns|jc|jnc)\\b",caseInsensitive:!0}, -{token:"variable.predefined.ahk",regex:"\\b(?:brk|dup)\\b",caseInsensitive:!0},{token:"variable.parameter.register.assembly",regex:"\\b(?:A|B|C|D|X|Y|bp|sp)\\b",caseInsensitive:!0},{token:"constant.character.decimal.assembly",regex:"\\b[0-9]+\\b"},{token:"constant.character.hexadecimal.assembly",regex:"\\b0x[A-F0-9]+\\b",caseInsensitive:!0},{token:"string.assembly",regex:/"([^\\"]|\\.)*"/},{token:"comment.assembly",regex:";.*$"},{token:"support.function.directive.assembly",regex:/^\.text|\.data/}, -{token:"entity.name.function.assembly",regex:/\w*:/}]};this.normalizeRules()};c.metaData={fileTypes:["asm"],name:"Much Assembly Required",scopeName:"source.assembly"};b.inherits(c,a);d.MarHighlightRules=c}); -define("ace/mode/mar","require exports module ace/lib/oop ace/mode/text ace/mode/mar_rules".split(" "),function(a,d,b){b=a("../lib/oop");var c=a("./text").Mode,e=a("./mar_rules").MarHighlightRules;a=function(){this.HighlightRules=e;this.$behaviour=this.$defaultBehaviour};b.inherits(a,c);a.prototype.lineCommentStart=";";a.prototype.$id="ace/mode/mar";d.Mode=a}); +define("ace/mode/mar_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,s){"use strict";var a=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,r=function(){this.$rules={start:[{token:"keyword.function.assembly",regex:"\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|dw|nop|equ|neg|hwq|not|ror|rol|sal|sar|pushf|popf)\\b",caseInsensitive:!0},{token:"keyword.operator.assembly",regex:"\\b(?:call|ret|jmp|jnz|jg|jl|jge|jle|hwi|jz|js|jns|jc|jnc)\\b",caseInsensitive:!0},{token:"variable.predefined.ahk",regex:"\\b(?:brk|dup)\\b",caseInsensitive:!0},{token:"variable.parameter.register.assembly",regex:"\\b(?:A|B|C|D|X|Y|bp|sp)\\b",caseInsensitive:!0},{token:"constant.character.decimal.assembly",regex:"\\b[0-9]+\\b"},{token:"constant.character.hexadecimal.assembly",regex:"\\b0x[A-F0-9]+\\b",caseInsensitive:!0},{token:"string.assembly",regex:/"([^\\"]|\\.)*"/},{token:"comment.assembly",regex:";.*$"},{token:"support.function.directive.assembly",regex:/^\.text|\.data/},{token:"entity.name.function.assembly",regex:/\w*:/}]},this.normalizeRules()};r.metaData={fileTypes:["asm"],name:"Much Assembly Required",scopeName:"source.assembly"},a.inherits(r,i),t.MarHighlightRules=r}),define("ace/mode/mar",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/mar_rules"],function(e,t,s){"use strict";var a=e("../lib/oop"),i=e("./text").Mode,r=e("./mar_rules").MarHighlightRules,o=function(){this.HighlightRules=r,this.$behaviour=this.$defaultBehaviour};a.inherits(o,i),function(){this.lineCommentStart=";",this.$id="ace/mode/mar"}.call(o.prototype),t.Mode=o}); \ No newline at end of file diff --git a/mar/editor.js b/mar/editor.js index f88dcd5..fd04206 100644 --- a/mar/editor.js +++ b/mar/editor.js @@ -257,7 +257,7 @@ function parseInstruction(line, result, currentLine) { if (!parseDWInstruction(line, result, currentLine)) { if (new RegExp('\\b(?:mov|add|sub|and|or|test|cmp|shl|shr|mul|push|pop|div|xor|hwi|hwq|nop|neg|' + - 'call|ret|jmp|jnz|jg|jl|jge|jle|int|jz|js|jns|brk|not|jc|jnc|ror|rol|sal|sar|jo|jno)\\b').test(mnemonic.toLowerCase())) { + 'call|ret|jmp|jnz|jg|jl|jge|jle|int|jz|js|jns|brk|not|jc|jnc|ror|rol|sal|sar|jo|jno|pushf|popf)\\b').test(mnemonic.toLowerCase())) { if (line.indexOf(",") !== -1) { @@ -338,7 +338,7 @@ function parseInstruction(line, result, currentLine) { } else { //No operand - if (!new RegExp('\\b(?:ret|brk|nop)\\b').test(mnemonic.toLowerCase())) { + if (!new RegExp('\\b(?:ret|brk|nop|pushf|popf)\\b').test(mnemonic.toLowerCase())) { //Validate operand number result.annotations.push({ diff --git a/mar/editor.min.js b/mar/editor.min.js index 0898478..3a0f155 100644 --- a/mar/editor.min.js +++ b/mar/editor.min.js @@ -1,17 +1 @@ -var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.checkStringArgs=function(a,c,b){if(null==a)throw new TypeError("The 'this' value for String.prototype."+b+" must not be null or undefined");if(c instanceof RegExp)throw new TypeError("First argument to String.prototype."+b+" must not be a regular expression");return a+""};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1; -$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this); -$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".");for(d=0;d=f}},"es6","es3"); -$jscomp.polyfill("String.prototype.endsWith",function(a){return a?a:function(a,b){var c=$jscomp.checkStringArgs(this,a,"endsWith");a+="";void 0===b&&(b=c.length);b=Math.max(0,Math.min(b|0,c.length));for(var e=a.length;0=e}},"es6","es3");OPERAND_INVALID=-1;OPERAND_REG=0;OPERAND_MEM_IMM=1;OPERAND_MEM_REG=2;OPERAND_IMM=3;editor=ace.edit("editor");editor.session.setOption("useWorker",!1);editor.$blockScrolling=Infinity; -function removeComment(a){return-1!==a.indexOf(";")?a.substring(0,a.indexOf(";")):a}function checkForLabel(a,c){a=removeComment(a);var b;null!==(b=/\b\w*\b:/.exec(a))&&c.labels.push(b[0].substring(0,b[0].length-1))}function checkForSegmentDeclaration(a){a=getTokens(a);return void 0!==a[0]&&(".data"===a[0].toLowerCase()||".text"===a[0].toLowerCase())} -function checkForEQUInstruction(a,c,b){var d=getTokens(a);return-1!==a.toLowerCase().indexOf(" equ ")||void 0!==d[1]&&"equ"===d[1].toLowerCase()?(a=Number(d[2]),isNaN(a)||a!==Math.floor(a)?c.annotations.push({row:b,column:0,text:"Usage: constant_name EQU immediate_value",type:"error"}):c.labels.push(d[0]),!0):!1}function getTokens(a){a=a.split(/\s+/);for(var c=0;c1){var s=Number(n[1]);return!isNaN(s)&&s===Math.floor(s)||(t.annotations.push({row:r,column:0,text:"Invalid operand: "+n[1],type:"error"}),!0)}}function parseDWInstruction(e,t,r){if(e=e.trim(),"dw"===e.substr(0,2).toLowerCase()){for(var n=e.substr(2,e.length).split(/,(?=(?:[^"]*"[^"]*")*[^"]*$)/,-1),o=0;o1){if(s=e.substring(e.indexOf(o)+o.length).trim(),!new RegExp("\\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc|jo|jno)\\b").test(o.toLowerCase()))return void t.annotations.push({row:r,column:0,text:o+" instruction with 1 operand is illegal",type:"error"});getOperandType(s,t)===OPERAND_INVALID&&t.annotations.push({row:r,column:0,text:"Invalid operand: "+s,type:"error"})}else new RegExp("\\b(?:ret|brk|nop|pushf|popf)\\b").test(o.toLowerCase())||t.annotations.push({row:r,column:0,text:o+" instruction with no operand is illegal",type:"error"});else t.annotations.push({row:r,column:0,text:"Unknown mnemonic: "+o,type:"error"})}function parse(){for(var e=ace.edit("editor").getValue(),t=e.split("\n"),r={labels:[],annotations:[]},n=0;n