var desc = { 'add': "Addadd $d,$s,$t", 'addu': "Add unsignedaddu $d,$s,$t", 'sub': "Subtractsub $d,$s,$t", 'subu': "Subtract unsignedsubu $d,$s,$t", 'addi': "Add immediateaddi $t,$s,C", 'addiu': "Add immediate unsignedaddiu $t,$s,C", 'mult': "Multiplymult $s,$t", 'multu': "Multiply unsignedmultu $s,$t", 'div': "Dividediv $s, $t", 'divu': "Divide unsigneddivu $s, $t", 'lw': "Load wordlw $t,C($s)", 'lh': "Load halfwordlh $t,C($s)", 'lhu': "Load halfword unsignedlhu $t,C($s)", 'lb': "Load bytelb $t,C($s)", 'lbu': "Load byte unsignedlbu $t,C($s)", 'sw': "Store wordsw $t,C($s)", 'sh': "Store halfsh $t,C($s)", 'sb': "Store bytesb $t,C($s)", 'lui': "Load upper immediatelui $t,C", 'mfhi': "Move from highmfhi $d", 'mflo': "Move from lowmflo $d", 'mfcZ': "Move from Control RegistermfcZ $t, $d", 'mtcZ': "Move to Control RegistermtcZ $t, $d", 'and': "Andand $d,$s,$t", 'andi': "And immediateandi $t,$s,C", 'or': "Oror $d,$s,$t", 'ori': "Or immediateori $t,$s,C", 'xor': "Exclusive orxor $d,$s,$t", 'nor': "Nornor $d,$s,$t", 'slt': "Set on less thanslt $d,$s,$t", 'slti': "Set on less than immediateslti $t,$s,C", 'sll': "Shift left logical immediatesll $d,$t,shamt", 'srl': "Shift right logical immediatesrl $d,$t,shamt", 'sra': "Shift right arithmetic immediatesra $d,$t,shamt", 'sllv': "Shift left logicalsllv $d,$t,$s", 'srlv': "Shift right logicalsrlv $d,$t,$s", 'srav': "Shift right arithmeticsrav $d,$t,$s", 'beq': "Branch on equalbeq $s,$t,C", 'bne': "Branch on not equalbne $s,$t,C", 'j': "Jumpj C", 'jr': "Jump registerjr $s", 'jal': "Jump and linkjal C", 'nop': "No operation (do nothing)", };
var re = /^([0-9a-f]{8}: [0-9a-f]{8} )(\w+)(\s.*)?$/i;
function tooltipize(i, node){ var txt = node.textContent; node.textContent = ''; //remove //make new nodes and add them txt.split(/\r?\n/) .forEach(function parse(s){ var match = re.exec(s); if(match == null){ //no asm detected node.appendChild(document.createTextNode(s+'\n')); return; } var prefix = document.createTextNode(match[1]); var instr = match[2]; var suffix = document.createTextNode(match[3]+'\n'); var link = $("<a></a>", { href: "./R3000_instruction set#"+instr, title: desc[instr], }).text(instr); console.log(prefix, instr, suffix, link); $(node).append(prefix, link, suffix); }); } $('div#mw-content-text pre').map(tooltipize);
It's a mockup of what can be done: tooltips and links for ASM instructions. Ideally, this would be done through wiki markup instead of Javascript, but this is fine until people figure out what they'd like out of it.
Title: Re: Javascript prototype for asm tooltips on the wiki
Post by: Raijinili on July 27, 2014, 03:24:23 am
I added a page (http://ffhacktics.com/wiki/R3000_instruction_set) for the script to link to, and edited the script as needed.
Title: Re: Javascript prototype for asm tooltips on the wiki
Post by: Raijinili on February 09, 2016, 04:04:23 pm
I am editing Monobook.js to add in Javascript that would help people read ASM.
To use this, log into your account, and go to "preferences" > "Appearance" > "Skin" = "Monobook", Monobook.css turns all the colors slightly red to make it clear what skin you're on.