jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 161 forks source link

issue 13: nested for loop broken #20

Closed yodalee closed 8 years ago

yodalee commented 8 years ago

The for loop in previous version is parsed as: // Init -> Cond -> Bz -> After -> Body -> Jmp and then swap the After and Body chunk. The swap does not consider the jump address in Body chunk and thus the incorrect jump address causes unexpected behavior. This issue has been reported at issue #13

In this patches for loop is parsed as: Init -> Cond -> Bz to end -> Jmp to Body -> After -> Jmp to Cond -> Body ->Jmp to After

It disadvantage at generating more Jmp instruction, which may decrease overall performance. However, it is more convenient then recalculating all jump address in Body and After chunk.

jserv commented 8 years ago

Please read this article How to Write a Git Commit Message carefully. Don't mention issue 13 in the subject. Instead, place Close #13 in the next line.

yodalee commented 8 years ago

Just fix the comment style and write nested for loop test in tests/for.c