EtchedPixels / CC6303

A C compiler for the 6800 series processors
Other
37 stars 7 forks source link

[Question] #23

Closed kikich10 closed 8 months ago

kikich10 commented 8 months ago

I’m experimenting with your compiler for the Matra Alice 32/90

I can compile and run the program. But using a little more calculations like some divisions, I get these error codes when compiling:

/opt/cc68/lib/lib6803.a: Unknown symbol 'div16x16'.
/opt/cc68/lib/lib6803.a: Unknown symbol 'pop2'.

Second to be able to take advantage a little more of the capabilities of the machine. I need to be able to embed ASM code, but I can’t: Error: Error in __asm__ format specifier 1

thank you for your work

EtchedPixels commented 8 months ago

Can you share a test case and command line used. Those two should both be coming from lib6803.a so either it didn't build right in your case or there is some pattern of linkage that is messing up and not including these two functions.

There's no provision for inline asm in the compiler - just linking with files built with the assembler.

kikich10 commented 8 months ago

Yes, of course, with this little source code, the error appears with me:

#include <stdio.h>
void main() {
    uint16_t value=255;
    value = value/55;
}

The command line to compile is: cc68 -tmc10 ./test.c -o test

I’m quite new to programming. Can you quickly explain how to link an asm file?

EtchedPixels commented 8 months ago

I have pushed a patch to fix this (it got broken due to a change for the other compiler that uses these assembler/linker tools).

For assembly an example might be simplest


foo.c:

extern int bar(void);
int foo(void) { return bar(); }

bar.s

.setcpu 6803
.export _bar
      .code
_bar:
       ldd #1234
      addd _xyz
      rts

     .data
_xyz: .word 0

cc -tmc100 foo.c bar.s

C puts "_" in front of all user function and variable names. They also need to exported on the asm side to be visible in C.

You can also access arguments in asm functions. They are pushed on the stack before the call so if you use TSX LDD offset,X you can access them.

The assembler code doesn't need to preserve D X or the flags

EtchedPixels commented 8 months ago

If the Alice32 would benefit from different start addresses etc or startup and keyboard/console code let me know.

kikich10 commented 8 months ago

Thank you for your help, it works well and I can also inject my asm code. The codes for keyboards and the console works fine.

For the memory I found this information:


Memory Map d'alice 32/90


=========================

EtchedPixels commented 8 months ago

Thanks for the info