/* */
/* */
/* */
-/* (C) 2017 Christian Krueger */
+/* (C) 2017 Christian Krueger */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
#define COMMA ,
#endif
-#define TEST int main(void) \
- {\
- printf("%s: ",__FILE__);
+#define TEST int main(void) \
+ {\
+ printf("%s: ",__FILE__);
-#define ENDTEST printf("Passed\n"); \
- return EXIT_SUCCESS; \
- }
+#define ENDTEST printf("Passed\n"); \
+ return EXIT_SUCCESS; \
+ }
-#define ASSERT_IsTrue(a,b) if (!(a)) \
- {\
- printf("Fail at line %d:\n",__LINE__);\
- printf(b);\
- printf("\n");\
- printf("Expected status should be true but wasn't!\n");\
- exit(EXIT_FAILURE);\
- }
+#define ASSERT_IsTrue(a,b) if (!(a)) \
+ {\
+ printf("Fail at line %d:\n",__LINE__);\
+ printf(b);\
+ printf("\n");\
+ printf("Expected status should be true but wasn't!\n");\
+ exit(EXIT_FAILURE);\
+ }
-#define ASSERT_IsFalse(a,b) if ((a)) \
- {\
- printf("Fail at line %d:\n",__LINE__);\
- printf(b);\
- printf("\n");\
- printf("Expected status should be false but wasn't!\n");\
- exit(EXIT_FAILURE);\
- }
+#define ASSERT_IsFalse(a,b) if ((a)) \
+ {\
+ printf("Fail at line %d:\n",__LINE__);\
+ printf(b);\
+ printf("\n");\
+ printf("Expected status should be false but wasn't!\n");\
+ exit(EXIT_FAILURE);\
+ }
-#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \
- {\
- printf("Fail at line %d:\n",__LINE__);\
- printf(d);\
- printf("\n");\
- printf("Expected value: "c", but is "c"!\n", (a), (b));\
- exit(EXIT_FAILURE);\
- }
+#define ASSERT_AreEqual(a,b,c,d) if ((a) != (b)) \
+ {\
+ printf("Fail at line %d:\n",__LINE__);\
+ printf(d);\
+ printf("\n");\
+ printf("Expected value: "c", but is "c"!\n", (a), (b));\
+ exit(EXIT_FAILURE);\
+ }
-#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \
- {\
- printf("Fail at line %d:\n",__LINE__);\
- printf(d);\
- printf("\n");\
- printf("Expected value not: "c", but is "c"!\n", (a), (b));\
- exit(EXIT_FAILURE);\
- }
+#define ASSERT_AreNotEqual(a,b,c,d) if ((a) == (b)) \
+ {\
+ printf("Fail at line %d:\n",__LINE__);\
+ printf(d);\
+ printf("\n");\
+ printf("Expected value not: "c", but is "c"!\n", (a), (b));\
+ exit(EXIT_FAILURE);\
+ }
/* End of unittest.h */
#endif
.importzp ptr1, ptr2, tmp3
_strcat:
- sta ptr1 ; Save src
- stx ptr1+1
- jsr popax ; Get dest
- sta tmp3 ; Remember for function return
- tay
- lda #0
- sta ptr2 ; access from page start, y contains low byte
- stx ptr2+1
+ sta ptr1 ; Save src
+ stx ptr1+1
+ jsr popax ; Get dest
+ sta tmp3 ; Remember for function return
+ tay
+ lda #0
+ sta ptr2 ; access from page start, y contains low byte
+ stx ptr2+1
findEndOfDest:
- lda (ptr2),y
- beq endOfDestFound
+ lda (ptr2),y
+ beq endOfDestFound
iny
- bne findEndOfDest
- inc ptr2+1
- bne findEndOfDest
+ bne findEndOfDest
+ inc ptr2+1
+ bne findEndOfDest
endOfDestFound:
- sty ptr2 ; advance pointer to last y position
- ldy #0 ; reset new y-offset
+ sty ptr2 ; advance pointer to last y position
+ ldy #0 ; reset new y-offset
copyByte:
- lda (ptr1),y
- sta (ptr2),y
- beq done
+ lda (ptr1),y
+ sta (ptr2),y
+ beq done
iny
- bne copyByte
- inc ptr1+1
- inc ptr2+1
- bne copyByte ; like bra here
+ bne copyByte
+ inc ptr1+1
+ inc ptr2+1
+ bne copyByte ; like bra here
; return pointer to dest
-done: lda tmp3 ; X does still contain high byte
+done: lda tmp3 ; X does still contain high byte
rts
-
#define SourceStringSize 257 // test correct page passing (>256)
-static char SourceString[SourceStringSize+1]; // +1 room for terminating null
+static char SourceString[SourceStringSize+1]; // +1 room for terminating null
static char DestinationString[2*SourceStringSize+1]; // will contain two times the source buffer
unsigned position = j*SourceStringSize+i;
unsigned current = DestinationString[position];
unsigned expected = (i%128)+1;
- ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position);
+ ASSERT_AreEqual(expected, current, "%u", "Unexpected destination buffer contents at position %u!\n" COMMA position);
}
}
ENDTEST