#include"mbasic.h"

extern void Expression();
extern void GetName();
extern void Block();

void ParseForLoop(void)
{
 int L1,L2;
 char buf[128];
 L1=NewLabel();
 L2=NewLabel();
 SkipWhite();
 GetName();
 STORE_TMP(buf);
 SkipWhite();
 Assignment(buf);
 SkipWhite();
 SkipToken(TOK_TO);
 SkipWhite();
 PostLabel(L1);
 Expression();
 emit("cmp eax,dword [%s]\n",buf);
 emit("jb L%u\n",L2);
 SkipWhite();
 Block();
 SkipWhite();
 emit("inc dword [%s]\n",buf);
 emit("jmp L%u\n",L1);
 PostLabel(L2);
}
