snapkitty
compilers
javascript
6502-asm
File size: 2,027 Bytes
e870690
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var OpcodeViewer = {
  opcodes: {
    BOOT:   { hex: '0x00', mnemonic: 'BOOT',   operand: 'SUN',    desc: 'Initialize system' },
    SEAL:   { hex: '0x01', mnemonic: 'SEAL',   operand: 'SHA256', desc: 'Generate audit seal' },
    TRUST:  { hex: '0x02', mnemonic: 'TRUST',  operand: 'DEED',   desc: 'Verify trust deed' },
    VAULT:  { hex: '0x03', mnemonic: 'VAULT',  operand: 'READ',   desc: 'Read Woz Vault' },
    DEBATE: { hex: '0x04', mnemonic: 'DEBATE', operand: 'TOPIC',  desc: 'Run ENKI/SENTINEL' },
    AGENT:  { hex: '0x05', mnemonic: 'AGENT',  operand: 'STAT',   desc: 'Agent status' },
    LISP:   { hex: '0x06', mnemonic: 'LISP',   operand: 'EVAL',   desc: 'Evaluate s-expr' },
    ASM:    { hex: '0x07', mnemonic: 'ASM',    operand: 'VIEW',   desc: 'View opcodes' },
    EXPORT: { hex: '0x08', mnemonic: 'EXPORT', operand: 'JSON',   desc: 'Export vault' },
    CLEAR:  { hex: '0x09', mnemonic: 'CLEAR',  operand: 'MEM',    desc: 'Clear memory' }
  },

  lookup: function(command) {
    var key = command.toUpperCase().replace(/[^A-Z]/g, '');
    return this.opcodes[key] || { hex: '0xFF', mnemonic: '???', operand: '???', desc: 'Unknown opcode' };
  },

  renderFor: function(command) {
    var op = this.lookup(command);
    return [
      '╔══════════════════════════════════════╗',
      'β•‘  OPCODE VIEWER (SIMULATED)           β•‘',
      '╠══════════════════════════════════════╣',
      'β•‘  COMMAND:  ' + command.padEnd(27) + 'β•‘',
      'β•‘  HEX:      ' + op.hex.padEnd(27) + 'β•‘',
      'β•‘  MNEMONIC: ' + op.mnemonic.padEnd(27) + 'β•‘',
      'β•‘  OPERAND:  ' + op.operand.padEnd(27) + 'β•‘',
      'β•‘  DESC:     ' + op.desc.padEnd(27) + 'β•‘',
      'β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•'
    ].join('\n');
  }
};