Editor support for PUSHF and POPF

This commit is contained in:
simon 2018-01-20 09:44:09 -05:00
parent f3de9c4c74
commit 3ce8fba3cd
4 changed files with 7 additions and 7 deletions

View File

@ -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|inc|dec|rcl|xchg|rcr)\\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|inc|dec|rcl|xchg|rcr|pushf|popf)\\b',
caseInsensitive: true
},
{

View File

@ -1,4 +1,4 @@
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|inc|dec|rcl|xchg|rcr)\\b",caseInsensitive:!0},{token:"keyword.operator.assembly",regex:"\\b(?:call|ret|jmp|jnz|jg|jl|jge|jle|hwi|jz|js|jns|jc|jnc|jo|jno)\\b",
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|inc|dec|rcl|xchg|rcr|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|jo|jno)\\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});

View File

@ -261,7 +261,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|inc|dec|rcl|xchg|rcr)\\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|inc|dec|rcl|xchg|rcr|pushf|popf)\\b').test(mnemonic.toLowerCase())) {
if (line.indexOf(",") !== -1) {
@ -319,7 +319,7 @@ function parseInstruction(line, result, currentLine) {
strO1 = line.substring(line.indexOf(mnemonic) + mnemonic.length).trim();
//Validate operand number
if (!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|inc|dec)\\b').test(mnemonic.toLowerCase())) {
if (!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|inc|dec|popf)\\b').test(mnemonic.toLowerCase())) {
result.annotations.push({
row: currentLine,
column: 0,
@ -342,7 +342,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)\\b').test(mnemonic.toLowerCase())) {
//Validate operand number
result.annotations.push({

4
mar/editor.min.js vendored
View File

@ -10,9 +10,9 @@ function parseDWInstruction(a,c,b){a=a.trim();if("dw"===a.substr(0,2).toLowerCas
column:0,text:"Usage: DW IMM, IMM ...",type:"error"});break}}return!0}return!1}
function getOperandType(a,c){a=a.trim();if(""===a)return OPERAND_INVALID;if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a))&&-1===a.indexOf("o")&&0!==a.indexOf("0e"))return OPERAND_IMM;if(/^(a|b|c|d|x|y|bp|sp)$/.test(a.toLowerCase()))return OPERAND_REG;for(b=0;b<c.labels.length;b++)if(a===c.labels[b])return OPERAND_IMM;if(a.startsWith("[")&&a.endsWith("]")){a=a.replace("[","").replace("]","");if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_IMM;for(var b=0;b<c.labels.length;b++)if(a===
c.labels[b])return OPERAND_MEM_IMM;if(/^(bp|sp)$/.test(a.toLowerCase().substring(0,2).toLowerCase()))a=a.substring(2);else if(/^(a|b|c|d|x|y)$/.test(a.toLowerCase().substring(0,1).toLowerCase()))a=a.substring(1);else return OPERAND_INVALID;if(""===a.replace(/\s+/g,""))return OPERAND_MEM_REG;a=a.replace(/\s+/g,"");for(b=0;b<c.labels.length;b++)if(a.substring(1)===c.labels[b])return OPERAND_MEM_REG;a=a.replace(/[+-]/,"");if(!isNaN(Number(a))&&Number(a)===Math.floor(Number(a)))return OPERAND_MEM_REG}return OPERAND_INVALID}
function parseInstruction(a,c,b){a=removeComment(a);a=removeLabel(a);var d=getTokens(a),e=d[0];if(void 0!==e&&""!==e&&!parseDWInstruction(a,c,b))if(/\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|inc|dec|rcl|xchg|rcr)\b/.test(e.toLowerCase()))if(-1!==a.indexOf(","))if(d=a.substring(a.indexOf(e)+e.length,a.indexOf(",")),a=a.substring(a.indexOf(",")+1).trim(),/\b(?:mov|add|sub|and|or|test|cmp|shl|shr|xor|rol|ror|sal|sar|rcl|xchg|rcr)\b/.test(e.toLowerCase())){e=
function parseInstruction(a,c,b){a=removeComment(a);a=removeLabel(a);var d=getTokens(a),e=d[0];if(void 0!==e&&""!==e&&!parseDWInstruction(a,c,b))if(/\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|inc|dec|rcl|xchg|rcr|pushf|popf)\b/.test(e.toLowerCase()))if(-1!==a.indexOf(","))if(d=a.substring(a.indexOf(e)+e.length,a.indexOf(",")),a=a.substring(a.indexOf(",")+1).trim(),/\b(?:mov|add|sub|and|or|test|cmp|shl|shr|xor|rol|ror|sal|sar|rcl|xchg|rcr)\b/.test(e.toLowerCase())){e=
getOperandType(d,c);var f=getOperandType(a,c);e===OPERAND_INVALID?c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):f===OPERAND_INVALID?c.annotations.push({row:b,column:0,text:"Invalid operand: "+a,type:"error"}):e===OPERAND_IMM&&c.annotations.push({row:b,column:0,text:"Destination operand can't be an immediate value",type:"error"})}else c.annotations.push({row:b,column:0,text:e+" instruction with 2 operands is illegal",type:"error"});else 1<d.length?(d=a.substring(a.indexOf(e)+
e.length).trim(),/\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc|jo|jno|inc|dec)\b/.test(e.toLowerCase())?getOperandType(d,c)===OPERAND_INVALID&&c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):c.annotations.push({row:b,column:0,text:e+" instruction with 1 operand is illegal",type:"error"})):/\b(?:ret|brk|nop)\b/.test(e.toLowerCase())||c.annotations.push({row:b,column:0,text:e+" instruction with no operand is illegal",type:"error"});
e.length).trim(),/\b(?:push|mul|pop|div|neg|call|jnz|jg|jl|jge|jle|hwi|hwq|jz|js|jns|ret|jmp|not|jc|jnc|jo|jno|inc|dec|popf)\b/.test(e.toLowerCase())?getOperandType(d,c)===OPERAND_INVALID&&c.annotations.push({row:b,column:0,text:"Invalid operand: "+d,type:"error"}):c.annotations.push({row:b,column:0,text:e+" instruction with 1 operand is illegal",type:"error"})):/\b(?:ret|brk|nop|pushf)\b/.test(e.toLowerCase())||c.annotations.push({row:b,column:0,text:e+" instruction with no operand is illegal",type:"error"});
else c.annotations.push({row:b,column:0,text:"Unknown mnemonic: "+e,type:"error"})}function parse(){for(var a=ace.edit("editor").getValue().split("\n"),c={labels:[],annotations:[]},b=0;b<a.length;b++)checkForLabel(a[b],c);for(b=0;b<a.length;b++)checkForSegmentDeclaration(a[b])||checkForEQUInstruction(a[b],c,b)||checkForORGInstruction(a[b],c,b)||parseInstruction(a[b],c,b);editor.getSession().setAnnotations(c.annotations)}
function gameClick(){document.getElementById("editorBtns").setAttribute("style","display: none");document.getElementById("gameBtns").setAttribute("style","")}function editorClick(){document.getElementById("editorBtns").setAttribute("style","");document.getElementById("gameBtns").setAttribute("style","display: none")}var editorStorage;editorStorage="undefined"!==typeof window.localStorage?window.localStorage:!1;
var editorThemeOptions={available:"theme/ambiance theme/chaos theme/chrome theme/clouds theme/clouds_midnight theme/cobalt theme/crimson_editor theme/dawn theme/dracula theme/dreamweaver theme/eclipse theme/github theme/gob theme/gruvbox theme/idle_fingers theme/iplastic theme/katzenmilch theme/kr_theme theme/kuroir theme/merbivore theme/merbivore_soft theme/mono_industrial theme/monokai theme/pastel_on_dark theme/solarized_dark theme/solarized_light theme/sqlserver theme/terminal theme/textmate theme/tomorrow theme/tomorrow_night_blue theme/tomorrow_night_bright theme/tomorrow_night_eighties theme/tomorrow_night theme/twilight theme/vibrant_ink theme/xcode".split(" "),defaultTheme:"theme/tomorrow"};