Page 2 of 2

Posted: Mon Jan 19, 2015 9:35 pm
by Mask of Destiny
KanedaFr wrote:I should wait for dma busy flag, I just couldn't simply loop on the list, right ?
There's no point in checking the DMA busy flag for a 68K->VDP transfer as the 68K will be locked out of the bus until the DMA is complete anyway. It's only useful for copies and fills.
KanedaFr wrote:I must understand how write inline asm with param ;)
Standard C calling convention on the 68K passes arguments on the stack. Probably in right to left order, but I'm not 100% sure.

Posted: Tue Jan 20, 2015 7:58 pm
by Chilly Willy
The standard ABI for m68k is d0-d1/a0-a1/cc are scratch, all args are pushed on the stack from right to left as LONGWORDS regardless of the type, results are returned in d0 if it fits, and d0-d1/a0-a1 for things up to 4 longs in length. Inline assembly is done like this:

Code: Select all

    asm volatile (
        "moveq #31,%0\n"
        "1:\n\t"
        "dbra %0,1b\n\t"
        : "=d" (tmp)
        :
        : "cc"
    );

Posted: Tue Jan 20, 2015 11:58 pm
by KanedaFr
ho! i didn't know you have to "backup" cc too.
It's the flag register, right ? CCR ?
thanks for the info

Posted: Wed Jan 21, 2015 1:04 am
by Chilly Willy
KanedaFr wrote:ho! i didn't know you have to "backup" cc too.
It's the flag register, right ? CCR ?
thanks for the info
Yes, "cc" is the ccr. It's not really backed up, that's the clobber line which tells the compiler that the clobbered register can't be relied on after the inline assembly. In this case, it tells the compiler that if it HAD been counting on the ccr being a particular state, that state is gone after the assembly.

Any register the compiler uses to pass the args is automatically considered clobbered, so you have to tell it if any other registers get clobbered. Most platforms assume the cc is clobbered by default, but the 680x0 can do so much without clobbering the ccr that it doesn't assume it's clobbered unless you tell it.

Also, "d" and "=d" puts the arg into a data register, while "a" and "=a" puts it in an address register. Shoulda pointed this little bit out in the first post since it's not entirely obvious.