* lookup the information about this function and use it. The jump itself
* does not change any registers, so we don't need to use the data from D.
*/
- if (E->OPC == OPC_JSR || ((E->Info & OF_BRA) != 0 && E->JumpTo == 0)) {
+ if ((E->Info & (OF_BRA | OF_CALL)) != 0 && E->JumpTo == 0) {
/* A subroutine call or jump to external symbol (function exit) */
GetFuncInfo (E->Arg, &E->Use, &E->Chg);
} else {
-CodeEntry* NewCodeEntry (opc_t OPC, am_t AM, const char* Arg, CodeLabel* JumpTo)
+CodeEntry* NewCodeEntry (opc_t OPC, am_t AM, const char* Arg,
+ CodeLabel* JumpTo, LineInfo* LI)
/* Create a new code entry, initialize and return it */
{
/* Get the opcode description */
CodeEntry* E = xmalloc (sizeof (CodeEntry));
/* Initialize the fields */
- E->OPC = D->OPC;
- E->AM = AM;
- E->Size = GetInsnSize (E->OPC, E->AM);
- E->Hints = 0;
- E->Arg = GetArgCopy (Arg);
- if (NumArg (E->Arg, &E->Num)) {
- E-> Flags = CEF_NUMARG;
- } else {
- E->Flags = 0;
- }
+ E->OPC = D->OPC;
+ E->AM = AM;
+ E->Arg = GetArgCopy (Arg);
+ E->Flags = NumArg (E->Arg, &E->Num)? CEF_NUMARG : 0;
E->Info = D->Info;
+ E->Size = GetInsnSize (E->OPC, E->AM);
E->JumpTo = JumpTo;
+ E->LI = UseLineInfo (LI);
SetUseChgInfo (E, D);
InitCollection (&E->Labels);
/* Cleanup the collection */
DoneCollection (&E->Labels);
+ /* Release the line info */
+ ReleaseLineInfo (E->LI);
+
/* Free the entry */
xfree (E);
}
/* Replace the opcode */
E->OPC = OPC;
- E->Size = GetInsnSize (E->OPC, E->AM);
E->Info = D->Info;
+ E->Size = GetInsnSize (E->OPC, E->AM);
SetUseChgInfo (E, D);
}
void AttachCodeLabel (CodeEntry* E, CodeLabel* L)
/* Attach the label to the entry */
{
- /* Mark the label as defined */
- L->Flags |= LF_DEF;
-
/* Add it to the entries label list */
CollAppend (&E->Labels, L);
/* Print the operand */
switch (E->AM) {
- case AM_IMP:
+ case AM65_IMP:
/* implicit */
break;
- case AM_ACC:
+ case AM65_ACC:
/* accumulator */
Chars += fprintf (F, "%*sa", 9-Chars, "");
break;
- case AM_IMM:
+ case AM65_IMM:
/* immidiate */
Chars += fprintf (F, "%*s#%s", 9-Chars, "", E->Arg);
break;
- case AM_ZP:
- case AM_ABS:
+ case AM65_ZP:
+ case AM65_ABS:
/* zeropage and absolute */
Chars += fprintf (F, "%*s%s", 9-Chars, "", E->Arg);
break;
- case AM_ZPX:
- case AM_ABSX:
+ case AM65_ZPX:
+ case AM65_ABSX:
/* zeropage,X and absolute,X */
Chars += fprintf (F, "%*s%s,x", 9-Chars, "", E->Arg);
break;
- case AM_ABSY:
+ case AM65_ABSY:
/* absolute,Y */
Chars += fprintf (F, "%*s%s,y", 9-Chars, "", E->Arg);
break;
- case AM_ZPX_IND:
+ case AM65_ZPX_IND:
/* (zeropage,x) */
Chars += fprintf (F, "%*s(%s,x)", 9-Chars, "", E->Arg);
break;
- case AM_ZP_INDY:
+ case AM65_ZP_INDY:
/* (zeropage),y */
Chars += fprintf (F, "%*s(%s),y", 9-Chars, "", E->Arg);
break;
- case AM_ZP_IND:
+ case AM65_ZP_IND:
/* (zeropage) */
Chars += fprintf (F, "%*s(%s)", 9-Chars, "", E->Arg);
break;
- case AM_BRA:
+ case AM65_BRA:
/* branch */
Target = E->JumpTo? E->JumpTo->Name : E->Arg;
Chars += fprintf (F, "%*s%s", 9-Chars, "", Target);
}
/* Print usage info if requested by the debugging flag */
-// if (Debug) {
- Chars += fprintf (F,
- "%*s; USE: %c%c%c CHG: %c%c%c SIZE: %u",
- 30-Chars, "",
- (E->Use & REG_A)? 'A' : '_',
- (E->Use & REG_X)? 'X' : '_',
- (E->Use & REG_Y)? 'Y' : '_',
- (E->Chg & REG_A)? 'A' : '_',
- (E->Chg & REG_X)? 'X' : '_',
- (E->Chg & REG_Y)? 'Y' : '_',
- E->Size);
-// }
-
+ if (Debug) {
+ fprintf (F,
+ "%*s; USE: %c%c%c CHG: %c%c%c SIZE: %u\n",
+ 30-Chars, "",
+ (E->Use & REG_A)? 'A' : '_',
+ (E->Use & REG_X)? 'X' : '_',
+ (E->Use & REG_Y)? 'Y' : '_',
+ (E->Chg & REG_A)? 'A' : '_',
+ (E->Chg & REG_X)? 'X' : '_',
+ (E->Chg & REG_Y)? 'Y' : '_',
+ E->Size);
+ } else {
+ /* Terminate the line */
+ fprintf (F, "\n");
+ }
}
+