// @(#)disassemble.v 1.2 4/15/92
// Tasks to disassemble instruction opcodes
// m4 doesn't work on this file with the usual quotes
// because these are used by verilog defines.
// change the quotes to very unlikely characters.
module Mdisassemble
;
// Task to dis-assemble opcodes, display on stdout
task disp_instr;
input [32:0] instruction; // instruction
// MSB is an active HIGH mexc
input [2:0] hhn; // help bit plus help number
input nop; // if set, instruction decodes as nop
fdisp_instr(1,instruction,hhn,nop) ;
endtask
// Task to dis-assemble opcodes
task fdisp_instr;
input [31:0] mcd ; // Multi-channel descriptor
input [32:0] instruction; // instruction
// MSB is an active HIGH mexc
input [2:0] hhn; // help bit plus help number
input nop; // if set, instruction decodes as nop
// OPCODE FIELDS
reg mexc;
reg help;
reg [1:0] op;
reg [2:0] op2;
reg [5:0] op3;
reg [8:0] opf;
reg [1:0] hn;
reg [2:0] hop;
reg [5:0] hop2;
reg [8:0] hop3;
reg [10:0] opcode;
// SOME OTHER INSTRUCTION FIELDS
reg imm;
reg anl;
begin
mexc = instruction[32]; // memory exception flag
help = hhn[2];
op = instruction[31:30];
op2 = instruction[24:22];
op3 = instruction[24:19];
opf = instruction[13:5];
hn = hhn[1:0]; // help number
hop = {help, op}; // h + op
hop2 = {help, op, op2}; // h + op + op2
hop3 = {help, op, op3}; // h + op + op3
opcode= {help, op, op3, hn}; // complete opcode
imm = instruction[13];
anl = instruction[29];
if (nop)
$fwrite(mcd,"NOP ");
else if (mexc)
$fwrite(mcd,"except ");
else if(help) begin
case (opcode)
({9'o270 | 9'o400, 2'b00}): $fwrite(mcd,"hjmp ");
({9'o271 | 9'o400, 2'b00}): $fwrite(mcd,"hrett ");
({9'o303 | 9'o400, 2'b00}): $fwrite(mcd,"hldd ");
({9'o323 | 9'o400, 2'b00}): $fwrite(mcd,"hldda ");
({9'o315 | 9'o400, 2'b00}): $fwrite(mcd,"hldstb ");
({9'o307 | 9'o400, 2'b00}): $fwrite(mcd,"hstd0 ");
({9'o317 | 9'o400, 2'b00}): $fwrite(mcd,"hswap ");
({9'o324 | 9'o400, 2'b00}): $fwrite(mcd,"hsta0 ");
({9'o324 | 9'o400, 2'b01}): $fwrite(mcd,"hsta1 ");
({9'o335 | 9'o400, 2'b00}): $fwrite(mcd,"hldstba ");
({9'o327 | 9'o400, 2'b00}): $fwrite(mcd,"hstda0 ");
({9'o327 | 9'o400, 2'b01}): $fwrite(mcd,"hstda1 ");
({9'o337 | 9'o400, 2'b00}): $fwrite(mcd,"hswapa ");
({9'o346 | 9'o400, 2'b00}): $fwrite(mcd,"hstdfq0 ");
({9'o346 | 9'o400, 2'b01}): $fwrite(mcd,"hstdfq1 ");
({9'o366 | 9'o400, 2'b00}): $fwrite(mcd,"hstdcq0 ");
({9'o366 | 9'o400, 2'b01}): $fwrite(mcd,"hstdcq1 ");
({9'o273 | 9'o400, 2'b00}): $fwrite(mcd,"hiflush0");
({9'o273 | 9'o400, 2'b01}): $fwrite(mcd,"hiflush1");
({9'o212 | 9'o400, 2'b00}): $fwrite(mcd,"humul0 ");
({9'o212 | 9'o400, 2'b01}): $fwrite(mcd,"humul1 ");
({9'o212 | 9'o400, 2'b10}): $fwrite(mcd,"humul2 ");
({9'o213 | 9'o400, 2'b00}): $fwrite(mcd,"hsmul0 ");
({9'o213 | 9'o400, 2'b01}): $fwrite(mcd,"hsmul1 ");
({9'o213 | 9'o400, 2'b10}): $fwrite(mcd,"hsmul2 ");
({9'o232 | 9'o400, 2'b00}): $fwrite(mcd,"humulcc0");
({9'o232 | 9'o400, 2'b01}): $fwrite(mcd,"humulcc1");
({9'o232 | 9'o400, 2'b10}): $fwrite(mcd,"humulcc2");
({9'o233 | 9'o400, 2'b00}): $fwrite(mcd,"hsmulcc0");
({9'o233 | 9'o400, 2'b01}): $fwrite(mcd,"hsmulcc1");
({9'o233 | 9'o400, 2'b10}): $fwrite(mcd,"hsmulcc2");
({9'o216 | 9'o400, 2'b00}): $fwrite(mcd,"hudiv0 ");
({9'o216 | 9'o400, 2'b01}): $fwrite(mcd,"hudiv1 ");
({9'o216 | 9'o400, 2'b10}): $fwrite(mcd,"hudiv2 ");
({9'o216 | 9'o400, 2'b11}): $fwrite(mcd,"hudiv3 ");
({9'o217 | 9'o400, 2'b00}): $fwrite(mcd,"hsdiv0 ");
({9'o217 | 9'o400, 2'b01}): $fwrite(mcd,"hsdiv1 ");
({9'o217 | 9'o400, 2'b10}): $fwrite(mcd,"hsdiv2 ");
({9'o217 | 9'o400, 2'b11}): $fwrite(mcd,"hsdiv3 ");
({9'o236 | 9'o400, 2'b00}): $fwrite(mcd,"hudivcc0");
({9'o236 | 9'o400, 2'b01}): $fwrite(mcd,"hudivcc1");
({9'o236 | 9'o400, 2'b10}): $fwrite(mcd,"hudivcc2");
({9'o236 | 9'o400, 2'b11}): $fwrite(mcd,"hudivcc3");
({9'o237 | 9'o400, 2'b00}): $fwrite(mcd,"hsdivcc0");
({9'o237 | 9'o400, 2'b01}): $fwrite(mcd,"hsdivcc1");
({9'o237 | 9'o400, 2'b10}): $fwrite(mcd,"hsdivcc2");
({9'o237 | 9'o400, 2'b11}): $fwrite(mcd,"hsdivcc3");
({9'o000 | 9'o400, 2'b00}): $fwrite(mcd,"hnop ");
({9'o010 | 9'o400, 2'b00}): $fwrite(mcd,"htrap ");
default: $fwrite(mcd,"%x", instruction[31:0]);
endcase
end
else begin
if(hop==3'b0_01)
$fwrite(mcd,"call ");
else if (hop==3'b0) begin // format 2
case (hop2)
6'b0_00_100: if (instruction[31:0]=='h01000000)
$fwrite(mcd,"nop ");
else $fwrite(mcd,"sethi ");
6'b0_00_010: $fwrite(mcd,"bicc ");
6'b0_00_110: $fwrite(mcd,"bfcc ");
6'b0_00_111: $fwrite(mcd,"bccc ");
6'b0_00_000: $fwrite(mcd,"unimp ");
default: $fwrite(mcd,"%x", instruction[31:0]);
endcase
end
else begin
case (hop3)
/* integer load */
9'o311: $fwrite(mcd,"ldsb ");
9'o301: $fwrite(mcd,"ldub ");
9'o312: $fwrite(mcd,"ldsh ");
9'o302: $fwrite(mcd,"lduh ");
9'o300: $fwrite(mcd,"ld ");
9'o303: $fwrite(mcd,"ldd ");
9'o317: $fwrite(mcd,"swap ");
9'o331: $fwrite(mcd,"ldsba ");
9'o321: $fwrite(mcd,"lduba ");
9'o332: $fwrite(mcd,"ldsha ");
9'o322: $fwrite(mcd,"lduha ");
9'o320: $fwrite(mcd,"lda ");
9'o323: $fwrite(mcd,"ldda ");
9'o337: $fwrite(mcd,"swapa ");
/* floating point load */
9'o340: $fwrite(mcd,"ldf ");
9'o350: $fwrite(mcd,"ldf2 ");
9'o351: $fwrite(mcd,"ldf3 ");
9'o343: $fwrite(mcd,"lddf ");
9'o341: $fwrite(mcd,"ldfsr ");
9'o360: $fwrite(mcd,"ldc ");
9'o370: $fwrite(mcd,"ldc2 ");
9'o371: $fwrite(mcd,"ldc3 ");
9'o363: $fwrite(mcd,"lddc ");
9'o361: $fwrite(mcd,"ldcsr ");
/* integer store */
9'o305: $fwrite(mcd,"stb ");
9'o306: $fwrite(mcd,"sth ");
9'o304: $fwrite(mcd,"st ");
9'o315: $fwrite(mcd,"ldstb ");
9'o307: $fwrite(mcd,"std ");
9'o325: $fwrite(mcd,"stba ");
9'o326: $fwrite(mcd,"stha ");
9'o324: $fwrite(mcd,"sta ");
9'o335: $fwrite(mcd,"ldstba ");
9'o327: $fwrite(mcd,"stda ");
/* floating point store */
9'o344: $fwrite(mcd,"stf ");
9'o354: $fwrite(mcd,"stf2 ");
9'o355: $fwrite(mcd,"stf3 ");
9'o347: $fwrite(mcd,"stdf ");
9'o345: $fwrite(mcd,"stfsr ");
9'o346: $fwrite(mcd,"stdfq ");
9'o364: $fwrite(mcd,"stc ");
9'o374: $fwrite(mcd,"stc2 ");
9'o375: $fwrite(mcd,"stc3 ");
9'o367: $fwrite(mcd,"stdc ");
9'o365: $fwrite(mcd,"stcsr ");
9'o366: $fwrite(mcd,"stdcq ");
/* 4'b0_10_0 group */
9'o200: $fwrite(mcd,"add ");
9'o210: $fwrite(mcd,"addx ");
9'o204: $fwrite(mcd,"sub ");
9'o214: $fwrite(mcd,"subx ");
9'o201: $fwrite(mcd,"and ");
9'o205: $fwrite(mcd,"andn ");
9'o202: $fwrite(mcd,"or ");
9'o206: $fwrite(mcd,"orn ");
9'o203: $fwrite(mcd,"xor ");
9'o207: $fwrite(mcd,"xnor ");
9'o212: $fwrite(mcd,"umul ");
9'o213: $fwrite(mcd,"smul ");
9'o216: $fwrite(mcd,"udiv ");
9'o217: $fwrite(mcd,"sdiv ");
9'o236: $fwrite(mcd,"udivcc ");
9'o237: $fwrite(mcd,"sdivcc ");
9'o220: $fwrite(mcd,"addcc ");
9'o230: $fwrite(mcd,"addxcc ");
9'o224: $fwrite(mcd,"subcc ");
9'o234: $fwrite(mcd,"subxcc ");
9'o221: $fwrite(mcd,"andcc ");
9'o225: $fwrite(mcd,"andncc ");
9'o222: $fwrite(mcd,"orcc ");
9'o226: $fwrite(mcd,"orncc ");
9'o223: $fwrite(mcd,"xorcc ");
9'o227: $fwrite(mcd,"xnorcc ");
9'o232: $fwrite(mcd,"umulcc ");
9'o233: $fwrite(mcd,"smulcc ");
/* 4'b0_10_1 group */
9'o240: $fwrite(mcd,"taddcc ");
9'o241: $fwrite(mcd,"tsubcc ");
9'o242: $fwrite(mcd,"taddcctv");
9'o243: $fwrite(mcd,"tsubcctv");
9'o244: $fwrite(mcd,"mulscc ");
9'o245: $fwrite(mcd,"sll ");
9'o246: $fwrite(mcd,"srl ");
9'o247: $fwrite(mcd,"sra ");
9'o250: $fwrite(mcd,"rdy ");
9'o251: $fwrite(mcd,"rdpsr ");
9'o252: $fwrite(mcd,"rdwim ");
9'o253: $fwrite(mcd,"rdtbr ");
9'o260: $fwrite(mcd,"wry ");
9'o261: $fwrite(mcd,"wrpsr ");
9'o262: $fwrite(mcd,"wrwim ");
9'o263: $fwrite(mcd,"wrtbr ");
9'o264: case(opf)
9'h01: $fwrite(mcd,"fmovs ");
9'h05: $fwrite(mcd,"fnegs ");
9'h09: $fwrite(mcd,"fabss ");
9'h29: $fwrite(mcd,"fsqrts ");
9'h2a: $fwrite(mcd,"fsqrtd ");
9'h2b: $fwrite(mcd,"fsqrtq ");
9'h41: $fwrite(mcd,"fadds ");
9'h42: $fwrite(mcd,"faddd ");
9'h43: $fwrite(mcd,"faddq ");
9'h45: $fwrite(mcd,"fsubs ");
9'h46: $fwrite(mcd,"fsubd ");
9'h47: $fwrite(mcd,"fsubq ");
9'h49: $fwrite(mcd,"fmuls ");
9'h4a: $fwrite(mcd,"fmuld ");
9'h4b: $fwrite(mcd,"fmulq ");
9'h4d: $fwrite(mcd,"fdivs ");
9'h4e: $fwrite(mcd,"fdivd ");
9'h4f: $fwrite(mcd,"fdivq ");
9'h69: $fwrite(mcd,"fsmuld ");
9'h6e: $fwrite(mcd,"fdmulq ");
9'hc4: $fwrite(mcd,"fitos ");
9'hc6: $fwrite(mcd,"fdtos ");
9'hc7: $fwrite(mcd,"fqtos ");
9'hc8: $fwrite(mcd,"fitod ");
9'hc9: $fwrite(mcd,"fstod ");
9'hcb: $fwrite(mcd,"fqtod ");
9'hcc: $fwrite(mcd,"fitoq ");
9'hcd: $fwrite(mcd,"fstoq ");
9'hce: $fwrite(mcd,"fdtoq ");
9'hd1: $fwrite(mcd,"fstoi ");
9'hd2: $fwrite(mcd,"fdtoi ");
9'hd3: $fwrite(mcd,"fqtoi ");
default: $fwrite(mcd,"fpop??? ");
endcase
9'o265: case(opf)
9'h51: $fwrite(mcd,"fcmps ");
9'h52: $fwrite(mcd,"fcmpd ");
9'h53: $fwrite(mcd,"fcmpq ");
9'h55: $fwrite(mcd,"fcmpes ");
9'h56: $fwrite(mcd,"fcmped ");
9'h57: $fwrite(mcd,"fcmpeq ");
default: $fwrite(mcd,"fpcmp???");
endcase
9'o266: $fwrite(mcd,"cpop ");
9'o267: $fwrite(mcd,"cpcmp ");
9'o274: $fwrite(mcd,"save ");
9'o275: $fwrite(mcd,"restore ");
9'o270: $fwrite(mcd,"jmp ");
9'o271: $fwrite(mcd,"rett ");
9'o272: $fwrite(mcd,"ticc ");
9'o273: $fwrite(mcd,"iflush ");
default: $fwrite(mcd,"%x", instruction[31:0]);
endcase
end
end
end
endtask
endmodule
This page: |
Created: | Thu Aug 19 12:02:27 1999 |
| From: |
../../../sparc_v8/env/rtl/disassemble.vpp
|