--- gforth/arch/mips/disasm.fs 2000/06/03 07:56:03 1.6 +++ gforth/arch/mips/disasm.fs 2000/09/23 15:06:06 1.11 @@ -1,28 +1,35 @@ \ disasm.fs disassembler file (for MIPS R3000) \ -\ Copyright (C) 1995-97 Martin Anton Ertl, Christian Pirker -\ -\ This file is part of RAFTS. -\ -\ RAFTS is free software; you can redistribute it and/or -\ modify it under the terms of the GNU General Public License -\ as published by the Free Software Foundation; either version 2 -\ of the License, or (at your option) any later version. -\ -\ This program is distributed in the hope that it will be useful, -\ but WITHOUT ANY WARRANTY; without even the implied warranty of -\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -\ GNU General Public License for more details. -\ -\ You should have received a copy of the GNU General Public License -\ along with this program; if not, write to the Free Software -\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +\ Copyright (C) 2000 Free Software Foundation, Inc. + +\ This file is part of Gforth. + +\ Gforth is free software; you can redistribute it and/or +\ modify it under the terms of the GNU General Public License +\ as published by the Free Software Foundation; either version 2 +\ of the License, or (at your option) any later version. + +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +\ You should have received a copy of the GNU General Public License +\ along with this program; if not, write to the Free Software +\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. \ 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 (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 bye" |sed 's/([^)]*) //'|diff -u - arch/mips/testasm.fs + +get-current +vocabulary disassembler +also disassembler definitions + \ instruction fields : disasm-op ( w -- u ) @@ -80,16 +87,23 @@ $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) dup disasm-op opc-tab-entry @ execute ; -: disasm-dump ( addr u -- ) \ gforth +: disasm ( addr u -- ) \ gforth \G disassemble u aus starting at addr bounds u+do cr ." ( " i hex. ." ) " i i @ disasm-inst - 1 cells +loop ; + 1 cells +loop + cr ; + +' disasm IS discode + +definitions : disasm-special ( addr w -- ) \ disassemble inst with opcode special @@ -128,7 +142,7 @@ $40 disasm-table cp0-tab-entry \ COP : disasm-J-target ( addr w -- ) \ print jump target - $03ffffff and swap $fc000000 and or 2 lshift hex. ; + 2 lshift $0fffffff and swap $f0000000 and or hex. ; : disasm-I-rs,rt,imm ( addr w -- ) dup disasm-rs . @@ -266,3 +280,5 @@ does> ( addr w -- ) drop nip asm-copz-imm1 ; include ./insts.fs + +previous set-current