Ziz
Advanced Member
- Joined
- Jan 15, 2006
- Messages
- 3,583
Hello,
First of all i'am German and my english is bad.
But I think, here are the people to help me. :rolleyes:
my problem:
I would like to learn something about arm-assembler especially in gcc.
So I use the gcc inline assembler.
my references are
GBA-ARM-Tutorial (german)
ARM GCC Inline (english)
That is my code:
CODE
void hline(SDL_Surface* screen,Uint16 x,Uint16 y,Uint16 l,Uint16 f)
{
SDL_LockSurface(screen);
Uint16* pixel=(Uint16*)screen->pixels;
#ifdef GP2X
Uint32 pos=(x+y*320)*2+Uint32(pixel);
asm volatile(".myloop: \n\t"
"strh %2,[%0],#2 \n\t"
"subs %1,%1,#1 \n\t"
"bne .myloop"
: "=&r" (pos), "=&r"(l), "=&r"(f)
:
: "cc", "r3");
#endif
#ifndef GP2X
Uint32 pos=(x+y*320);
for (int a=pos;a<pos+l;a++)
pixel[a]=f;
#endif
SDL_UnlockSurface(screen);
}
The "#ifndef GP2X"-Part is not necessary. It works.
The problem is in the "#ifdef GP2X" Part.
I should draw a horizontal line from (x,y) to (x+l,y) in color f.
But if I start this function (with x=10;y=10;l=10;f=65535) the program stops and I land in the menu.
So where is my failure?
Thx for reading and sorry for my baaaad english again. :rolleyes:
Cyberpuer
First of all i'am German and my english is bad.
But I think, here are the people to help me. :rolleyes:
my problem:
I would like to learn something about arm-assembler especially in gcc.
So I use the gcc inline assembler.
my references are
GBA-ARM-Tutorial (german)
ARM GCC Inline (english)
That is my code:
CODE
void hline(SDL_Surface* screen,Uint16 x,Uint16 y,Uint16 l,Uint16 f)
{
SDL_LockSurface(screen);
Uint16* pixel=(Uint16*)screen->pixels;
#ifdef GP2X
Uint32 pos=(x+y*320)*2+Uint32(pixel);
asm volatile(".myloop: \n\t"
"strh %2,[%0],#2 \n\t"
"subs %1,%1,#1 \n\t"
"bne .myloop"
: "=&r" (pos), "=&r"(l), "=&r"(f)
:
: "cc", "r3");
#endif
#ifndef GP2X
Uint32 pos=(x+y*320);
for (int a=pos;a<pos+l;a++)
pixel[a]=f;
#endif
SDL_UnlockSurface(screen);
}
The "#ifndef GP2X"-Part is not necessary. It works.
The problem is in the "#ifdef GP2X" Part.
I should draw a horizontal line from (x,y) to (x+l,y) in color f.
But if I start this function (with x=10;y=10;l=10;f=65535) the program stops and I land in the menu.
So where is my failure?
Thx for reading and sorry for my baaaad english again. :rolleyes:
Cyberpuer