Reformat AsmInit.CC

This commit is contained in:
TomAwezome 2020-07-22 04:02:16 -05:00 committed by VoidNV
parent 040e265be8
commit 4767fc9f2f
3 changed files with 141 additions and 124 deletions

View file

@ -1,13 +1,17 @@
U0 AsmParseInsFlags(CCompCtrl *cc, CInst *tmpins) U0 AsmParseInsFlags(CCompCtrl *cc, CInst *tmpins)
{ {
I64 i; I64 i;
while (TRUE) { while (TRUE)
switch (cc->token) { {
switch (cc->token)
{
case TK_IDENT: case TK_IDENT:
if ((i=ListMatch(cc->cur_str,"NO\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0"))>=0) { if ((i = ListMatch(cc->cur_str, "NO\0CB\0CW\0CD\0CP\0IB\0IW\0ID\0")) >= 0)
{
tmpins->opcode_modifier = i; tmpins->opcode_modifier = i;
break; break;
} else }
else
return; return;
case TK_I64: case TK_I64:
if (cc->cur_i64 == 16) if (cc->cur_i64 == 16)
@ -22,16 +26,19 @@ U0 AsmParseInsFlags(CCompCtrl *cc,CInst *tmpins)
case '/': case '/':
if (Lex(cc) == TK_I64 && cc->cur_i64 < 8) if (Lex(cc) == TK_I64 && cc->cur_i64 < 8)
tmpins->slash_val = cc->cur_i64; tmpins->slash_val = cc->cur_i64;
else if (cc->token==TK_IDENT) { else if (cc->token == TK_IDENT)
{
if (!StrCompare(cc->cur_str, "R")) if (!StrCompare(cc->cur_str, "R"))
tmpins->slash_val = SV_R_REG; tmpins->slash_val = SV_R_REG;
else if (!StrCompare(cc->cur_str, "I")) else if (!StrCompare(cc->cur_str, "I"))
tmpins->slash_val = SV_I_REG; tmpins->slash_val = SV_I_REG;
else else
return; return;
} else }
else
return; return;
break; break;
case '!': tmpins->flags |= IEF_DONT_SWITCH_MODES; break; case '!': tmpins->flags |= IEF_DONT_SWITCH_MODES; break;
case '&': tmpins->flags |= IEF_DEFAULT; break; case '&': tmpins->flags |= IEF_DEFAULT; break;
case '%': tmpins->flags |= IEF_NOT_IN_64_BIT; break; case '%': tmpins->flags |= IEF_NOT_IN_64_BIT; break;
@ -40,6 +47,7 @@ U0 AsmParseInsFlags(CCompCtrl *cc,CInst *tmpins)
case '^': tmpins->flags |= IEF_REX_XOR_LIKE; break; case '^': tmpins->flags |= IEF_REX_XOR_LIKE; break;
case '*': tmpins->flags |= IEF_STI_LIKE; break; case '*': tmpins->flags |= IEF_STI_LIKE; break;
case '$$': tmpins->flags |= IEF_ENDING_ZERO; break; case '$$': tmpins->flags |= IEF_ENDING_ZERO; break;
default: default:
return; return;
} }
@ -71,7 +79,8 @@ U0 AsmHashLoad()
cc = CompCtrlNew(FileRead("OpCodes.DD"),, "OpCodes.DD"); cc = CompCtrlNew(FileRead("OpCodes.DD"),, "OpCodes.DD");
cc->htc.hash_table_list = NULL; cc->htc.hash_table_list = NULL;
Lex(cc); Lex(cc);
while (cc->token) { while (cc->token)
{
if (cc->token != TK_IDENT) if (cc->token != TK_IDENT)
LexExcept(cc, "Expecting identifier at "); LexExcept(cc, "Expecting identifier at ");
i = ListMatch(cc->cur_str, "NONE\0R8\0R16\0R32\0R64\0SEG\0FSTACK\0MM\0XMM\0OPCODE\0KEYWORD\0ASM_KEYWORD\0"); i = ListMatch(cc->cur_str, "NONE\0R8\0R16\0R32\0R64\0SEG\0FSTACK\0MM\0XMM\0OPCODE\0KEYWORD\0ASM_KEYWORD\0");
@ -80,7 +89,8 @@ U0 AsmHashLoad()
Lex(cc); //skip keyword Lex(cc); //skip keyword
if (cc->token != TK_IDENT) if (cc->token != TK_IDENT)
LexExcept(cc, "Expecting identifier at "); LexExcept(cc, "Expecting identifier at ");
switch (i) { switch (i)
{
case REGT_R8...REGT_XMM: case REGT_R8...REGT_XMM:
tmpr = CAlloc(sizeof(CHashReg)); tmpr = CAlloc(sizeof(CHashReg));
tmpr->str = cc->cur_str; tmpr->str = cc->cur_str;
@ -103,7 +113,8 @@ U0 AsmHashLoad()
tmpo_max->str = cc->cur_str; tmpo_max->str = cc->cur_str;
cc->cur_str = 0; cc->cur_str = 0;
Lex(cc); //Skip OPCODE Lex(cc); //Skip OPCODE
while (cc->token && cc->token!=';' && cc->token!=':') { while (cc->token && cc->token != ';' && cc->token != ':')
{
tmpins = &tmpo_max->ins[tmpo_max->inst_entry_count]; tmpins = &tmpo_max->ins[tmpo_max->inst_entry_count];
tmpins->ins_entry_num = tmpo_max->inst_entry_count++; tmpins->ins_entry_num = tmpo_max->inst_entry_count++;
tmpins->slash_val = SV_NONE; //Not zero!! tmpins->slash_val = SV_NONE; //Not zero!!
@ -123,7 +134,8 @@ U0 AsmHashLoad()
tmpins->uasm_slash_val = SV_STI_LIKE; tmpins->uasm_slash_val = SV_STI_LIKE;
tmpins->arg1 = tmpins->arg2 = tmpins->size1 = tmpins->size2 = 0; tmpins->arg1 = tmpins->arg2 = tmpins->size1 = tmpins->size2 = 0;
if (cc->token==TK_IDENT) { if (cc->token == TK_IDENT)
{
j = DefineMatch(cc->cur_str, "ST_ARG_TYPES"); j = DefineMatch(cc->cur_str, "ST_ARG_TYPES");
tmpins->arg1 = j; tmpins->arg1 = j;
if (Bt(&cmp.size_arg_mask[1], j)) if (Bt(&cmp.size_arg_mask[1], j))
@ -135,7 +147,8 @@ U0 AsmHashLoad()
else if (Bt(&cmp.size_arg_mask[8], j)) else if (Bt(&cmp.size_arg_mask[8], j))
tmpins->size1 = 64; tmpins->size1 = 64;
if (Lex(cc)==TK_IDENT) { if (Lex(cc) == TK_IDENT)
{
j = DefineMatch(cc->cur_str, "ST_ARG_TYPES"); j = DefineMatch(cc->cur_str, "ST_ARG_TYPES");
Lex(cc); Lex(cc);
tmpins->arg2 = j; tmpins->arg2 = j;
@ -158,8 +171,10 @@ U0 AsmHashLoad()
LexExcept(cc, "Duplicate OPCODE entry "); LexExcept(cc, "Duplicate OPCODE entry ");
HashAdd(tmpo, cmp.asm_hash); HashAdd(tmpo, cmp.asm_hash);
//Parse aliases. //Parse aliases.
if (cc->token==':') { if (cc->token == ':')
while (Lex(cc)==TK_IDENT) { {
while (Lex(cc) == TK_IDENT)
{
tmpo2 = MAllocIdent(tmpo); tmpo2 = MAllocIdent(tmpo);
tmpo2->str = cc->cur_str; tmpo2->str = cc->cur_str;
cc->cur_str = 0; cc->cur_str = 0;
@ -193,7 +208,8 @@ U0 AsmHashLoad()
} }
Free(tmpo_max); Free(tmpo_max);
CompCtrlDel(cc); CompCtrlDel(cc);
for (i=0;i<INTERNAL_TYPES_NUM;i++) { for (i = 0; i < INTERNAL_TYPES_NUM; i++)
{
tmpit = &internal_types_table[i]; tmpit = &internal_types_table[i];
tmpc = ParseClassNew; tmpc = ParseClassNew;
tmpc->type = HTT_INTERNAL_TYPE; tmpc->type = HTT_INTERNAL_TYPE;

View file

@ -38,6 +38,7 @@ StartOS.CC
/Compiler/ /Compiler/
Asm.CC Asm.CC
AsmInit.CC
CompilerA.HH CompilerA.HH
CompilerB.HH CompilerB.HH