- X = NewCodeEntry (OP65_STA, AM65_ZP, "ptr1+1", 0, L[3]->LI);
- CS_InsertEntry (S, X, I+4);
+ X = NewCodeEntry (OP65_STA, AM65_ZP, "ptr1+1", 0, L[4]->LI);
+ CS_InsertEntry (S, X, I+5);
+
+ /* If the instruction before the adc is a ldx, replace the
+ * txa by and lda with the same location of the ldx.
+ */
+ if ((P = CS_GetPrevEntry (S, I)) != 0 &&
+ P->OPC == OP65_LDX &&
+ !CE_HasLabel (P)) {
+
+ X = NewCodeEntry (OP65_LDA, P->AM, P->Arg, 0, P->LI);
+ CS_InsertEntry (S, X, I+4);
+ CS_DelEntry (S, I+3);
+ }