This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Arm Programming Problem


Arm Programming Problem

Postby leolau » Feb 3, 2004 @ 5:10am

I want to convert a C function into ARM function. But the arm function doesn't work. Please have a look and tell me what's wrong. Thank!!

C function:

#define MK_RGB565(R,G,B) ((MAX(0,MIN(255, R)) << 8) & 0xf800)
|\((MAX(0,MIN(255, G)) << 3) & 07e0)
|\((MAX(0,MIN(255, B)) >> 3) & 0x001f)

*(uint16_t *) dst = MK_RGB565(r, g, b);

ARM function:
; extern "C" void MKRGB(unsigned char* dst, int r, int g, int b);
;
mov r7, #0

mov r4, r1
mov r5, r2
mov r6, r3

cmp r4, #0
movlt r4, #0
cmp r4, #255
movgt r4, #255

cmp r5, #0
movlt r5, #0
cmp r5, #255
movgt r5, #255

cmp r6, #0
movlt r6, #0
cmp r6, #255
movgt r6, #255

mov r4, r4, LSL #8
and r7, r4, #0x0000f800

mov r5, r5, LSL #3
and r7, r5, #0x000007e0

mov r6, r6, LSR #3
and r7, r6, #0x0000001f

strh r7, [r0]
leolau
pm Member
 
Posts: 6
Joined: Dec 29, 2003 @ 11:12am


Re: Arm Programming Problem

Postby Kak » Feb 3, 2004 @ 8:31am

User avatar
Kak
pm Member
 
Posts: 291
Joined: Jul 26, 2003 @ 12:24pm
Location: Zannarkand, Spira


Postby leolau » Feb 3, 2004 @ 11:15am

leolau
pm Member
 
Posts: 6
Joined: Dec 29, 2003 @ 11:12am


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron