diff --git a/sw/test_exec/Makefile b/sw/test_exec/Makefile new file mode 100644 index 0000000..8aec806 --- /dev/null +++ b/sw/test_exec/Makefile @@ -0,0 +1,41 @@ +CC=~/Software/cc65/bin/cl65 +CFLAGS=-v -T -t none -I. --cpu "65C02" +test: CFLAGS=-T -t sim65c02 -I. +LDFLAGS=-v -C link.ld -m $(NAME).map +SIM=sim65 +SIMARGS=-v -c -x 1000000 + +NAME=test + +BIN=$(NAME).o65 +HEX=$(NAME).hex + +LISTS=lists + +SRCS=$(wildcard *.s) $(wildcard *.c) +OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS))) +OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS))) + +all: $(BIN) + +$(HEX): $(BIN) + objcopy --input-target=binary --output-target=ihex $(BIN) $(HEX) + + +$(BIN): $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ + +%.o: %.c $(LISTS) + $(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@ + +%.o: %.s $(LISTS) + $(CC) $(CFLAGS) -l $(LISTS)/$<.list -c $< -o $@ + +$(LISTS): + mkdir -p $(addprefix $(LISTS)/,$(sort $(dir $(SRCS)))) + +.PHONY: clean +clean: + rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) $(NAME).map + rm -rf $(TEST_OBJS) $(TEST_BIN) + diff --git a/sw/test_exec/link.ld b/sw/test_exec/link.ld new file mode 100644 index 0000000..ade4e99 --- /dev/null +++ b/sw/test_exec/link.ld @@ -0,0 +1,43 @@ +MEMORY +{ + ZP: start = $0, size = $100, type = rw, define = yes; + SDRAM: start = $1000, size = $6ef0, type = rw, define = yes; +} + +FILES { + %O: format = o65; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + DATA: load = SDRAM, type = rw, define = yes, run = SDRAM; + BSS: load = SDRAM, type = bss, define = yes; + HEAP: load = SDRAM, type = bss, optional = yes; + STARTUP: load = SDRAM, type = ro; + ONCE: load = SDRAM, type = ro, optional = yes; + CODE: load = SDRAM, type = ro; + RODATA: load = SDRAM, type = ro; +} + +FEATURES { + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + # Define the stack size for the application + __STACKSIZE__: value = $0200, type = weak; + __STACKSTART__: type = weak, value = $0800; # 2k stack + +} + +FORMATS { + o65: os = 5, version = 0, type = small, + export = _main; + } diff --git a/sw/test_exec/main.c b/sw/test_exec/main.c new file mode 100644 index 0000000..ad40be3 --- /dev/null +++ b/sw/test_exec/main.c @@ -0,0 +1,3 @@ +int main() { + return 0x41; +} \ No newline at end of file diff --git a/sw/test_exec/out.txt b/sw/test_exec/out.txt new file mode 100644 index 0000000..863dd89 --- /dev/null +++ b/sw/test_exec/out.txt @@ -0,0 +1,289 @@ +mkdir -p lists/./ +~/Software/cc65/bin/cl65 -T -t none -I. --cpu "65C02" -l lists/main.c.list -c main.c -o main.o +~/Software/cc65/bin/cl65 -T -t none -I. --cpu "65C02" -C link.ld -m test.map main.o -o test.o65 +Writing a bunch of data! +1 0 6f 36 35 + +Writing size value 1025 +Writing size value 0 +Writing size value 1000 +Writing size value 0 +Writing size value 1025 +Writing size value 0 +Writing size value 0 +Writing size value 0 +Writing size value 0 +Writing a bunch of data! +74 65 73 74 2e 6f 36 35 0 + +Writing a bunch of data! +6c 64 36 35 20 56 32 2e 31 39 20 2d 20 47 69 74 20 30 38 35 31 34 37 34 37 35 0 + +Writing a bunch of data! +46 72 69 20 41 70 72 20 31 35 20 31 36 3a 30 34 3a 30 31 20 32 30 32 32 0 + +Writing a bunch of data! +5 0 + +WRITING TEXT SEGWrite seg count: 4, dowrite: 1 +Writing a bunch of data! +a9 + +Writing a bunch of data! +a2 + +Writing a bunch of data! +85 + +Writing a bunch of data! +86 + +Writing a bunch of data! +20 + +Writing a bunch of data! +20 + +Writing a bunch of data! +20 + +Writing a bunch of data! +48 + +Writing a bunch of data! +20 + +Writing a bunch of data! +68 + +Writing a bunch of data! +60 + +Writing a bunch of data! +a0 + +Writing a bunch of data! +f0 + +Writing a bunch of data! +7 + +Writing a bunch of data! +a9 + +Writing a bunch of data! +a2 + +Writing a bunch of data! +4c + +Writing a bunch of data! +60 + +Writing a bunch of data! +a2 cc + +Writing a bunch of data! +a9 dd + +Writing a bunch of data! +4c + +Writing a bunch of data! +60 + +Writing a bunch of data! +a0 + +Writing a bunch of data! +f0 + +Writing a bunch of data! +7 + +Writing a bunch of data! +a9 + +Writing a bunch of data! +a2 + +Writing a bunch of data! +4c + +Writing a bunch of data! +60 + +Writing a bunch of data! +a9 + +Writing a bunch of data! +85 + +Writing a bunch of data! +a9 + +Writing a bunch of data! +85 + +Writing a bunch of data! +a9 0 + +Writing a bunch of data! +a8 + +Writing a bunch of data! +a2 + +Writing a bunch of data! +f0 + +Writing a bunch of data! +a + +Writing a bunch of data! +91 + +Writing a bunch of data! +c8 + +Writing a bunch of data! +d0 + +Writing a bunch of data! +fb + +Writing a bunch of data! +e6 + +Writing a bunch of data! +ca + +Writing a bunch of data! +d0 + +Writing a bunch of data! +f6 + +Writing a bunch of data! +c0 + +Writing a bunch of data! +f0 + +Writing a bunch of data! +5 + +Writing a bunch of data! +91 + +Writing a bunch of data! +c8 + +Writing a bunch of data! +d0 + +Writing a bunch of data! +f7 + +Writing a bunch of data! +60 + +Text count: 4 +Text Size: 90 +WRITING DATA SEGWrite seg count: 1, dowrite: 1 +Writing a bunch of data! +8d + +Writing a bunch of data! +8e + +Writing a bunch of data! +8d + +Writing a bunch of data! +8e + +Writing a bunch of data! +88 + +Writing a bunch of data! +b9 ff ff + +Writing a bunch of data! +8d + +Writing a bunch of data! +88 + +Writing a bunch of data! +b9 ff ff + +Writing a bunch of data! +8d + +Writing a bunch of data! +8c + +Writing a bunch of data! +20 ff ff + +Writing a bunch of data! +a0 ff + +Writing a bunch of data! +d0 + +Writing a bunch of data! +e8 + +Writing a bunch of data! +60 + +Data count: 1 +Data Size: 37 +Write seg count: 1, dowrite: 0 +Writing zp seg (this should just be a few)Write seg count: 1, dowrite: 0 +WRITING IMPORTSWriting size value 0 +ExtSymCount: 0 +WRITING TEXT RELOCATION + + +Writing a bunch of data! +6 25 2 25 2 82 3 82 3 82 4 82 9 22 2 42 3c 2 83 8 82 8 22 2 42 3c 2 83 4 24 2 25 2 44 0 2 25 9 25 5 25 9 25 0 + +Writing a bunch of data! +2 83 3 83 3 83 3 83 7 83 7 83 3 83 0 + +Writing size value 1 +Writing a bunch of data! +5f 6d 61 69 6e 0 + +Writing size value 1048 +Writing a bunch of data! +1 0 6f 36 35 + +Writing size value 1025 +Writing size value 5a +Writing size value 1000 +Writing size value 25 +Writing size value 1025 +Writing size value 0 +Writing size value 0 +Writing size value 1a +Writing size value 0 +Writing a bunch of data! +74 65 73 74 2e 6f 36 35 0 + +Writing a bunch of data! +6c 64 36 35 20 56 32 2e 31 39 20 2d 20 47 69 74 20 30 38 35 31 34 37 34 37 35 0 + +Writing a bunch of data! +46 72 69 20 41 70 72 20 31 35 20 31 36 3a 30 34 3a 30 31 20 32 30 32 32 0 + +Writing a bunch of data! +5 0 + +Text Base: 1025 +Text Size: 5a +Data Base: 1000 +Data Size: 25 diff --git a/sw/test_exec/out2.txt b/sw/test_exec/out2.txt new file mode 100644 index 0000000..b60e9a4 --- /dev/null +++ b/sw/test_exec/out2.txt @@ -0,0 +1,488 @@ +mkdir -p lists/./ +~/Software/cc65/bin/cl65 -v -T -t none -I. --cpu "65C02" -l lists/main.c.list -c main.c -o main.o +0 errors and 0 warnings generated. +Opened output file 'main.s' +Wrote output to 'main.s' +Closed output file 'main.s' +~/Software/cc65/bin/cl65 -v -T -t none -I. --cpu "65C02" -v -C link.ld -m test.map main.o -o test.o65 +Module 'main.o': Found segment 'CODE', size = 8, alignment = 1, type = 2 +Module 'main.o': Found segment 'RODATA', size = 0, alignment = 1, type = 2 +Module 'main.o': Found segment 'BSS', size = 0, alignment = 1, type = 2 +Module 'main.o': Found segment 'DATA', size = 0, alignment = 1, type = 2 +Module 'main.o': Found segment 'ZEROPAGE', size = 0, alignment = 1, type = 1 +Module 'main.o': Found segment 'NULL', size = 0, alignment = 1, type = 2 +Module 'condes.o': Found segment 'CODE', size = 12, alignment = 1, type = 2 +Module 'condes.o': Found segment 'RODATA', size = 0, alignment = 1, type = 2 +Module 'condes.o': Found segment 'BSS', size = 0, alignment = 1, type = 2 +Module 'condes.o': Found segment 'DATA', size = 37, alignment = 1, type = 2 +Module 'condes.o': Found segment 'ZEROPAGE', size = 0, alignment = 1, type = 1 +Module 'condes.o': Found segment 'NULL', size = 0, alignment = 1, type = 2 +Module 'condes.o': Found segment 'ONCE', size = 12, alignment = 1, type = 2 +Module 'crt0.o': Found segment 'CODE', size = 0, alignment = 1, type = 2 +Module 'crt0.o': Found segment 'RODATA', size = 0, alignment = 1, type = 2 +Module 'crt0.o': Found segment 'BSS', size = 0, alignment = 1, type = 2 +Module 'crt0.o': Found segment 'DATA', size = 0, alignment = 1, type = 2 +Module 'crt0.o': Found segment 'ZEROPAGE', size = 0, alignment = 1, type = 1 +Module 'crt0.o': Found segment 'NULL', size = 0, alignment = 1, type = 2 +Module 'crt0.o': Found segment 'STARTUP', size = 23, alignment = 1, type = 2 +Module 'zerobss.o': Found segment 'CODE', size = 35, alignment = 1, type = 2 +Module 'zerobss.o': Found segment 'RODATA', size = 0, alignment = 1, type = 2 +Module 'zerobss.o': Found segment 'BSS', size = 0, alignment = 1, type = 2 +Module 'zerobss.o': Found segment 'DATA', size = 0, alignment = 1, type = 2 +Module 'zerobss.o': Found segment 'ZEROPAGE', size = 0, alignment = 1, type = 1 +Module 'zerobss.o': Found segment 'NULL', size = 0, alignment = 1, type = 2 +Module 'zeropage.o': Found segment 'CODE', size = 0, alignment = 1, type = 2 +Module 'zeropage.o': Found segment 'RODATA', size = 0, alignment = 1, type = 2 +Module 'zeropage.o': Found segment 'BSS', size = 0, alignment = 1, type = 2 +Module 'zeropage.o': Found segment 'DATA', size = 0, alignment = 1, type = 2 +Module 'zeropage.o': Found segment 'ZEROPAGE', size = 26, alignment = 1, type = 1 +Module 'zeropage.o': Found segment 'NULL', size = 0, alignment = 1, type = 2 +Opened 'test.o65'... +Writing size value 1025 +Writing size value 0 +Writing size value 1000 +Writing size value 0 +Writing size value 1025 +Writing size value 0 +Writing size value 0 +Writing size value 0 +Writing size value 0 +WRITING TEXT SEG Writing 'STARTUP' + Section from "crt0.o" + Filling 0x0 bytes with 0x00 + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Section from "[linker generated]" + Filling 0x0 bytes with 0x00 + Section from "[linker generated]" + Filling 0x0 bytes with 0x00 + Writing 'ONCE' + Section from "condes.o" + Filling 0x0 bytes with 0x00 + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Writing 'CODE' + Section from "main.o" + Filling 0x0 bytes with 0x00 + Fragment with 0x2 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Section from "condes.o" + Filling 0x0 bytes with 0x00 + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Section from "crt0.o" + Filling 0x0 bytes with 0x00 + Section from "zerobss.o" + Filling 0x0 bytes with 0x00 + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Section from "zeropage.o" + Filling 0x0 bytes with 0x00 + Writing 'RODATA' + Section from "main.o" + Filling 0x0 bytes with 0x00 + Section from "condes.o" + Filling 0x0 bytes with 0x00 + Section from "crt0.o" + Filling 0x0 bytes with 0x00 + Section from "zerobss.o" + Filling 0x0 bytes with 0x00 + Section from "zeropage.o" + Filling 0x0 bytes with 0x00 +Text count: 4 +Text Size: 90 +WRITING DATA SEG Writing 'DATA' + Section from "main.o" + Filling 0x0 bytes with 0x00 + Section from "condes.o" + Filling 0x0 bytes with 0x00 + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x3 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x3 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x2 bytes + Fragment with 0x3 bytes + Fragment with 0x2 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Fragment with 0x1 bytes + Section from "crt0.o" + Filling 0x0 bytes with 0x00 + Section from "zerobss.o" + Filling 0x0 bytes with 0x00 + Section from "zeropage.o" + Filling 0x0 bytes with 0x00 +Data count: 1 +Data Size: 37 + Writing 'BSS' +Writing zp seg (this should just be a few) Writing 'ZEROPAGE' +WRITING IMPORTSWriting size value 0 +ExtSymCount: 0 +WRITING TEXT RELOCATION + + +Writing size value 1 +Writing size value 1048 +Writing size value 1025 +Writing size value 5a +Writing size value 1000 +Writing size value 25 +Writing size value 1025 +Writing size value 0 +Writing size value 0 +Writing size value 1a +Writing size value 0 +Text Base: 1025 +Text Size: 5a +Data Base: 1000 +Data Size: 25 +Segment: CODE (55) + Section: + Literal (2 bytes): + A2 CC + Literal (2 bytes): + A9 DD + Literal (1 bytes): + 4C + Expression (2 bytes): + SEC $0007 + + Literal (1 bytes): + 60 + Section: + Literal (1 bytes): + A0 + Expression (1 bytes): + SYM() $0002 * BYTE0 + Literal (1 bytes): + F0 + Literal (1 bytes): + 07 + Literal (1 bytes): + A9 + Expression (1 bytes): + SYM() BYTE0 + Literal (1 bytes): + A2 + Expression (1 bytes): + SYM() BYTE1 + Literal (1 bytes): + 4C + Expression (2 bytes): + SEC + Literal (1 bytes): + 60 + Section: + Section: + Literal (1 bytes): + A9 + Expression (1 bytes): + SYM() BYTE0 + Literal (1 bytes): + 85 + Expression (1 bytes): + SYM() + Literal (1 bytes): + A9 + Expression (1 bytes): + SYM() BYTE1 + Literal (1 bytes): + 85 + Expression (1 bytes): + SYM() $0001 + + Literal (2 bytes): + A9 00 + Literal (1 bytes): + A8 + Literal (1 bytes): + A2 + Expression (1 bytes): + SYM() BYTE1 + Literal (1 bytes): + F0 + Literal (1 bytes): + 0A + Literal (1 bytes): + 91 + Expression (1 bytes): + SYM() + Literal (1 bytes): + C8 + Literal (1 bytes): + D0 + Literal (1 bytes): + FB + Literal (1 bytes): + E6 + Expression (1 bytes): + SYM() $0001 + + Literal (1 bytes): + CA + Literal (1 bytes): + D0 + Literal (1 bytes): + F6 + Literal (1 bytes): + C0 + Expression (1 bytes): + SYM() BYTE0 + Literal (1 bytes): + F0 + Literal (1 bytes): + 05 + Literal (1 bytes): + 91 + Expression (1 bytes): + SYM() + Literal (1 bytes): + C8 + Literal (1 bytes): + D0 + Literal (1 bytes): + F7 + Literal (1 bytes): + 60 + Section: +Segment: RODATA (0) + Section: + Section: + Section: + Section: + Section: +Segment: BSS (0) + Section: + Section: + Section: + Section: + Section: +Segment: DATA (37) + Section: + Section: + Literal (1 bytes): + 8D + Expression (2 bytes): + SEC $000D + $0001 + + Literal (1 bytes): + 8E + Expression (2 bytes): + SEC $000D + $0002 + + Literal (1 bytes): + 8D + Expression (2 bytes): + SEC $0014 + $0001 + + Literal (1 bytes): + 8E + Expression (2 bytes): + SEC $0014 + $0002 + + Literal (1 bytes): + 88 + Literal (3 bytes): + B9 FF FF + Literal (1 bytes): + 8D + Expression (2 bytes): + SEC $001D + $0002 + + Literal (1 bytes): + 88 + Literal (3 bytes): + B9 FF FF + Literal (1 bytes): + 8D + Expression (2 bytes): + SEC $001D + $0001 + + Literal (1 bytes): + 8C + Expression (2 bytes): + SEC $0020 + $0001 + + Literal (3 bytes): + 20 FF FF + Literal (2 bytes): + A0 FF + Literal (1 bytes): + D0 + Literal (1 bytes): + E8 + Literal (1 bytes): + 60 + Section: + Section: + Section: +Segment: ZEROPAGE (26) + Section: + Section: + Section: + Section: + Section: + Empty space (2 bytes) + Empty space (2 bytes) + Empty space (4 bytes) + Empty space (2 bytes) + Empty space (2 bytes) + Empty space (2 bytes) + Empty space (2 bytes) + Empty space (1 bytes) + Empty space (1 bytes) + Empty space (1 bytes) + Empty space (1 bytes) + Empty space (6 bytes) +Segment: NULL (0) + Section: + Section: + Section: + Section: + Section: +Segment: ONCE (12) + Section: + Literal (1 bytes): + A0 + Expression (1 bytes): + SYM() $0002 * BYTE0 + Literal (1 bytes): + F0 + Literal (1 bytes): + 07 + Literal (1 bytes): + A9 + Expression (1 bytes): + SYM() BYTE0 + Literal (1 bytes): + A2 + Expression (1 bytes): + SYM() BYTE1 + Literal (1 bytes): + 4C + Expression (2 bytes): + SEC + Literal (1 bytes): + 60 +Segment: STARTUP (23) + Section: + Literal (1 bytes): + A9 + Expression (1 bytes): + SYM() BYTE0 + Literal (1 bytes): + A2 + Expression (1 bytes): + SYM() BYTE1 + Literal (1 bytes): + 85 + Expression (1 bytes): + SYM() + Literal (1 bytes): + 86 + Expression (1 bytes): + SYM() $0001 + + Literal (1 bytes): + 20 + Expression (2 bytes): + SYM() + Literal (1 bytes): + 20 + Expression (2 bytes): + SYM() + Literal (1 bytes): + 20 + Expression (2 bytes): + SYM() + Literal (1 bytes): + 48 + Literal (1 bytes): + 20 + Expression (2 bytes): + SYM() + Literal (1 bytes): + 68 + Literal (1 bytes): + 60 + Section: + Section: +CONDES(0): 0 symbols +CONDES(1): 0 symbols +CONDES(2): 0 symbols +CONDES(3): 0 symbols +CONDES(4): 0 symbols +CONDES(5): 0 symbols +CONDES(6): 0 symbols diff --git a/sw/test_exec/test.o65 b/sw/test_exec/test.o65 new file mode 100644 index 0000000..d34296e Binary files /dev/null and b/sw/test_exec/test.o65 differ