BEYOn the 2016-02-02 at 05:59pm
Hi all,
time to rewrite some C function to ASM 68K in NEOPHOENIX for speed up the game smile

I'm a total newbie in asm 68K so forgive me for any stupid questions, here's the first one:
//C code: unsigned short code,A; int x,y,yBg,k; yBg=(A&0x1F)+k *VRAM_OFFSET = 0x0800 + (x<<6) + (yBg<<1); *VRAM_VIDEO = 512+code; *VRAM_VIDEO = ((code >> 5)| 0x00 ) << 3; //ASM code: __asm__( "move.w #0x0800, %%d1 \n" // "movw %0, %%d0 \n" // load x from C "lsl.w #0x6, %%d0 \n" //-- x<<6 "add.w %%d0, %%d1 \n" // 0x0800+(x<<6) "movw %1, %%d0 \n" // load y=A & 0x1F from C "andi.w #0x001f, %%d0 \n" // y=(A&0x1F) "movw %2, %%d2 \n" //-- Load k from C in d2 "add.w %%d2, %%d0 \n" // yBg=y+k "lsl.w #0x1, %%d0 \n" // yBg<<1 "add.w %%d0, %%d1 \n" // 0x0800+(x<<6)+(yBg<<1) "move.w %%d1, (0x3C0000) \n" // write data to VRAM_OFFSET "move.w %3, %%d0 \n" // load code from C "move.w %%d0, %%d1 \n" // Backup code into d1 "add.w #0x200, %%d0 \n" // 512+code "move.w %%d0, (0x3C0002) \n" // VRAM_VIDEO in a0 *VRAM_VIDEO = 512+code "and.w #0xffe0, %%d1 \n" "lsl.w #0x3, %%d1 \n" "move.w %%d1, (0x3C0002) \n" // *VRAM_VIDEO VRAM_VIDEO in a0 ((code >> 5) | 0x00 ) << 8 : :"a"(x), "a"(A), "a"(k), "a" (code) :"d0" ,"d1", "d2" );
This code work fine.
The question is: How can I optimize the ASM code? It's possible?