mirror of
https://github.com/simon987/Much-Assembly-Required-Frontend.git
synced 2025-04-10 14:26:44 +00:00
Fixed POPF parsing in editor
This commit is contained in:
parent
bf88eb87a2
commit
352bfef375
@ -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|popf)\\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)\\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|pushf)\\b').test(mnemonic.toLowerCase())) {
|
||||
if (!new RegExp('\\b(?:ret|brk|nop|pushf|popf)\\b').test(mnemonic.toLowerCase())) {
|
||||
|
||||
//Validate operand number
|
||||
result.annotations.push({
|
||||
|
2
mar/editor.min.js
vendored
2
mar/editor.min.js
vendored
@ -12,7 +12,7 @@ function getOperandType(a,c){a=a.trim();if(""===a)return OPERAND_INVALID;if(!isN
|
||||
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|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|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"});
|
||||
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|pushf|popf)\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"};
|
||||
|
Loading…
x
Reference in New Issue
Block a user