@@ -146,9 +146,11 @@ mod console;
146
146
pub mod colors;
147
147
pub mod constants;
148
148
mod winapi;
149
+ mod fpu;
149
150
150
151
use flags:: Flags ;
151
152
use eflags:: Eflags ;
153
+ use fpu:: FPU ;
152
154
use maps:: Maps ;
153
155
use regs32:: Regs32 ;
154
156
use console:: Console ;
@@ -163,6 +165,7 @@ pub struct Emu32 {
163
165
regs : Regs32 ,
164
166
flags : Flags ,
165
167
eflags : Eflags ,
168
+ fpu : FPU ,
166
169
maps : Maps ,
167
170
exp : u64 ,
168
171
break_on_alert : bool ,
@@ -180,6 +183,7 @@ impl Emu32 {
180
183
regs : Regs32 :: new ( ) ,
181
184
flags : Flags :: new ( ) ,
182
185
eflags : Eflags :: new ( ) ,
186
+ fpu : FPU :: new ( ) ,
183
187
maps : Maps :: new ( ) ,
184
188
exp : 0 ,
185
189
break_on_alert : false ,
@@ -5466,6 +5470,45 @@ impl Emu32 {
5466
5470
}
5467
5471
} ,
5468
5472
5473
+ ///// FPU ///// https://github.com/radare/radare/blob/master/doc/xtra/fpu
5474
+
5475
+ Some ( "ffree" ) => {
5476
+ if !step {
5477
+ println ! ( "{}{} {}{}" , self . colors. green, self . pos, ins, self . colors. nc) ;
5478
+ }
5479
+
5480
+ let op = ins. op_str ( ) . unwrap ( ) ;
5481
+ match op {
5482
+ "st(0)" => self . fpu . clear ( 0 ) ,
5483
+ "st(1)" => self . fpu . clear ( 1 ) ,
5484
+ "st(2)" => self . fpu . clear ( 2 ) ,
5485
+ "st(3)" => self . fpu . clear ( 3 ) ,
5486
+ "st(4)" => self . fpu . clear ( 4 ) ,
5487
+ "st(5)" => self . fpu . clear ( 5 ) ,
5488
+ "st(6)" => self . fpu . clear ( 6 ) ,
5489
+ "st(7)" => self . fpu . clear ( 7 ) ,
5490
+ _ => panic ! ( "fpu ffre operand no implemented" ) ,
5491
+ }
5492
+ self . fpu . set_eip ( self . regs . eip ) ;
5493
+ } ,
5494
+
5495
+ Some ( "fnstenv" ) => {
5496
+ if !step {
5497
+ println ! ( "{}{} {}{}" , self . colors. green, self . pos, ins, self . colors. nc) ;
5498
+ }
5499
+
5500
+ let mut dir = "dword ptr " . to_string ( ) ;
5501
+ dir. push_str ( ins. op_str ( ) . unwrap ( ) ) ;
5502
+
5503
+ let addr: u32 = self . memory_operand_to_address ( dir. as_str ( ) ) ;
5504
+ let env = self . fpu . get_env ( ) ;
5505
+ for i in 0 ..4 {
5506
+ self . maps . write_dword ( addr+( i* 4 ) , env[ i as usize ] ) ;
5507
+ }
5508
+
5509
+ self . fpu . set_eip ( self . regs . eip ) ;
5510
+ } ,
5511
+
5469
5512
5470
5513
Some ( "sysenter" ) => {
5471
5514
println ! ( "{}{} {}{} function: 0x{:x}" , self . colors. red, self . pos, ins, self . colors. nc, self . regs. eax) ;
0 commit comments