Index: BasicCompiler32/Compile_Calc_PushVar.cpp
===================================================================
--- BasicCompiler32/Compile_Calc_PushVar.cpp	(revision 3)
+++ BasicCompiler32/Compile_Calc_PushVar.cpp	(revision 62)
@@ -21,4 +21,7 @@
 			op_fld_basereg(type,REG_ECX);
 		}
+	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		SetError(300,NULL,cp);
 	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
@@ -89,15 +92,27 @@
 			//mov reg, ptr[ecx+offset]
 			op_mov_RM(var_size,reg,REG_ECX,(int)pRelativeVar->offset,MOD_BASE_DISP32);
-			obp-=sizeof(long);
-			pobj_GlobalVarSchedule->add();
-			obp+=sizeof(long);
 		}
 		else{
 			//mov reg, ptr[offset]
 			op_mov_RM(var_size,reg,0,(int)pRelativeVar->offset,MOD_DISP32);
-			obp-=sizeof(long);
-			pobj_GlobalVarSchedule->add();
-			obp+=sizeof(long);
-		}
+		}
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		if(pRelativeVar->bOffsetOffset){
+			//add ecx,qword ptr[offset]
+			op_add_RM(var_size,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);
+		}
+		else{
+			//mov ecx,qword ptr[offset]
+			op_mov_RM(var_size,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);
+		}
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+
+		goto directmem;
 	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
@@ -105,15 +120,12 @@
 			//mov reg, ptr[ebp+ecx+offset]
 			op_mov_RM_ex(var_size,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET);
-			obp-=sizeof(long);
-			AddLocalVarAddrSchedule();
-			obp+=sizeof(long);
 		}
 		else{
 			//mov reg, ptr[ebp+offset]
 			op_mov_RM(var_size,reg,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
-			obp-=sizeof(long);
-			AddLocalVarAddrSchedule();
-			obp+=sizeof(long);
-		}
+		}
+		obp-=sizeof(long);
+		AddLocalVarAddrSchedule();
+		obp+=sizeof(long);
 	}
 	else if(pRelativeVar->dwKind==VAR_REFLOCAL){
@@ -121,15 +133,12 @@
 			//add ecx,qword ptr[ebp+offset]
 			op_add_RM(var_size,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
-			obp-=sizeof(long);
-			AddLocalVarAddrSchedule();
-			obp+=sizeof(long);
 		}
 		else{
 			//mov ecx,qword ptr[ebp+offset]
 			op_mov_RM(var_size,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
-			obp-=sizeof(long);
-			AddLocalVarAddrSchedule();
-			obp+=sizeof(long);
-		}
+		}
+		obp-=sizeof(long);
+		AddLocalVarAddrSchedule();
+		obp+=sizeof(long);
 
 		goto directmem;
@@ -178,4 +187,7 @@
 			obp+=sizeof(long);
 		}
+	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		SetError(300,NULL,cp);
 	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
@@ -275,4 +287,21 @@
 		}
 	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		//mov eax,dword ptr[offset]
+		op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+
+		if(pRelativeVar->bOffsetOffset){
+			//add eax,ecx
+			OpBuffer[obp++]=(char)0x03;
+			OpBuffer[obp++]=(char)0xC1;
+		}
+
+		//push dword ptr[eax]
+		OpBuffer[obp++]=(char)0xFF;
+		OpBuffer[obp++]=(char)0x30;
+	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
 		if(pRelativeVar->bOffsetOffset){
@@ -343,4 +372,22 @@
 			obp+=sizeof(long);
 		}
+	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		//mov ebx,dword ptr[offset]
+		op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+
+		if(pRelativeVar->bOffsetOffset){
+			//add ebx,ecx
+			OpBuffer[obp++]=(char)0x03;
+			OpBuffer[obp++]=(char)0xD9;
+		}
+
+		//movsx eax,word ptr[ebx]
+		OpBuffer[obp++]=(char)0x0F;
+		OpBuffer[obp++]=(char)0xBF;
+		OpBuffer[obp++]=(char)0x03;
 	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
@@ -422,4 +469,22 @@
 		}
 	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		//mov ebx,dword ptr[offset]
+		op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+
+		if(pRelativeVar->bOffsetOffset){
+			//add ebx,ecx
+			OpBuffer[obp++]=(char)0x03;
+			OpBuffer[obp++]=(char)0xD9;
+		}
+
+		//mov ax,word ptr[ebx]
+		OpBuffer[obp++]=(char)0x66;
+		OpBuffer[obp++]=(char)0x8B;
+		OpBuffer[obp++]=(char)0x03;
+	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
 		if(pRelativeVar->bOffsetOffset){
@@ -498,4 +563,22 @@
 		}
 	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		//mov ebx,dword ptr[offset]
+		op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+
+		if(pRelativeVar->bOffsetOffset){
+			//add ebx,ecx
+			OpBuffer[obp++]=(char)0x03;
+			OpBuffer[obp++]=(char)0xD9;
+		}
+
+		//movsx eax,byte ptr[ebx]
+		OpBuffer[obp++]=(char)0x0F;
+		OpBuffer[obp++]=(char)0xBE;
+		OpBuffer[obp++]=(char)0x03;
+	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
 		if(pRelativeVar->bOffsetOffset){
@@ -574,4 +657,21 @@
 		}
 	}
+	else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
+		//mov ebx,dword ptr[offset]
+		op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
+		obp-=sizeof(long);
+		pobj_GlobalVarSchedule->add();
+		obp+=sizeof(long);
+
+		if(pRelativeVar->bOffsetOffset){
+			//add ebx,ecx
+			OpBuffer[obp++]=(char)0x03;
+			OpBuffer[obp++]=(char)0xD9;
+		}
+
+		//mov al,byte ptr[ebx]
+		OpBuffer[obp++]=(char)0x8A;
+		OpBuffer[obp++]=(char)0x03;
+	}
 	else if(pRelativeVar->dwKind==VAR_LOCAL){
 		if(pRelativeVar->bOffsetOffset){
