Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is there any method to use a DoorsOS library with TIGCC (such as ZipLib) and how to call a routine that uses something other than the stack in the routine for arguments passing?

0
Posted

Is there any method to use a DoorsOS library with TIGCC (such as ZipLib) and how to call a routine that uses something other than the stack in the routine for arguments passing?

0

Good and common question. When an assembly routine uses register passing, the solution is not so obvious. I will give a concrete example. Look at ZipLib, function compress. This is a cite from DoorsOS documentation: ; compress () ; Function: compress data ; Input: A0 = Pointer to uncompressed data ; A1 = Pointer to where the compressed data ; should be stored ; D0.W = Length of datas which will be compressed ; ziplib::compress equ ziplib@0004 So, how to interface this with TIGCC? There is a lot of solutions. One solution is to use an interface function which accepts parameters via stack then to use embeded assembler to call library function: void compress (void *src, void *dest, unsigned short len) { asm (“move.l (%a6,8),%a0 move.l (%a6,12),%a1 move.w (%a6,16),%d0 jsr ziplib__0004”); } This works, but maybe it is awkward to know where the parameters are stored on the stack. GNU C has some extensions for interfacing with assembler, so the following solution is more elegant: void compres

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123