'+x+"\n";
if (Y.encode_instruction(x,test_opcodes.ASM)) {
Y.DISASM(test_opcodes.ASM.encoded_instruction,test_opcodes.DISASM);
if (test_opcodes.DISASM.instruction != x) {
// putting the tag here should force the browser to go to the first error in the list
test_opcodes.add_message("red",a+"output != input");
test_opcodes.errnum++;
}
}
else {
test_opcodes.add_message("red",a+"error ");
test_opcodes.errnum++;
}
},
scan_opcode_table: function() {
if (test_opcodes.cur_opcode>=test_opcodes.max_opcode) { // last opcode scanned ?
if (test_opcodes.errnum > 0) {
test_opcodes.win.shortmsg(I8N("tcw")+test_opcodes.errnum+I8N("rs"));
document.location.href="#end_error"; // focus qui marche
YGCSS.changeTheme(test_opcodes.win, "doc_red")
}
else {
test_opcodes.win.shortmsg(I8N("Ts"));
YGCSS.changeTheme(test_opcodes.win, "doc_gryl")
}
if (window.list_yas){
test_opcodes.cur_opcode=0;
test_opcodes.scan_examples();
}
}
else {
test_opcodes.HTML="";
var chunk=test_opcodes.chunks; // display "chunks" at a time
while ((chunk > 0) && (test_opcodes.cur_opcode"+int2hex(index)+' : '
+name+' "'+instr.description+'"\n';
// Scan the forms list
var f=instr.forms;
var i=1;
do {
if (f & i) {
var j=Y.TableForm[i];
var k=j.replace(/FORM_/,"");
var v=' -'+j+"";
var w=Y.TableEncoders[j].ex(instr.flags, name); // random operands
if (w=="") // no operands so don't add a spacer that will bork the instruction
w=instr.name;
else
w=instr.name+" "+w;
test_opcodes.HTML+=v+"\n";
test_opcodes.test_opcode(w);
if ((i & Y.FORMS_EXTENDABLE)&&((instr.flags & Y.NO_CONDITION)==0))
test_opcodes.test_opcode(w+" "+Y.randomCondition());
}
i<<=1;
} while (i <= f);
} // while chunk>0...
var new_pre = dcE("pre");
new_pre.innerHTML=test_opcodes.HTML;
test_opcodes.win.contents_id.firstChild.appendChild(new_pre);
redraw(test_opcodes.scan_opcode_table);
}
},
start: function() {
// (re-)initialise important variables
test_opcodes.msg_number=0;
test_opcodes.errnum=0;
test_opcodes.sorted_opcodes=[];
test_opcodes.max_opcode=0;
test_opcodes.cur_opcode=0;
test_opcodes.win= ygwm.new_window( "", null, "none",
650, Math.ceil((getHeight()*3)/4),
100, 50, false, true, true, true, false);
test_opcodes.win.contents_id.firstChild.innerHTML=import_htmi("ASM/test_opcodes");
winman.patchInnerLinks(test_opcodes.win.contents_id);
var h=getByClass("hiddenDiv","DIV", test_opcodes.win.contents_id);
ygwm.changeWinTitle(test_opcodes.win, hiddenText(0,h));
test_opcodes.ASM = new Y.ASM_context(test_opcodes.add_message);
test_opcodes.ASM.YASEP_TYPE=32; // => IMM20 works
test_opcodes.DISASM= new Y.DISASM_context(test_opcodes.add_message);
// prepare the sorted list of opcodes
for (var name in Y.table_opcode) {
if ((Y.table_opcode[name].forms>0)
&& (typeof Y.opcode_aliases[name]) == "undefined") // check it's not an alias
test_opcodes.sorted_opcodes[test_opcodes.max_opcode++]=name;
}
test_opcodes.sorted_opcodes=test_opcodes.sorted_opcodes.sort();
test_opcodes.win.shortmsg(I8N("rng"));
redraw(test_opcodes.scan_opcode_table);
return test_opcodes.win;
},
init_obj: function() {
menu.subMenuItem(menu.list["ASM"], i8n.ats, "ASM/test_opcodes");
}
});