1(module 2 (import "spectest" "print" (func $print (param i32))) 3 4 (memory 1) 5 (data (i32.const 0) "abcdefghijklmnopqrstuvwxyz") 6 7 (func (export "good") (param $i i32) 8 (call $print (i32.load8_u offset=0 (get_local $i))) ;; 97 'a' 9 (call $print (i32.load8_u offset=1 (get_local $i))) ;; 98 'b' 10 (call $print (i32.load8_u offset=2 (get_local $i))) ;; 99 'c' 11 (call $print (i32.load8_u offset=25 (get_local $i))) ;; 122 'z' 12 13 (call $print (i32.load16_u offset=0 (get_local $i))) ;; 25185 'ab' 14 (call $print (i32.load16_u align=1 (get_local $i))) ;; 25185 'ab' 15 (call $print (i32.load16_u offset=1 align=1 (get_local $i))) ;; 25442 'bc' 16 (call $print (i32.load16_u offset=2 (get_local $i))) ;; 25699 'cd' 17 (call $print (i32.load16_u offset=25 align=1 (get_local $i))) ;; 122 'z\0' 18 19 (call $print (i32.load offset=0 (get_local $i))) ;; 1684234849 'abcd' 20 (call $print (i32.load offset=1 align=1 (get_local $i))) ;; 1701077858 'bcde' 21 (call $print (i32.load offset=2 align=2 (get_local $i))) ;; 1717920867 'cdef' 22 (call $print (i32.load offset=25 align=1 (get_local $i))) ;; 122 'z\0\0\0' 23 ) 24 25 (func (export "bad") (param $i i32) 26 (drop (i32.load offset=4294967295 (get_local $i))) 27 ) 28) 29 30(invoke "good" (i32.const 0)) 31(invoke "good" (i32.const 65507)) 32(assert_trap (invoke "good" (i32.const 65508)) "out of bounds memory access") 33(assert_trap (invoke "bad" (i32.const 0)) "out of bounds memory access") 34(assert_trap (invoke "bad" (i32.const 1)) "out of bounds memory access") 35