Index: trunk/abdev/BasicCompiler32/Compile_Calc.cpp
===================================================================
--- trunk/abdev/BasicCompiler32/Compile_Calc.cpp	(revision 206)
+++ trunk/abdev/BasicCompiler32/Compile_Calc.cpp	(revision 225)
@@ -14,40 +14,42 @@
 	if(OldType==DEF_DOUBLE){
 		//fld qword ptr[esp]
-		op_fld_ptr_esp(DEF_DOUBLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
 
 		//add esp,8
-		op_add_esp(8);
+		compiler.codeGenerator.op_add_esp(8);
 	}
 	else if(OldType==DEF_SINGLE){
 		//fld dword ptr[esp]
-		op_fld_ptr_esp(DEF_SINGLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 	}
 	else if(OldType==DEF_LONG){
 		//fild dword ptr[esp]
-		op_fld_ptr_esp(DEF_LONG);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 	}
 	else if(OldType==DEF_DWORD){
 		//pop eax
-		op_pop(REG_EAX);
+		compiler.codeGenerator.op_pop(REG_EAX);
 
 		//push 0
-		op_push_V(0);
+		compiler.codeGenerator.op_push_V(0);
 
 		//push eax
-		op_push(REG_EAX);
+		compiler.codeGenerator.op_push(REG_EAX);
 
 		//fild qword ptr[esp]
-		OpBuffer[obp++]=(char)0xDF;
-		OpBuffer[obp++]=(char)0x2C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.PutOld(
+			(char)0xDF,
+			(char)0x2C,
+			(char)0x24
+		);
 
 		//add esp,8
-		op_add_esp(8);
+		compiler.codeGenerator.op_add_esp(8);
 	}
 }
@@ -58,13 +60,11 @@
 	else if(OldType==DEF_SINGLE){
 		//fld dword ptr[esp]
-		op_fld_ptr_esp(DEF_SINGLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
 
 		//sub esp,4
-		op_sub_esp(4);
+		compiler.codeGenerator.op_sub_esp(4);
 
 		//fstp qword ptr[esp]
-		OpBuffer[obp++]=(char)0xDD;
-		OpBuffer[obp++]=(char)0x1C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.op_fstp_basereg( DEF_DOUBLE, REG_ESP );
 	}
 	else if(OldType==DEF_INT64||OldType==DEF_QWORD){
@@ -72,10 +72,8 @@
 
 		//fild qword ptr[esp]
-		op_fld_ptr_esp(DEF_INT64);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_INT64);
 
 		//fstp qword ptr[esp]
-		OpBuffer[obp++]=(char)0xDD;
-		OpBuffer[obp++]=(char)0x1C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.op_fstp_basereg( DEF_DOUBLE, REG_ESP );
 	}
 	else if(IsWholeNumberType(OldType)){
@@ -87,32 +85,28 @@
 			if(OldType==DEF_INTEGER || (Smoothie::IsUnicode()&&OldType==DEF_CHAR)){
 				//pop eax
-				op_pop(REG_EAX);
+				compiler.codeGenerator.op_pop(REG_EAX);
 
 				//movsx eax,ax
-				OpBuffer[obp++]=(char)0x0F;
-				OpBuffer[obp++]=(char)0xBF;
-				OpBuffer[obp++]=(char)0xC0;
+				compiler.codeGenerator.op_movsx_R32R16( REG_EAX );
 
 				//push eax
-				op_push(REG_EAX);
+				compiler.codeGenerator.op_push(REG_EAX);
 			}
 			else if(OldType==DEF_SBYTE || (Smoothie::IsUnicode()==false&&OldType==DEF_CHAR)){
 				//pop eax
-				op_pop(REG_EAX);
+				compiler.codeGenerator.op_pop(REG_EAX);
 
 				//movsx eax,al
-				OpBuffer[obp++]=(char)0x0F;
-				OpBuffer[obp++]=(char)0xBE;
-				OpBuffer[obp++]=(char)0xC0;
+				compiler.codeGenerator.op_movsx_R32R8( REG_EAX );
 
 				//push eax
-				op_push(REG_EAX);
+				compiler.codeGenerator.op_push(REG_EAX);
 			}
 
 			//fild dword ptr[esp]
-			op_fld_ptr_esp(DEF_LONG);
+			compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
 
 			//sub esp,4
-			op_sub_esp(4);
+			compiler.codeGenerator.op_sub_esp(4);
 		}
 		else{
@@ -120,22 +114,22 @@
 
 			//pop eax
-			op_pop(REG_EAX);
+			compiler.codeGenerator.op_pop(REG_EAX);
 
 			//push 0
-			op_push_V(0);
+			compiler.codeGenerator.op_push_V(0);
 
 			//push eax
-			op_push(REG_EAX);
+			compiler.codeGenerator.op_push(REG_EAX);
 
 			//fild qword ptr[esp]
-			OpBuffer[obp++]=(char)0xDF;
-			OpBuffer[obp++]=(char)0x2C;
-			OpBuffer[obp++]=(char)0x24;
+			compiler.codeGenerator.PutOld(
+				(char)0xDF,
+				(char)0x2C,
+				(char)0x24
+			);
 		}
 
 		//fstp qword ptr[esp]
-		OpBuffer[obp++]=(char)0xDD;
-		OpBuffer[obp++]=(char)0x1C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.op_fstp_basereg( DEF_DOUBLE, REG_ESP );
 	}
 	else SetError(9,NULL,cp);
@@ -147,13 +141,11 @@
 	else if(OldType==DEF_DOUBLE){
 		//fld qword ptr[esp]
-		op_fld_ptr_esp(DEF_DOUBLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 
 		//fstp dword ptr[esp]
-		OpBuffer[obp++]=(char)0xD9;
-		OpBuffer[obp++]=(char)0x1C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.op_fstp_basereg( DEF_SINGLE, REG_ESP );
 	}
 	else if(OldType==DEF_INT64||OldType==DEF_QWORD){
@@ -161,13 +153,11 @@
 
 		//fild qword ptr[esp]
-		op_fld_ptr_esp(DEF_INT64);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_INT64);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 
 		//fstp dword ptr[esp]
-		OpBuffer[obp++]=(char)0xD9;
-		OpBuffer[obp++]=(char)0x1C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.op_fstp_basereg( DEF_SINGLE, REG_ESP );
 	}
 	else if(IsWholeNumberType(OldType)){
@@ -179,29 +169,25 @@
 			if(OldType==DEF_INTEGER || (Smoothie::IsUnicode()&&OldType==DEF_CHAR)){
 				//pop eax
-				op_pop(REG_EAX);
+				compiler.codeGenerator.op_pop(REG_EAX);
 
 				//movsx eax,ax
-				OpBuffer[obp++]=(char)0x0F;
-				OpBuffer[obp++]=(char)0xBF;
-				OpBuffer[obp++]=(char)0xC0;
+				compiler.codeGenerator.op_movsx_R32R16( REG_EAX );
 
 				//push eax
-				op_push(REG_EAX);
+				compiler.codeGenerator.op_push(REG_EAX);
 			}
 			else if(OldType==DEF_SBYTE || (Smoothie::IsUnicode()==false&&OldType==DEF_CHAR)){
 				//pop eax
-				op_pop(REG_EAX);
+				compiler.codeGenerator.op_pop(REG_EAX);
 
 				//movsx eax,al
-				OpBuffer[obp++]=(char)0x0F;
-				OpBuffer[obp++]=(char)0xBE;
-				OpBuffer[obp++]=(char)0xC0;
+				compiler.codeGenerator.op_movsx_R32R8( REG_EAX );
 
 				//push eax
-				op_push(REG_EAX);
+				compiler.codeGenerator.op_push(REG_EAX);
 			}
 
 			//fild dword ptr[esp]
-			op_fld_ptr_esp(DEF_LONG);
+			compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
 		}
 		else{
@@ -209,11 +195,9 @@
 
 			//fild dword ptr[esp]
-			op_fld_ptr_esp(DEF_LONG);
+			compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
 		}
 
 		//fstp dword ptr[esp]
-		OpBuffer[obp++]=(char)0xD9;
-		OpBuffer[obp++]=(char)0x1C;
-		OpBuffer[obp++]=(char)0x24;
+		compiler.codeGenerator.op_fstp_basereg( DEF_SINGLE, REG_ESP );
 	}
 	else SetError(9,NULL,cp);
@@ -227,18 +211,18 @@
 	else if(OldType==DEF_DOUBLE){
 		//fld qword ptr[esp]
-		op_fld_ptr_esp(DEF_DOUBLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
 
 		//fistp qword ptr[esp]
-		op_fistp_ptr_esp( sizeof(_int64) );
+		compiler.codeGenerator.op_fistp_ptr_esp( sizeof(_int64) );
 	}
 	else if(OldType==DEF_SINGLE){
 		//fld dword ptr[esp]
-		op_fld_ptr_esp(DEF_SINGLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
 
 		//sub esp,4
-		op_sub_esp(4);
+		compiler.codeGenerator.op_sub_esp(4);
 
 		//fistp qword ptr[esp]
-		op_fistp_ptr_esp( sizeof(_int64) );
+		compiler.codeGenerator.op_fistp_ptr_esp( sizeof(_int64) );
 	}
 	else if(IsWholeNumberType(OldType)){
@@ -249,14 +233,14 @@
 
 			//pop eax
-			op_pop(REG_EAX);
+			compiler.codeGenerator.op_pop(REG_EAX);
 
 			//cdq
-			op_cdq();
+			compiler.codeGenerator.op_cdq();
 
 			//push edx
-			op_push(REG_EDX);
+			compiler.codeGenerator.op_push(REG_EDX);
 
 			//push eax
-			op_push(REG_EAX);
+			compiler.codeGenerator.op_push(REG_EAX);
 		}
 		else{
@@ -264,11 +248,11 @@
 
 			//pop eax
-			op_pop(REG_EAX);
+			compiler.codeGenerator.op_pop(REG_EAX);
 
 			//push 0
-			op_push_V(0);
+			compiler.codeGenerator.op_push_V(0);
 
 			//push eax
-			op_push(REG_EAX);
+			compiler.codeGenerator.op_push(REG_EAX);
 		}
 	}
@@ -281,28 +265,28 @@
 
 		//fld qword ptr[esp]
-		op_fld_ptr_esp(DEF_DOUBLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 
 		//fistp dword ptr[esp]
-		op_fistp_ptr_esp( sizeof(long) );
+		compiler.codeGenerator.op_fistp_ptr_esp( sizeof(long) );
 	}
 	else if(OldType==DEF_SINGLE){
 		//fld dword ptr[esp]
-		op_fld_ptr_esp(DEF_SINGLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
 
 		//fistp dword ptr[esp]
-		op_fistp_ptr_esp( sizeof(long) );
+		compiler.codeGenerator.op_fistp_ptr_esp( sizeof(long) );
 	}
 	else if(OldType==DEF_INT64||OldType==DEF_QWORD){
 		//pop eax
-		op_pop(REG_EAX);
+		compiler.codeGenerator.op_pop(REG_EAX);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 
 		//push eax
-		op_push(REG_EAX);
+		compiler.codeGenerator.op_push(REG_EAX);
 	}
 }
@@ -314,13 +298,11 @@
 	else if(OldType==DEF_SBYTE || (Smoothie::IsUnicode()==false&&OldType==DEF_CHAR)){
 		//pop eax
-		op_pop(REG_EAX);
+		compiler.codeGenerator.op_pop(REG_EAX);
 
 		//movsx eax,al
-		OpBuffer[obp++]=(char)0x0F;
-		OpBuffer[obp++]=(char)0xBE;
-		OpBuffer[obp++]=(char)0xC0;
+		compiler.codeGenerator.op_movsx_R32R8( REG_EAX );
 
 		//push eax
-		op_push(REG_EAX);
+		compiler.codeGenerator.op_push(REG_EAX);
 	}
 	else{
@@ -328,13 +310,11 @@
 
 		//pop eax
-		op_pop(REG_EAX);
+		compiler.codeGenerator.op_pop(REG_EAX);
 
 		//and eax,0000FFFFh
-		OpBuffer[obp++]=(char)0x25;
-		*((long *)(OpBuffer+obp))=0x0000FFFF;
-		obp+=sizeof(long);
+		compiler.codeGenerator.op_and_RV( REG_EAX, 0x0000FFFF );
 
 		//push eax
-		op_push(REG_EAX);
+		compiler.codeGenerator.op_push(REG_EAX);
 	}
 }
@@ -346,13 +326,11 @@
 
 	//pop eax
-	op_pop(REG_EAX);
+	compiler.codeGenerator.op_pop(REG_EAX);
 
 	//and eax,000000FFh
-	OpBuffer[obp++]=(char)0x25;
-	*((long *)(OpBuffer+obp))=0x000000FF;
-	obp+=sizeof(long);
+	compiler.codeGenerator.op_and_RV( REG_EAX, 0x000000FF );
 
 	//push eax
-	op_push(REG_EAX);
+	compiler.codeGenerator.op_push(REG_EAX);
 }
 
@@ -370,26 +348,26 @@
 	if(type==DEF_DOUBLE){
 		//fld qword ptr[esp]
-		op_fld_ptr_esp(DEF_DOUBLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
 
 		//add esp,8
-		op_add_esp(8);
+		compiler.codeGenerator.op_add_esp(8);
 	}
 	else if(type==DEF_SINGLE){
 		//fld dword ptr[esp]
-		op_fld_ptr_esp(DEF_SINGLE);
+		compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
 
 		//add esp,4
-		op_add_esp(4);
+		compiler.codeGenerator.op_add_esp(4);
 	}
 	else if( Is64Type( type ) ){
 		//pop eax
-		op_pop(REG_EAX);
+		compiler.codeGenerator.op_pop(REG_EAX);
 
 		//pop edx
-		op_pop(REG_EDX);
+		compiler.codeGenerator.op_pop(REG_EDX);
 	}
 	else{
 		//pop eax
-		op_pop(REG_EAX);
+		compiler.codeGenerator.op_pop(REG_EAX);
 	}
 }
@@ -586,5 +564,5 @@
 
 		//push eax
-		op_push(REG_EAX);
+		compiler.codeGenerator.op_push(REG_EAX);
 	}
 
@@ -639,8 +617,8 @@
 
 		// call System.[TypeClass]._Create
-		op_call( pUserProc );
+		compiler.codeGenerator.op_call( pUserProc );
 
 		// push eax
-		op_push( REG_EAX );
+		compiler.codeGenerator.op_push( REG_EAX );
 
 		calcType = pUserProc->ReturnType();
