--- gforth/arch/mips/disasm.fs 2000/06/02 19:20:19 1.5 +++ gforth/arch/mips/disasm.fs 2000/06/03 10:06:30 1.8 @@ -20,9 +20,16 @@ \ this disassembler is based on data from the R4400 manual \ http://www.mips.com/Documentation/R4400_Uman_book_Ed2.pdf, in -\ particular pages A3,A181,A182 (offset 468 pages in xpdf). +\ particular pages A3, A181, A182 (p. 471, 649, 650 in xpdf). \ it is limited to the R3000 (MIPS-I) architecture, though. +\ test this with +\ gforth arch/mips/disasm.fs -e "here" arch/mips/testdisasm.fs -e "here over - disasm-dump bye" |sed 's/([^)]*) //'|diff -u - arch/mips/testasm.fs + +get-current +vocabulary disassembler +also disassembler definitions + \ instruction fields : disasm-op ( w -- u ) @@ -55,7 +62,7 @@ : disasm-relative ( addr n -- w ) \ compute printable form of relative address n relative to addr - nip ( + ) ; + 2 lshift nip ( + ) ; \ decode tables @@ -80,6 +87,8 @@ $40 disasm-table cp0-tab-entry \ COP \ disassembler central decode cascade +dup set-current + : disasm-inst ( addr w -- ) \G disassemble instruction w at addr (addr is used for computing \G branch targets) @@ -91,6 +100,8 @@ $40 disasm-table cp0-tab-entry \ COP cr ." ( " i hex. ." ) " i i @ disasm-inst 1 cells +loop ; +definitions + : disasm-special ( addr w -- ) \ disassemble inst with opcode special dup disasm-funct funct-tab-entry @ execute ; @@ -128,7 +139,7 @@ $40 disasm-table cp0-tab-entry \ COP : disasm-J-target ( addr w -- ) \ print jump target - $3ffffff and swap $fc000000 and or hex. ; + 2 lshift $0fffffff and swap $f0000000 and or hex. ; : disasm-I-rs,rt,imm ( addr w -- ) dup disasm-rs . @@ -266,3 +277,5 @@ does> ( addr w -- ) drop nip asm-copz-imm1 ; include ./insts.fs + +previous set-current