Page 1 of 1

Number switching (very simple inline ASM)

Posted: Tue Jan 25, 2005 7:56 pm
by Tvspelsfreak
As requested by GV, I'll post a very simple ASM example of switching 2 numbers.

Code: Select all

#include <stdio.h>

void main(){
    int a = 10;
    int b = 20;

    printf("Before:\t%d,%d\n",a,b);

    __asm{
        mov eax,a
        mov ebx,b
        mov a,ebx
        mov b,eax
    }

    printf("After:\t%d,%d\n",a,b);
}

Posted: Tue Jan 25, 2005 8:29 pm
by Falco Girgis
Btw, it's moving a to register eax and b to register ebx. Then it's putting what's in ebx in a and what's in eax in b.

Thanks for explaining that Tvspelsfreak. XD

Posted: Wed Jan 26, 2005 7:27 am
by JS Lemming
Yeah I diddle daddled in ASM in my time. But it was for TI 83 plus. Hmm. It looks easy to incorparate. Maybe I can use it to speed up some repetive code! An asm particle engine would be friggen sweet.

Posted: Wed Jan 26, 2005 8:11 am
by Falco Girgis
Dear god, I pray that you aren't talking about for Dreamcast.

You do realize that x86 ASM is NOT going to work on DC. ASM is not portable so whatever platform you code that particle engine for will stay on that platform.

It's SH4 asm for the DC.

Posted: Wed Jan 26, 2005 8:16 am
by JS Lemming
NAH DUH Gyrovobis! I'm sad you would think that I am that nieve.

Posted: Wed Jan 26, 2005 8:19 am
by Falco Girgis
I was just making sure.

Maybe you are naive!

:guffaw:

Posted: Wed Jan 26, 2005 8:22 am
by JS Lemming
No i think YOU are the nuaieve one. :lol: