Changeset 225 in dev for trunk/abdev/BasicCompiler32/Compile_Set_Var.cpp
- Timestamp:
- Jul 21, 2007, 11:47:40 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Set_Var.cpp
r206 r225 2 2 3 3 #include <jenga/include/smoothie/Smoothie.h> 4 5 #include <Compiler.h> 4 6 5 7 #include "../BasicCompiler_Common/common.h" … … 21 23 22 24 //mov ecx,object_size 23 op_mov_RV(REG_ECX,object_size);25 compiler.codeGenerator.op_mov_RV(REG_ECX,object_size); 24 26 25 27 //pop esi 26 op_pop(REG_ESI);28 compiler.codeGenerator.op_pop(REG_ESI); 27 29 28 30 //pop edi 29 op_pop(REG_EDI);31 compiler.codeGenerator.op_pop(REG_EDI); 30 32 31 33 if(bUseHeap){ 32 34 //mov eax,esi 33 op_mov_RR(REG_EAX,REG_ESI);35 compiler.codeGenerator.op_mov_RR(REG_EAX,REG_ESI); 34 36 } 35 37 36 38 //rep movs byte ptr[edi],byte ptr[esi] 37 op_rep_movs(sizeof(BYTE));39 compiler.codeGenerator.op_rep_movs(sizeof(BYTE)); 38 40 39 41 if(bUseHeap){ 40 42 //push eax 41 op_push(REG_EAX);43 compiler.codeGenerator.op_push(REG_EAX); 42 44 43 45 //call free 44 46 extern const UserProc *pSub_free; 45 op_call(pSub_free);47 compiler.codeGenerator.op_call(pSub_free); 46 48 } 47 49 … … 64 66 65 67 //push edx 66 op_push( REG_EDX );68 compiler.codeGenerator.op_push( REG_EDX ); 67 69 68 70 //push eax 69 op_push( REG_EAX );71 compiler.codeGenerator.op_push( REG_EAX ); 70 72 71 73 //fild qword ptr[esp] 72 op_fld_ptr_esp(DEF_INT64);74 compiler.codeGenerator.op_fld_ptr_esp(DEF_INT64); 73 75 74 76 //pop 75 op_pop( REG_NON );77 compiler.codeGenerator.op_pop( REG_NON ); 76 78 77 79 //pop 78 op_pop( REG_NON );80 compiler.codeGenerator.op_pop( REG_NON ); 79 81 } 80 82 else{ 81 83 //push eax 82 op_push( REG_EAX );84 compiler.codeGenerator.op_push( REG_EAX ); 83 85 84 86 //fild qword ptr[esp] 85 op_fld_ptr_esp(DEF_LONG);87 compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG); 86 88 87 89 //pop 88 op_pop( REG_NON );90 compiler.codeGenerator.op_pop( REG_NON ); 89 91 } 90 92 } … … 93 95 if(pRelativeVar->bOffsetOffset){ 94 96 //fstp ptr[ecx+offset] 95 op_fstp_base_offset(VarType,REG_ECX,(int)pRelativeVar->offset);97 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_ECX,(int)pRelativeVar->offset); 96 98 obp-=sizeof(long); 97 99 pobj_GlobalVarSchedule->add(); … … 100 102 else{ 101 103 //mov ecx,offset 102 op_mov_RV(REG_ECX,(int)pRelativeVar->offset);104 compiler.codeGenerator.op_mov_RV(REG_ECX,(int)pRelativeVar->offset); 103 105 obp-=sizeof(long); 104 106 pobj_GlobalVarSchedule->add(); … … 106 108 107 109 //fstp ptr[ecx] 108 op_fstp_basereg(VarType,REG_ECX);110 compiler.codeGenerator.op_fstp_basereg(VarType,REG_ECX); 109 111 } 110 112 } … … 112 114 if(pRelativeVar->bOffsetOffset){ 113 115 //add ecx,qword ptr[offset] 114 op_add_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);116 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 115 117 } 116 118 else{ 117 119 //mov ecx,qword ptr[offset] 118 op_mov_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);120 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 119 121 } 120 122 obp-=sizeof(long); … … 127 129 if(pRelativeVar->bOffsetOffset){ 128 130 //fstp ptr[ebp+ecx+offset] 129 op_fstp_base_offset_ex(VarType,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET);131 compiler.codeGenerator.op_fstp_base_offset_ex(VarType,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET); 130 132 } 131 133 else{ 132 134 //fstp ptr[ebp+offset] 133 op_fstp_base_offset(VarType,REG_EBP,(int)pRelativeVar->offset);135 compiler.codeGenerator.op_fstp_base_offset(VarType,REG_EBP,(int)pRelativeVar->offset); 134 136 } 135 137 obp-=sizeof(long); … … 140 142 if(pRelativeVar->bOffsetOffset){ 141 143 //add ecx,qword ptr[ebp+offset] 142 op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);144 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 143 145 } 144 146 else{ 145 147 //mov ecx,qword ptr[ebp+offset] 146 op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);148 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 147 149 } 148 150 obp-=sizeof(long); … … 155 157 directmem: 156 158 //fstp ptr[ecx] 157 op_fstp_basereg(VarType,REG_ECX);159 compiler.codeGenerator.op_fstp_basereg(VarType,REG_ECX); 158 160 } 159 161 } … … 170 172 else if(type==DEF_INT64||type==DEF_QWORD){ 171 173 //cmp eax,0 172 op_cmp_value(GetTypeSize(type,-1),REG_EAX,0);174 compiler.codeGenerator.op_cmp_value(GetTypeSize(type,-1),REG_EAX,0); 173 175 174 176 //setne al 175 op_setne( REG_EAX );177 compiler.codeGenerator.op_setne( REG_EAX ); 176 178 177 179 //cmp edx,0 178 op_cmp_value(GetTypeSize(type,-1),REG_EDX,0);180 compiler.codeGenerator.op_cmp_value(GetTypeSize(type,-1),REG_EDX,0); 179 181 180 182 //setne cl 181 op_setne( REG_ECX );183 compiler.codeGenerator.op_setne( REG_ECX ); 182 184 183 185 //or al,cl 184 op_or_RR( sizeof( _int8 ), REG_EAX, REG_ECX );186 compiler.codeGenerator.op_or_RR( sizeof( _int8 ), REG_EAX, REG_ECX ); 185 187 } 186 188 else{ … … 193 195 194 196 //cmp eax,0 195 op_cmp_value(GetTypeSize(type,-1),REG_EAX,0);197 compiler.codeGenerator.op_cmp_value(GetTypeSize(type,-1),REG_EAX,0); 196 198 197 199 //setne al 198 op_setne( REG_EAX );200 compiler.codeGenerator.op_setne( REG_EAX ); 199 201 200 202 SetWholeVariable( sizeof(char), DEF_BYTE, pRelative ); … … 209 211 if(IsSignedType(type)){ 210 212 //cdq 211 op_cdq();213 compiler.codeGenerator.op_cdq(); 212 214 } 213 215 else{ 214 216 //xor edx,edx 215 op_zero_reg(REG_EDX);217 compiler.codeGenerator.op_zero_reg(REG_EDX); 216 218 } 217 219 } … … 219 221 if(type==DEF_INTEGER || (Smoothie::IsUnicode()&&type==DEF_CHAR)){ 220 222 //movsx reg32,reg16 221 op_movsx_R32R16(reg,reg);223 compiler.codeGenerator.op_movsx_R32R16(reg,reg); 222 224 } 223 225 else if(type==DEF_WORD){ 224 226 //and reg,0000FFFFh 225 op_and_RV(reg,(int)0x0000FFFF);227 compiler.codeGenerator.op_and_RV(reg,(int)0x0000FFFF); 226 228 } 227 229 else if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){ 228 230 //movsx reg32,reg8 229 op_movsx_R32R8(reg,reg);231 compiler.codeGenerator.op_movsx_R32R8(reg,reg); 230 232 } 231 233 else if(type==DEF_BYTE||type==DEF_BOOLEAN){ 232 234 //and reg,000000FFh 233 op_and_RV(reg,(int)0xFF);235 compiler.codeGenerator.op_and_RV(reg,(int)0xFF); 234 236 } 235 237 } … … 237 239 if(type==DEF_SBYTE || (Smoothie::IsUnicode()==false&&type==DEF_CHAR)){ 238 240 //movsx reg16,reg8 239 op_movsx_R16R8(reg,reg);241 compiler.codeGenerator.op_movsx_R16R8(reg,reg); 240 242 } 241 243 else if(type==DEF_BYTE||type==DEF_BOOLEAN){ 242 244 //and reg,000000FFh 243 op_and_RV(reg,(int)0xFF);245 compiler.codeGenerator.op_and_RV(reg,(int)0xFF); 244 246 } 245 247 } … … 256 258 //push 257 259 //push 258 op_sub_esp( PTR_SIZE * 2 );260 compiler.codeGenerator.op_sub_esp( PTR_SIZE * 2 ); 259 261 260 262 //fistp qword ptr[esp] 261 op_fistp_ptr_esp( sizeof(_int64) );263 compiler.codeGenerator.op_fistp_ptr_esp( sizeof(_int64) ); 262 264 263 265 //pop eax 264 op_pop( REG_EAX );266 compiler.codeGenerator.op_pop( REG_EAX ); 265 267 266 268 //pop edx 267 op_pop( REG_EDX );269 compiler.codeGenerator.op_pop( REG_EDX ); 268 270 } 269 271 else{ … … 272 274 273 275 //push 274 op_push( REG_NON );276 compiler.codeGenerator.op_push( REG_NON ); 275 277 276 278 //fistp dword ptr[esp] 277 op_fistp_ptr_esp( sizeof(long) );279 compiler.codeGenerator.op_fistp_ptr_esp( sizeof(long) ); 278 280 279 281 //pop eax 280 op_pop( REG_EAX );282 compiler.codeGenerator.op_pop( REG_EAX ); 281 283 } 282 284 } … … 310 312 311 313 //mov ecx,eax 312 op_mov_RR( REG_ECX, REG_EAX );314 compiler.codeGenerator.op_mov_RR( REG_ECX, REG_EAX ); 313 315 314 316 //add ecx,sizeof(long) 315 op_add_RV8( REG_ECX, sizeof(long) );317 compiler.codeGenerator.op_add_RV8( REG_ECX, sizeof(long) ); 316 318 317 319 //mov eax,edx 318 op_mov_RR( REG_EAX, REG_EDX );320 compiler.codeGenerator.op_mov_RR( REG_EAX, REG_EDX ); 319 321 320 322 SetWholeVariable(sizeof(long),DEF_LONG,pRelative); … … 326 328 if(pRelative->bOffsetOffset){ 327 329 //mov ptr[ecx+offset],eax/ax/al 328 op_mov_MR(varSize,REG_EAX,REG_ECX,(int)pRelative->offset,MOD_BASE_DISP32);330 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_ECX,(int)pRelative->offset,MOD_BASE_DISP32); 329 331 } 330 332 else{ 331 333 //mov ptr[offset],eax/ax/al 332 op_mov_MR(varSize,REG_EAX,0,(int)pRelative->offset,MOD_DISP32);334 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,0,(int)pRelative->offset,MOD_DISP32); 333 335 } 334 336 obp-=sizeof(long); … … 342 344 if(pRelative->bOffsetOffset){ 343 345 //add ecx,qword ptr[offset] 344 op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32);346 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32); 345 347 } 346 348 else{ 347 349 //mov ecx,qword ptr[offset] 348 op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32);350 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelative->offset,MOD_DISP32); 349 351 } 350 352 obp-=sizeof(long); … … 357 359 if(pRelative->bOffsetOffset){ 358 360 //mov ptr[ebp+ecx+offset],eax/ax/al 359 op_mov_MR_ex(varSize,REG_EAX,REG_EBP,REG_ECX,(int)pRelative->offset,USE_OFFSET);361 compiler.codeGenerator.op_mov_MR_ex(varSize,REG_EAX,REG_EBP,REG_ECX,(int)pRelative->offset,USE_OFFSET); 360 362 } 361 363 else{ 362 364 //mov ptr[ebp+offset],eax/ax/al 363 op_mov_MR(varSize,REG_EAX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32);365 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32); 364 366 } 365 367 obp-=sizeof(long); … … 370 372 if(pRelative->bOffsetOffset){ 371 373 //add ecx,ptr[ebp+offset] 372 op_add_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32);374 compiler.codeGenerator.op_add_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32); 373 375 } 374 376 else{ 375 377 //mov ecx,ptr[ebp+offset] 376 op_mov_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32);378 compiler.codeGenerator.op_mov_RM(PTR_SIZE,REG_ECX,REG_EBP,(int)pRelative->offset,MOD_BASE_DISP32); 377 379 } 378 380 obp-=sizeof(long); … … 386 388 387 389 //mov ptr[ecx],eax/ax/al 388 op_mov_MR(varSize,REG_EAX,REG_ECX,0,MOD_BASE);389 } 390 } 390 compiler.codeGenerator.op_mov_MR(varSize,REG_EAX,REG_ECX,0,MOD_BASE); 391 } 392 }
Note:
See TracChangeset
for help on using the changeset viewer.