Skip to content

Instantly share code, notes, and snippets.

@sfpgmr
Created April 28, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sfpgmr/1e3fe52f14161abe5267ca97660ba83b to your computer and use it in GitHub Desktop.
Save sfpgmr/1e3fe52f14161abe5267ca97660ba83b to your computer and use it in GitHub Desktop.
オレオレ言語のコンパイルテスト(6)for文
export i32 main(){
i32 a = 0;
for(i32 c = 0;c < 4;++c) {
++a;
}
return a;// 4
}
(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