jun Posted October 11, 2021 Share Posted October 11, 2021 Hi, Everybody. I'm having trouble referencing the libti99 header file properly. ・Is the location of libti99 wrong? ・Is the make of libti99 failed? ・Is there any other reason? I would appreciate your ideas. 【Install procedure】 1.Install gcc and gcc fot ti on Ubntu 20.04.3 LTS 2.Download gcc-installer.tar.gz from and install. 3.Get libti99 from https://github.com/tursilion/libti99 and compile. Then I placed the libti99 directory to /home/user/tigcc/lib/gcc/tms9900/4.4.0/include 【Trouble】 I want to use vdp.h to compile the following code #include <libti99/vdp.h> void main() { /* VDP SETUP */ int x = set_bitmap_raw(VDP_SPR_8x8); VDP_SET_REGISTER(VDP_REG_MODE1, x); VDP_SET_REGISTER(VDP_REG_SIT, 7); // 1C00 /* VDP_SET_REGISTER(VDP_REG_CT, 0x80); // 2000 VDP_SET_REGISTER(VDP_REG_PDT, 0); // 0000 VDP_SET_REGISTER(VDP_REG_SDT, 3); // 1800 */ VDP_SET_REGISTER(VDP_REG_SAL,0x3E); // 1F00 /* RESTORE VRAM */ vdpmemcpy(0x0000, (unsigned char*)0x5000, 0x1000); vdpmemcpy(0x1000, (unsigned char*)0x9000, 0x3000); /* RETURN TO G-BASIC */ __asm__("li r0,>F000"); __asm__("li r1,>0100"); __asm__("li r15,>6000"); __asm__("movb *R0+,*R15+"); __asm__("dec r1"); __asm__("joc >0FFA"); __asm__("lwpi >6000"); __asm__("li r0,>8F00"); __asm__("li r1,>0100"); __asm__("li r15,>F000"); __asm__("movb *R0+,*R15+"); __asm__("dec r1"); __asm__("joc >0FFA"); __asm__("limi >0003"); __asm__("lwpi >F0A0"); __asm__("b @>0E5C"); } But,I get an error code like the following and cannot build. /home/user/tigcc/lib/gcc/tms9900/4.4.0/../../../../tms9900/bin/ld: warning: cannnot find entry symbol _start; defaulting to 000000000000a074 /tmp/ccuxOSjn.o: In function `main': (.text+0x110): undefined reference to `set_bitmap_raw' /tmp/ccuxOSjn.o: In function `main': (.text+0x146): undefined reference to `vdpmemcpy' /tmp/ccuxOSjn.o: In function `main': (.text+0x156): undefined reference to `vdpmemcpy' collect2: ld returned 1 exit status. I think tms9900-gcc(or/and ld) can not referencing vdp.h , or this header file is not built properly. I tried my best to solve this problem on my own, but I could not. Any help in resolving this would be appreciated. Thank you. Quote Link to comment Share on other sites More sharing options...
jun Posted October 11, 2021 Author Share Posted October 11, 2021 Ah! There seems to be a problem with the contents of the Makefile! I may be able to fix it myself. I don't know how to delete the Topic, so I'll leave it. I'll report back when it's done. Sorry to bother you. 1 Quote Link to comment Share on other sites More sharing options...
+Ksarul Posted October 11, 2021 Share Posted October 11, 2021 Definitely let us know what happened there, as it may help someone else out of a similar problem in the future. . . 2 Quote Link to comment Share on other sites More sharing options...
Tursi Posted October 12, 2021 Share Posted October 12, 2021 crt0.s is not being linked in - that's where the symbol START is defined. It's needed to initialize the system and stack, and jump to main(). Looks like you also aren't linking in libti99.a, either (need a "-lti99" at the end of the linker line). This is the link for testlib in the libti99 Makefile: test: library testlib.o $(OBJECT_LIST_EA5) $(LD) $(OBJECT_LIST_EA5) testlib.o $(LDFLAGS_EA5) -L. -lti99 -o testlib.ea5.elf > ea5.map $(ELF2EA5) testlib.ea5.elf testlib.ea5.bin $(EA5_SPLIT) testlib.ea5.bin cp TESTLI* $(CLASSIC99_DSK1) Not sure how familiar you are with Makefiles, so for the the sake of everyone I'll break it down: First line specifies the target (test) and the dependencies - if any of those change, then this target needs to be remade. So library is the target that builds libti99 itself, you would not need that in your own, testlib.o is the compiled form of testlib.c, and $(OBJECT_LIST_EA5) references an earlier list in the makefile. This is the bit that creates testlib.o from testlib.c - in fact it turns any referenced .c file into a .o: # Recipe to compile all C files %.o: %.c $(CC) -c $< $(C_FLAGS) -o $@ And this is the definition for OBJECT_LIST_EA5 - you can see it's literally just the object form of the crt0_ea5.s: OBJECT_LIST_EA5=\ crt0_ea5.o And finally, the same syntax is used to turn all assembly source into object files: # Recipe to compile all C files %.o: %.c $(CC) -c $< $(C_FLAGS) -o $@ That's a lot of information in the first line - but that's the power of Makefiles - all the references. The second line does the actual linking - since the first line implies that the compile itself was already done: $(LD) $(OBJECT_LIST_EA5) testlib.o $(LDFLAGS_EA5) -L. -lti99 -o testlib.ea5.elf > ea5.map The indentation in Makefiles is important, that's how it knows which rule lines are associated with. There are a few variables here, all defined earlier in the Makefile: $(LD) - the link command, which makes to tms9900-ld $(OBJECT_LIST_EA5) - the crt0 object file. This must always be first or the code won't work, even if it links, since it's the startup code. testlib.o - the object form of testlib.c, as discussed above $(LDFLAGS_EA5) - these are the linker command flags. They include the start addresses for text (program) - A000 and data (2080). -M generates a readable map of the linked data. -L. - this adds the current folder (.) to the search path for library files - replace '.' with the path to your library -lti99 - this links the library ti99 into the program, which is the file libti99.a, searched for in the library path -o testlib.ea5.elf - this makes the output file testlib.ea5.elf. The gcc compiler creates ELF files by default that need further processing to run. > ea5.map - the map information is output on standard out, so this redirects it to ea5.map $(ELF2EA5) testlib.ea5.elf testlib.ea5.bin This runs the ELF2EA5 program to convert the ELF file into a fixed binary PROGRAM-style image. Tool should be available with the compiler but you may need to build it separately. Alternately, if you build libti99 successfully, you must already have it. $(EA5_SPLIT) testlib.ea5.bin Likewise, the output of ELF2EA5 doesn't honor the 8k limit, so this tool splits it up into separate pieces. I can't remember if this came with the compiler or I wrote it. Same as above. cp TESTLI* $(CLASSIC99_DSK1) And I'm surprised nobody complains about this, but this copies the TESTLIB1, TESTLIB2, etc files to the Classic99 DSK1 folder, if you set up the path earlier. Obviously optional. 5 Quote Link to comment Share on other sites More sharing options...
+jedimatt42 Posted October 12, 2021 Share Posted October 12, 2021 Normally you don't copy the built libti99 directory of headers around. Instead you use the gcc options like (capital I) -I to add to the include path, and (lowercase el) -l to reference the library libti99.a file. These are fairly normal C compiler options. Insomnia's GCC patches to target the 9900 leave usage the same as any GCC toolchain. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.