+ /* ldy #yy+1 */
+ Arg = MakeHexArg (L[2]->Num+1);
+ X = NewCodeEntry (OP65_LDY, AM65_IMM, Arg, 0, L[2]->LI);
+ CS_InsertEntry (S, X, I+12);
+
+ /* adc (sp),y */
+ X = NewCodeEntry (OP65_ADC, AM65_ZP_INDY, "sp", 0, L[3]->LI);
+ CS_InsertEntry (S, X, I+13);
+
+ /* sta (sp),y */
+ X = NewCodeEntry (OP65_STA, AM65_ZP_INDY, "sp", 0, L[3]->LI);
+ CS_InsertEntry (S, X, I+14);
+
+ /* Delete the old code */
+ CS_DelEntries (S, I, 4);
+
+ /* Remember, we had changes */
+ ++Changes;
+
+ }
+
+ /* Next entry */
+ ++I;
+
+ }
+
+ /* Return the number of changes made */
+ return Changes;
+}
+
+
+
+unsigned OptAdd3 (CodeSeg* S)
+/* Search for the sequence
+ *
+ * jsr pushax
+ * lda xxx
+ * ldx yyy
+ * jsr tosaddax
+ *
+ * and replace it by
+ *
+ * clc
+ * adc xxx
+ * pha
+ * txa
+ * adc yyy
+ * tax
+ * pla
+ */
+{
+ unsigned Changes = 0;
+
+ /* Walk over the entries */
+ unsigned I = 0;
+ while (I < CS_GetEntryCount (S)) {
+
+ CodeEntry* L[4];
+
+ /* Get next entry */
+ L[0] = CS_GetEntry (S, I);
+
+ /* Check for the sequence */
+ if (CE_IsCallTo (L[0], "pushax") &&
+ CS_GetEntries (S, L+1, I+1, 3) &&
+ !CS_RangeHasLabel (S, I+1, 3) &&
+ L[1]->OPC == OP65_LDA &&
+ (L[1]->AM == AM65_ABS || L[1]->AM == AM65_ZP) &&
+ L[2]->OPC == OP65_LDX &&
+ (L[2]->AM == AM65_ABS || L[2]->AM == AM65_ZP) &&
+ CE_IsCallTo (L[3], "tosaddax")) {
+
+ CodeEntry* X;
+
+ /* Insert new code behind the sequence */
+ X = NewCodeEntry (OP65_CLC, AM65_IMP, 0, 0, L[3]->LI);