@@ -30,17 +30,19 @@ class DisassembledInstruction {
3030
3131 public referencedAddress : number ;
3232 public warning : string ;
33+ public info : string ;
3334
3435 public bytes : Uint8Array ;
3536
36- constructor ( address : number , instruction : Instruction , operands : string , referencedAddress : number , warning : string , bytes : Uint8Array ) {
37+ constructor ( address : number , instruction : Instruction , operands : string , referencedAddress : number , warning : string , info : string , bytes : Uint8Array ) {
3738 this . address = address ;
3839
3940 this . instruction = instruction ;
4041 this . operands = operands ;
4142
4243 this . referencedAddress = referencedAddress ;
4344 this . warning = warning ;
45+ this . info = info ;
4446
4547 this . bytes = bytes ;
4648 }
@@ -69,6 +71,7 @@ export class Disassembler {
6971
7072 private jumpDestination : number ;
7173 private warning : string ;
74+ private info : string ;
7275
7376 public static readonly MIN_OBJ_SIZE : number = 1 + 1 + 3 * 4 + 1 ;
7477
@@ -150,7 +153,7 @@ export class Disassembler {
150153 public static readonly DUP_X1 : Instruction = { mnemonic : "dup_x1" , opcode : 59 } ;
151154 public static readonly DUP_X2 : Instruction = { mnemonic : "dup_x2" , opcode : 60 } ;
152155
153- public static readonly INVALID_INSTR : Instruction = { mnemonic : "" , opcode : 61 } ;
156+ public static readonly INVALID_INSTR : Instruction = { mnemonic : "??? " , opcode : 61 } ;
154157
155158 public static readonly INSTRUCTIONS : Instruction [ ] = [
156159 Disassembler . LOAD , Disassembler . LOAD_0 , Disassembler . LOAD_1 , Disassembler . LOAD_2 ,
@@ -201,7 +204,7 @@ export class Disassembler {
201204 if ( this . jumpDestination && ( this . jumpDestination < 0 || this . jumpDestination >= this . uint8Array . length - this . headerSize ) ) {
202205 this . warning = 'This instruction is problematic! Destination address does not exist.' ;
203206 }
204- this . disassembledInstructions . push ( new DisassembledInstruction ( this . address , instruction , operands , isJumpInstruction ? this . jumpDestination : null , this . warning , bytes ) ) ;
207+ this . disassembledInstructions . push ( new DisassembledInstruction ( this . address , instruction , operands , isJumpInstruction ? this . jumpDestination : null , this . warning , this . info , bytes ) ) ;
205208 this . address = this . current - this . headerSize ;
206209 }
207210
@@ -224,6 +227,7 @@ export class Disassembler {
224227
225228 while ( this . current < this . uint8Array . length ) {
226229 this . warning = null ;
230+ this . info = null ;
227231 this . jumpDestination = null ;
228232 this . startAddresses . push ( this . address ) ;
229233 switch ( this . opcode = this . get ( ) ) {
@@ -327,7 +331,8 @@ export class Disassembler {
327331 this . operand1 = this . get4 ( ) ;
328332 let asciiChar = String . fromCharCode ( this . operand1 ) ;
329333 let isPrintable = / ^ [ - ~ ] $ / . test ( asciiChar ) ;
330- this . put ( Disassembler . CONST , new Uint8Array ( [ this . opcode , ( this . operand1 >> 24 ) & 0x0ff , ( this . operand1 >> 16 ) & 0x0ff , ( this . operand1 >> 8 ) & 0x0ff , this . operand1 & 0x0ff ] ) , this . operand1 . toString ( ) + ( isPrintable ? " (ASCII char: '" + asciiChar + "')" : "" ) ) ;
334+ this . info = isPrintable ? "If it is interpreted as an ASCII char, this value is '" + asciiChar + "'" : "" ;
335+ this . put ( Disassembler . CONST , new Uint8Array ( [ this . opcode , ( this . operand1 >> 24 ) & 0x0ff , ( this . operand1 >> 16 ) & 0x0ff , ( this . operand1 >> 8 ) & 0x0ff , this . operand1 & 0x0ff ] ) , this . operand1 . toString ( ) ) ;
331336 break ;
332337 }
333338case Disassembler . ADD . opcode : {
0 commit comments