test some more possible cases and move test into test/val

This commit is contained in:
mrdudz
2022-08-28 03:43:54 +02:00
parent d371046ae4
commit ce6ee1b891
3 changed files with 45 additions and 27 deletions

45
test/val/bug1252.c Normal file
View File

@@ -0,0 +1,45 @@
// bug #1252 - inline asm: cc65 chokes on label ref if space/tab follows
#include <stdlib.h>
int main(void)
{
// first test the recommended way to use labels in inline assembly:
// this works
c_label:
asm("inx\n"
"bne %g\n",
c_label);
// this does not work
c_label2:
asm("inx\n"
"bne %g \n",
c_label2);
// now the following is from the original bug report. note that using labels
// this way only works by chance - the name of the label may clash with
// generated labels
// this works
asm("label1: inx\n"
"bne label1\n");
// this does not work
asm("label2: inx\n"
"bne label2 \n");
// a variant of the above using local labels.
// this works
asm("@label1: inx\n"
"bne @label1\n");
// this does not work
asm("@label2: inx\n"
"bne @label2 \n");
return EXIT_SUCCESS;
}