Created
April 28, 2018 12:30
-
-
Save sfpgmr/1e3fe52f14161abe5267ca97660ba83b to your computer and use it in GitHub Desktop.
オレオレ言語のコンパイルテスト(6)for文
This file contains 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
export i32 main(){ | |
i32 a = 0; | |
for(i32 c = 0;c < 4;++c) { | |
++a; | |
} | |
return a;// 4 | |
} |
This file contains 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
(module | |
(type $main (func (result i32))) | |
(export "main" (func $main)) | |
(func $main (; 0 ;) (type $main) (result i32) | |
(local $0 i32) | |
(local $1 i32) | |
(set_local $0 | |
(i32.const 0) | |
) | |
(block $for0 | |
(set_local $1 | |
(i32.const 0) | |
) | |
(loop $loop1 | |
(br_if $for0 | |
(i32.eqz | |
(i32.lt_s | |
(get_local $1) | |
(i32.const 4) | |
) | |
) | |
) | |
(block | |
(set_local $0 | |
(i32.add | |
(get_local $0) | |
(i32.const 1) | |
) | |
) | |
) | |
(set_local $1 | |
(i32.add | |
(get_local $1) | |
(i32.const 1) | |
) | |
) | |
(br $loop1) | |
) | |
) | |
(return | |
(get_local $0) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment