DMA memory to VRAM

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

Mask of Destiny
Very interested
Posts: 572
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Mon Jan 19, 2015 9:35 pm

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.

Chilly Willy
Very interested
Posts: 2603
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jan 20, 2015 7:58 pm

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"
    );

User avatar
KanedaFr
Administrateur
Posts: 1117
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Tue Jan 20, 2015 11:58 pm

ho! i didn't know you have to "backup" cc too.
It's the flag register, right ? CCR ?
thanks for the info

Chilly Willy
Very interested
Posts: 2603
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Jan 21, 2015 1:04 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest