@@ -757,7 +757,7 @@ mod tests {
757
757
fn test_input_hint ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
758
758
let instructions = vec ! [
759
759
wom:: pre_read_u32:: <F >( ) ,
760
- wom:: read_u32:: <F >( 10 , 0 ) ,
760
+ wom:: read_u32:: <F >( 10 ) ,
761
761
reveal( 10 , 0 ) ,
762
762
halt( ) ,
763
763
] ;
@@ -766,4 +766,41 @@ mod tests {
766
766
767
767
run_vm_test ( "Input hint" , instructions, 42 , Some ( stdin) )
768
768
}
769
+
770
+ #[ test]
771
+ fn test_input_hint_with_frame_jump_and_xor ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
772
+ let instructions = vec ! [
773
+ // Read first value into r8
774
+ wom:: pre_read_u32:: <F >( ) ,
775
+ wom:: read_u32:: <F >( 8 ) ,
776
+ wom:: allocate_frame_imm:: <F >( 9 , 64 ) , // Allocate frame, pointer in 99
777
+ wom:: copy_into_frame:: <F >( 2 , 8 , 9 ) , // Copy r8 to frame[2]
778
+ // Jump to new frame
779
+ wom:: jaaf:: <F >( 24 , 9 ) , // Jump to PC=24, activate frame at r9
780
+ // This should be skipped
781
+ halt( ) ,
782
+ // Read second value into r3
783
+ wom:: pre_read_u32:: <F >( ) ,
784
+ wom:: read_u32:: <F >( 3 ) ,
785
+ // Xor the two read values
786
+ wom:: xor:: <F >( 4 , 2 , 3 ) ,
787
+ // TODO: register 5 below is the absolute value for local register 4 used above,
788
+ // due to the `loadstore` chip not being fp relative yet.
789
+ // The allocated frame is 4 (first allocation). Registers are 4-aligned,
790
+ // so in order to access local reg 4 we need (fp / 4 + local reg) = 4/4+1.
791
+ reveal( 5 , 0 ) ,
792
+ halt( ) ,
793
+ ] ;
794
+
795
+ let mut stdin = StdIn :: default ( ) ;
796
+ stdin. write ( & 170u32 ) ; // First value: 170 in decimal
797
+ stdin. write ( & 204u32 ) ; // Second value: 204 in decimal
798
+
799
+ run_vm_test (
800
+ "Input hint with frame jump and XOR" ,
801
+ instructions,
802
+ 102 ,
803
+ Some ( stdin) ,
804
+ )
805
+ }
769
806
}
0 commit comments