diff --git a/test/asm/listing/200-overwrite.cfg b/test/asm/listing/200-overwrite.cfg new file mode 100644 index 000000000..b7b2fee49 --- /dev/null +++ b/test/asm/listing/200-overwrite.cfg @@ -0,0 +1,20 @@ +MEMORY +{ + A: start = 0, size = 8, file = %O, fill = yes, fillval = $33; + B: start = 8, size = 8, file = %O, fill = yes, fillval = $44; + C: start = 0, size = 8, file = %O, fill = yes, fillval = $55; + D: start = 8, size = 8, file = %O, fill = no, fillval = $66; +} +SEGMENTS +{ + A: load = A, type = ro; + B: load = B, type = ro; + C0: load = C, type = ro; + C1: load = C, type = ro, start = 5; + D: load = D, type = ro; + + AO: load = A, type = overwrite, start = 4; + BO: load = B, type = overwrite, start = 8+5; + CO: load = C, type = overwrite, start = 2; + DO: load = D, type = overwrite, start = 8+4; +} diff --git a/test/asm/listing/200-overwrite.s b/test/asm/listing/200-overwrite.s new file mode 100644 index 000000000..cd2349c6a --- /dev/null +++ b/test/asm/listing/200-overwrite.s @@ -0,0 +1,29 @@ +; verification of overwrite segment feature +; See: https://github.com/cc65/cc65/issues/1366 + +; A: full memory area which is overwritten to the end +.segment "A" +.byte 0,1,2,3,4,5,6,7 +.segment "AO" +.byte $24,$25,$26,$27 + +; B: incomplete memory area overwritten in the fill area +.segment "B" +.byte 0,1,2 +.segment "BO" +.byte $25,$26 + +; C: memory area with gap overwritten across the gap +.segment "C0" +.byte 0,1,2 +.segment "C1" +.byte 5,6,7 +.segment "CO" +.byte $22,$23,$24,$25 + +; D: incomplete memory area without fill, +; but overwrite extends past existing segments +.segment "D" +.byte 0,1,2 +.segment "DO" +.byte $24,$25 diff --git a/test/asm/listing/201-overwrite-overflow.cfg b/test/asm/listing/201-overwrite-overflow.cfg new file mode 100644 index 000000000..cada57d5a --- /dev/null +++ b/test/asm/listing/201-overwrite-overflow.cfg @@ -0,0 +1,12 @@ +MEMORY +{ + A: start = 0, size = 8, file = %O, fill = yes, fillval = $33; + B: start = 8, size = 8, file = %O, fill = yes, fillval = $44; +} +SEGMENTS +{ + A: load = A, type = ro; + B: load = B, type = ro; + AO: load = A, type = overwrite, start = 6; + BO: load = B, type = overwrite, start = 8+6; +} diff --git a/test/asm/listing/201-overwrite-overflow.s b/test/asm/listing/201-overwrite-overflow.s new file mode 100644 index 000000000..156388ab5 --- /dev/null +++ b/test/asm/listing/201-overwrite-overflow.s @@ -0,0 +1,13 @@ +; verification of overwrite segment overflow cases + +; error: overflow past end of A memory area +.segment "A" +.byte 0,1,2,3 +.segment "AO" +.byte $26,$27,$28 + +; error: overflow past end of B memory area +.segment "B" +.byte 0,1,2,3 +.segment "BO" +.byte $26,$27,$28 diff --git a/test/asm/listing/Makefile b/test/asm/listing/Makefile index 3c4c404af..204984b64 100644 --- a/test/asm/listing/Makefile +++ b/test/asm/listing/Makefile @@ -58,12 +58,20 @@ $(WORKDIR)/$1.bin: $1.s $(ISEQUAL) ifeq ($(wildcard control/$1.err),) $(CA65) -t none -o $$(@:.bin=.o) $$< > $$(@:.bin=.err) 2> $$(@:.bin=.err2) ifeq ($(wildcard control/$1.no-ld65),) +ifeq ($(wildcard $1.cfg),) $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) +else + $(LD65) -C $$(<:.s=.cfg) -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) +endif endif else $(CA65) -t none -o $$(@:.bin=.o) $$< > $$(@:.bin=.err) 2> $$(@:.bin=.err2) || $(TRUE) ifeq ($(wildcard control/$1.no-ld65),) +ifeq ($(wildcard $1.cfg),) $(LD65) -t none -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) || $(TRUE) +else + $(LD65) -C $$(<:.s=.cfg) -o $$@ $$(@:.bin=.o) none.lib > $$(@:.bin=.ld65-err) 2> $$(@:.bin=.ld65-err2) || $(TRUE) +endif endif endif @@ -117,12 +125,20 @@ endif ifeq ($(wildcard control/$1.err),) $(CA65) -t none -l $$(@:.bin=.list-lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2> $$(@:.bin=.list-err2) ifeq ($(wildcard control/$1.no-ld65),) +ifeq ($(wildcard $1.cfg),) $(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) +else + $(LD65) -C $$(<:.s=.cfg) -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) +endif endif else $(CA65) -t none -l $$(@:.bin=.list-lst) -o $$(@:.bin=.list-o) $$< > $$(@:.bin=.list-err) 2> $$(@:.bin=.list-err2) || $(TRUE) ifeq ($(wildcard control/$1.no-ld65),) +ifeq ($(wildcard $1.cfg),) $(LD65) -t none -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) || $(TRUE) +else + $(LD65) -C $$(<:.s=.cfg) -o $$(@:.bin=.list-bin) $$(@:.bin=.list-o) none.lib > $$(@:.bin=.list-ld65-err) 2> $$(@:.bin=.list-ld65-err2) || $(TRUE) +endif endif endif diff --git a/test/asm/listing/control/201-overwrite-overflow.err b/test/asm/listing/control/201-overwrite-overflow.err new file mode 100644 index 000000000..e69de29bb diff --git a/test/asm/listing/readme.txt b/test/asm/listing/readme.txt index d6280b954..5436b234a 100644 --- a/test/asm/listing/readme.txt +++ b/test/asm/listing/readme.txt @@ -4,6 +4,8 @@ Overall test: These testcases can be used to test different aspects of the assembler. The name of a test is everything in the form .s. +If a custom linker configuration is needed, also include .cfg. + The following reference files can be added: - ref/.bin-ref: diff --git a/test/asm/listing/ref/200-overwrite.bin-ref b/test/asm/listing/ref/200-overwrite.bin-ref new file mode 100644 index 000000000..b3a6f4f63 Binary files /dev/null and b/test/asm/listing/ref/200-overwrite.bin-ref differ diff --git a/test/asm/listing/ref/201-overwrite-overflow.ld65err2-ref b/test/asm/listing/ref/201-overwrite-overflow.ld65err2-ref new file mode 100644 index 000000000..e372938ef --- /dev/null +++ b/test/asm/listing/ref/201-overwrite-overflow.ld65err2-ref @@ -0,0 +1,3 @@ +ld65: Warning: 201-overwrite-overflow.cfg:3: Segment 'AO' overflows memory area 'A' by 1 byte +ld65: Warning: 201-overwrite-overflow.cfg:4: Segment 'BO' overflows memory area 'B' by 1 byte +ld65: Error: Cannot generate most of the files due to memory area overflows diff --git a/test/asm/readme.txt b/test/asm/readme.txt index c3198c12a..db7f64504 100644 --- a/test/asm/readme.txt +++ b/test/asm/readme.txt @@ -1,32 +1,38 @@ Assembler Testcases =================== -Opcode Tests: -------------- +cpudetect +--------- -these go into opcodes/. Refer to opcodes/readme.txt +Tests the --cpu command line option of ca65/ld65. +Refer to cpudetect/readme.txt -CPU Detect Tests ----------------- +opcodes +------- -these go into cpudetect/. Refer to cpudetect/readme.txt +Test of assembler opcodes for each CPU. +Refer to opcodes/readme.txt -Overall tests: --------------- - -These go into listing/. Refer to listing/readme.txt - -val: ----- - -Works very much like the /val directory used to test the compiler - individual -tests are run in the simulator and should exit with an exit code of 0 when they -pass, or either -1 or a number indicating what part of the test failed on error. - err: ---- -Works very much like the /err directory used to test the compiler - individual -tests are assembled and MUST NOT assemble without error. +Used to test assembler errors. These tests MUST NOT assemble without error. + + +listing: +-------- + +This is the most versatile assembler test form, allowing control customizations, +reference tests for binary output, stdout and error text ouput, error tests, +listings, custom linker configuration, etc. as needed. +Refer to listing/readme.txt + + +val: +---- + +Runtime assembly tests using sim65 that should exit with an exit code of 0 when +the pass, or either -1 or a number indicating what part of the test failed on +error.