diff mbox series

external/mambo: Add di command to decode instructions

Message ID 20180423064117.6836-1-mikey@neuling.org
State Accepted
Headers show
Series external/mambo: Add di command to decode instructions | expand

Commit Message

Michael Neuling April 23, 2018, 6:41 a.m. UTC
By default you get 16 instructions but you can specify the number you
want.  ie

  systemsim % di 0x100 4
  0x0000000000000100: Enc:0xA64BB17D : mtspr   HSPRG1,r13
  0x0000000000000104: Enc:0xA64AB07D : mfspr   r13,HSPRG0
  0x0000000000000108: Enc:0xF0092DF9 : std     r9,0x9F0(r13)
  0x000000000000010C: Enc:0xA6E2207D : mfspr   r9,PPR

Using di since it's what xmon uses.

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 external/mambo/mambo_utils.tcl | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Balbir Singh April 24, 2018, 6:47 a.m. UTC | #1
On Mon, Apr 23, 2018 at 4:41 PM, Michael Neuling <mikey@neuling.org> wrote:
> By default you get 16 instructions but you can specify the number you
> want.  ie
>
>   systemsim % di 0x100 4
>   0x0000000000000100: Enc:0xA64BB17D : mtspr   HSPRG1,r13
>   0x0000000000000104: Enc:0xA64AB07D : mfspr   r13,HSPRG0
>   0x0000000000000108: Enc:0xF0092DF9 : std     r9,0x9F0(r13)
>   0x000000000000010C: Enc:0xA6E2207D : mfspr   r9,PPR
>
> Using di since it's what xmon uses.
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
>  external/mambo/mambo_utils.tcl | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl
> index 54b367c47c..b503acbfd4 100644
> --- a/external/mambo/mambo_utils.tcl
> +++ b/external/mambo/mambo_utils.tcl
> @@ -158,6 +158,17 @@ proc ex {  ea { size 8 } } {
>      puts "$pa : $val"
>  }
>
> +proc di { location { count 16 } }    {
> +    set addr  [expr $location & 0xfffffffffffffff0]
> +    set top [expr $addr + ($count * 4)]
> +    for { set i $addr } { $i < $top } { incr i 4 } {
> +       set pc_laddr [mysim cpu 0 util itranslate $i]
> +       set inst [mysim cpu 0 memory display $pc_laddr 4]
> +       set disasm [mysim cpu 0 util ppc_disasm $inst $i]
> +       puts "$pc_laddr: Enc:$inst : $disasm"
> +    }
> +}
> +

Doesn't disasm_mem mysim $location $count achieve the same thing?

Balbir Singh
Michael Neuling April 24, 2018, 12:36 p.m. UTC | #2
> > +proc di { location { count 16 } }    {
> > +    set addr  [expr $location & 0xfffffffffffffff0]
> > +    set top [expr $addr + ($count * 4)]
> > +    for { set i $addr } { $i < $top } { incr i 4 } {
> > +       set pc_laddr [mysim cpu 0 util itranslate $i]
> > +       set inst [mysim cpu 0 memory display $pc_laddr 4]
> > +       set disasm [mysim cpu 0 util ppc_disasm $inst $i]
> > +       puts "$pc_laddr: Enc:$inst : $disasm"
> > +    }
> > +}
> > +
> 
> Doesn't disasm_mem mysim $location $count achieve the same thing?

Oh nice.. I didn't know that, thanks.

I might make di wrapper around that instead

Mikey
Stewart Smith April 30, 2018, 6:45 a.m. UTC | #3
Michael Neuling <mikey@neuling.org> writes:
>> > +proc di { location { count 16 } }    {
>> > +    set addr  [expr $location & 0xfffffffffffffff0]
>> > +    set top [expr $addr + ($count * 4)]
>> > +    for { set i $addr } { $i < $top } { incr i 4 } {
>> > +       set pc_laddr [mysim cpu 0 util itranslate $i]
>> > +       set inst [mysim cpu 0 memory display $pc_laddr 4]
>> > +       set disasm [mysim cpu 0 util ppc_disasm $inst $i]
>> > +       puts "$pc_laddr: Enc:$inst : $disasm"
>> > +    }
>> > +}
>> > +
>> 
>> Doesn't disasm_mem mysim $location $count achieve the same thing?
>
> Oh nice.. I didn't know that, thanks.
>
> I might make di wrapper around that instead

Well, I merged this before I read the mail, so umm... boo to me?
Easy to patch around it I guess.
In master as of 1bcd6d84ec8061e3593bfca50e2a1f81006b16c0.
diff mbox series

Patch

diff --git a/external/mambo/mambo_utils.tcl b/external/mambo/mambo_utils.tcl
index 54b367c47c..b503acbfd4 100644
--- a/external/mambo/mambo_utils.tcl
+++ b/external/mambo/mambo_utils.tcl
@@ -158,6 +158,17 @@  proc ex {  ea { size 8 } } {
     puts "$pa : $val"
 }
 
+proc di { location { count 16 } }    {
+    set addr  [expr $location & 0xfffffffffffffff0]
+    set top [expr $addr + ($count * 4)]
+    for { set i $addr } { $i < $top } { incr i 4 } {
+	set pc_laddr [mysim cpu 0 util itranslate $i]
+	set inst [mysim cpu 0 memory display $pc_laddr 4]
+	set disasm [mysim cpu 0 util ppc_disasm $inst $i]
+	puts "$pc_laddr: Enc:$inst : $disasm"
+    }
+}
+
 proc hexdump { location count }    {
     set addr  [expr $location & 0xfffffffffffffff0]
     set top [expr $addr + ($count * 15)]