Changeset 228 in dev for trunk/abdev/BasicCompiler64/CodeGenerator.cpp
- Timestamp:
- Jul 23, 2007, 3:24:20 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/CodeGenerator.cpp
r226 r228 79 79 #define INDEX_NON 0x04 80 80 81 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp ){81 void CodeGenerator::set_mod_rm_sib_disp(char mod,int reg,int scale,int index_reg,int base_reg,long disp, Schedule::Type scheduleType ){ 82 82 if(mod==MOD_DISP32){ 83 83 //ModR/Mバイト … … 115 115 if(mod==MOD_BASE_DISP8) pNativeCode->Put( (char)disp ); 116 116 else{ 117 pNativeCode->Put( disp );118 } 119 } 120 121 122 123 void CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod ){117 pNativeCode->Put( disp, scheduleType ); 118 } 119 } 120 121 122 123 void CodeGenerator::__op_format(int op_size,char op_prefix,char opcode1,char opcode2,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){ 124 124 //命令プリフィックス 125 125 if(op_prefix) pNativeCode->Put( op_prefix ); … … 133 133 134 134 //ModR/M, SIB, disp 135 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset); 135 set_mod_rm_sib_disp(mod,reg,SCALE_NON,INDEX_NON,base_reg,offset, scheduleType ); 136 } 137 138 void CodeGenerator::__jmp_op_format( char opcode, long offset, int op_size ) 139 { 140 pNativeCode->Put( opcode ); 141 if( op_size == sizeof(char) ) 142 { 143 pNativeCode->Put( (char)offset ); 144 } 145 else if( op_size == sizeof(long) ) 146 { 147 SetError(); 148 pNativeCode->Put( offset ); 149 } 150 else 151 { 152 SetError(); 153 } 136 154 } 137 155 … … 175 193 pNativeCode->Put( i64data ); 176 194 } 177 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod ){195 void CodeGenerator::op_mov_RM(int op_size,int reg,int base_reg,long offset,char mod, Schedule::Type scheduleType ){ 178 196 //mov reg64,qword ptr[base_reg+offset] 179 197 //mov reg32,dword ptr[base_reg+offset] … … 190 208 else opcode=(char)0x8B; 191 209 192 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod );193 } 194 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset ){210 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType); 211 } 212 void CodeGenerator::op_mov_RM_ex(int op_size,int reg,int base_reg1,int base_reg2,long offset,BOOL bUseOffset, Schedule::Type scheduleType ){ 195 213 //mov reg64,qword ptr[base_reg1+base_reg2+offset] 196 214 //mov reg32,dword ptr[base_reg1+base_reg2+offset] … … 226 244 227 245 //オフセット値 228 pNativeCode->Put( offset );246 pNativeCode->Put( offset, scheduleType ); 229 247 } 230 248 else{ … … 561 579 562 580 ////////////////////////////////// 581 // ビット拡張 582 ////////////////////////////////// 583 584 void CodeGenerator::op_cqo() 585 { 586 pNativeCode->Put( (char)0x48 ); 587 pNativeCode->Put( (char)0x99 ); 588 } 589 590 591 592 ////////////////////////////////// 563 593 // インクリメント・デクリメント 564 594 ////////////////////////////////// … … 593 623 ///////////////////// 594 624 595 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod ){625 void CodeGenerator::op_add_RM(int op_size,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType ){ 596 626 //add reg64,qword ptr[base_reg+offset] 597 627 //add reg32,dword ptr[base_reg+offset] … … 608 638 else opcode=(char)0x03; 609 639 610 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod );640 __op_format(op_size,op_prefix,opcode,0,reg,base_reg,offset,mod, scheduleType ); 611 641 } 612 642 … … 638 668 } 639 669 } 640 void CodeGenerator::op_add 64_reg(int reg1,int reg2){670 void CodeGenerator::op_add_RR(int reg1,int reg2){ 641 671 //add reg1,reg2 642 672 char RexByte=-1; … … 1704 1734 1705 1735 ///////////////////////////// 1736 // 分岐 1737 ///////////////////////////// 1738 1739 void CodeGenerator::op_jle( long offset, int op_size ) 1740 { 1741 __jmp_op_format( (char)0x7E, offset, op_size ); 1742 } 1743 void CodeGenerator::op_jbe( long offset, int op_size ) 1744 { 1745 __jmp_op_format( (char)0x76, offset, op_size ); 1746 } 1747 void CodeGenerator::op_jge( long offset, int op_size ) 1748 { 1749 __jmp_op_format( (char)0x7D, offset, op_size ); 1750 } 1751 void CodeGenerator::op_jae( long offset, int op_size ) 1752 { 1753 __jmp_op_format( (char)0x73, offset, op_size ); 1754 } 1755 void CodeGenerator::op_jl( long offset, int op_size ) 1756 { 1757 __jmp_op_format( (char)0x7C, offset, op_size ); 1758 } 1759 void CodeGenerator::op_jb( long offset, int op_size ) 1760 { 1761 __jmp_op_format( (char)0x72, offset, op_size ); 1762 } 1763 void CodeGenerator::op_jg( long offset, int op_size ) 1764 { 1765 __jmp_op_format( (char)0x7F, offset, op_size ); 1766 } 1767 void CodeGenerator::op_ja( long offset, int op_size ) 1768 { 1769 __jmp_op_format( (char)0x77, offset, op_size ); 1770 } 1771 void CodeGenerator::op_jne( long offset, int op_size ) 1772 { 1773 __jmp_op_format( (char)0x75, offset, op_size ); 1774 } 1775 void CodeGenerator::op_je( long offset, int op_size ) 1776 { 1777 __jmp_op_format( (char)0x74, offset, op_size ); 1778 } 1779 void CodeGenerator::op_jmp( long offset, int op_size ) 1780 { 1781 __jmp_op_format( (char)0xEB, offset, op_size ); 1782 } 1783 1784 1785 1786 ///////////////////////////// 1706 1787 // 関数呼び出し 1707 1788 /////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.