Created
December 17, 2018 16:06
-
-
Save eira-fransham/2458437d0c43d4b0e08f70040cf6813d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INPUT: | |
(module | |
(func | |
(call $assert-return (call $as-binary-operand) (i32.const 12)) | |
(call $assert-return (call $break-bare) (i32.const 19)) | |
(call $assert-return (call $break-value) (i32.const 18)) | |
(call $assert-return (call $break-repeated) (i32.const 18)) | |
(call $assert-return (call $break-inner) (i32.const 0x7)) | |
) | |
(func $dummy) | |
(func $as-binary-operand (result i32) | |
(i32.mul | |
(loop (result i32) (call $dummy) (i32.const 3)) | |
(loop (result i32) (call $dummy) (i32.const 4)) | |
) | |
) | |
(func $break-bare (result i32) | |
(block (loop (br 1) (br 0) (unreachable))) | |
(block (loop (br_if 1 (i32.const 1)) (unreachable))) | |
(i32.const 19) | |
) | |
(func $break-value (result i32) | |
(block (result i32) | |
(loop (result i32) (br 1 (i32.const 18)) (br 0) (i32.const 19)) | |
) | |
) | |
(func $break-repeated (result i32) | |
(block (result i32) | |
(loop (result i32) | |
(br 1 (i32.const 18)) | |
(br 1 (i32.const 19)) | |
(drop (br_if 1 (i32.const 20) (i32.const 0))) | |
(drop (br_if 1 (i32.const 20) (i32.const 1))) | |
(br 1 (i32.const 21)) | |
(i32.const 21) | |
) | |
) | |
) | |
(func $break-inner (result i32) | |
(local i32) | |
(set_local 0 (i32.const 0)) | |
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (block (result i32) (br 2 (i32.const 0x1))))))) | |
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (loop (result i32) (br 2 (i32.const 0x2))))))) | |
(set_local 0 (i32.add (get_local 0) (block (result i32) (loop (result i32) (block (result i32) (loop (result i32) (br 1 (i32.const 0x4)))))))) | |
(get_local 0) | |
) | |
(func $assert-return (param i32) (param i32) | |
(if (i32.eq (get_local 0) (get_local 1)) (then) (else (unreachable))) | |
) | |
) | |
OUTPUT: | |
0: e8 61 00 00 00 call $as-binary-operand | |
5: 48 c7 c6 0c 00 00 00 mov rsi, 0xc | |
c: 48 89 c7 mov rdi, rax | |
f: e8 2e 01 00 00 call $assert-return | |
14: e8 74 00 00 00 call $break-bare | |
19: 48 c7 c6 13 00 00 00 mov rsi, 0x13 | |
20: 48 89 c7 mov rdi, rax | |
23: e8 1a 01 00 00 call $assert-return | |
28: e8 84 00 00 00 call $break-value | |
2d: 48 c7 c6 12 00 00 00 mov rsi, 0x12 | |
34: 48 89 c7 mov rdi, rax | |
37: e8 06 01 00 00 call $assert-return | |
3c: e8 7d 00 00 00 call $break-repeated | |
41: 48 c7 c6 12 00 00 00 mov rsi, 0x12 | |
48: 48 89 c7 mov rdi, rax | |
4b: e8 f2 00 00 00 call $assert-return | |
50: e8 76 00 00 00 call $break-inner | |
55: 48 c7 c6 07 00 00 00 mov rsi, 7 | |
5c: 48 89 c7 mov rdi, rax | |
5f: e8 de 00 00 00 call $assert-return | |
64: c3 ret | |
$dummy: | |
65: c3 ret | |
$as-binary-operand: | |
66: e8 fa ff ff ff call $dummy | |
6b: 48 c7 c0 03 00 00 00 mov rax, 3 | |
72: 49 89 c2 mov r10, rax | |
75: 41 52 push r10 | |
77: e8 e9 ff ff ff call $dummy | |
7c: 41 5a pop r10 | |
7e: 48 c7 c0 04 00 00 00 mov rax, 4 | |
85: 44 0f af d0 imul r10d, eax | |
89: 4c 89 d0 mov rax, r10 | |
8c: c3 ret | |
$break-bare: | |
8d: e9 00 00 00 00 jmp 0x92 | |
92: 48 c7 c0 01 00 00 00 mov rax, 1 | |
99: 40 85 c0 test eax, eax | |
9c: 0f 84 05 00 00 00 je 0xa7 | |
a2: e9 02 00 00 00 jmp 0xa9 | |
a7: 0f 0b ud2 | |
a9: 48 c7 c0 13 00 00 00 mov rax, 0x13 | |
b0: c3 ret | |
$break-repeated: | |
b1: 48 c7 c0 12 00 00 00 mov rax, 0x12 | |
b8: e9 00 00 00 00 jmp 0xbd | |
bd: c3 ret | |
$break-inner: | |
be: 48 c7 c0 12 00 00 00 mov rax, 0x12 | |
c5: e9 00 00 00 00 jmp 0xca | |
ca: c3 ret | |
cb: 55 push rbp | |
cc: 48 89 e5 mov rbp, rsp | |
cf: 48 81 ec 10 00 00 00 sub rsp, 0x10 | |
d6: c7 84 24 00 00 00 00 00 00 00 00 mov dword ptr [rsp], 0 | |
e1: 48 c7 c0 01 00 00 00 mov rax, 1 | |
e8: e9 00 00 00 00 jmp 0xed | |
ed: 40 03 84 24 00 00 00 00 add eax, dword ptr [rsp] | |
f5: 48 89 84 24 00 00 00 00 mov qword ptr [rsp], rax | |
fd: 48 c7 c0 02 00 00 00 mov rax, 2 | |
104: e9 00 00 00 00 jmp 0x109 | |
109: 40 03 84 24 00 00 00 00 add eax, dword ptr [rsp] | |
111: 48 89 84 24 00 00 00 00 mov qword ptr [rsp], rax | |
119: 48 c7 c0 04 00 00 00 mov rax, 4 | |
120: e9 00 00 00 00 jmp 0x125 | |
125: 40 03 84 24 00 00 00 00 add eax, dword ptr [rsp] | |
12d: 48 89 84 24 00 00 00 00 mov qword ptr [rsp], rax | |
135: 48 8b 84 24 00 00 00 00 mov rax, qword ptr [rsp] | |
13d: 48 89 ec mov rsp, rbp | |
140: 5d pop rbp | |
141: c3 ret | |
$assert-return: | |
142: 55 push rbp | |
143: 48 89 e5 mov rbp, rsp | |
146: 48 81 ec 10 00 00 00 sub rsp, 0x10 | |
14d: 48 31 c0 xor rax, rax | |
150: 40 3b fe cmp edi, esi | |
153: 40 0f 94 c0 sete al | |
157: 40 85 c0 test eax, eax | |
15a: 0f 84 05 00 00 00 je 0x165 | |
160: e9 02 00 00 00 jmp 0x167 | |
165: 0f 0b ud2 | |
167: 48 89 ec mov rsp, rbp | |
16a: 5d pop rbp | |
16b: c3 ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment