gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > colors problem

#21450 - realV - Sat May 29, 2004 2:52 pm

Code (GNU gas)
---------------------

.text
.arm
.global main

bitmap: .hword 0x1FFF,0xFFFF,0x1111,0x1232

main:
ldr r0,=0x04000000
ldrh r1,=0x0403
strh r1,[r0]

ldr r0,=0x06000000
ldr r1,=bitmap
ldr r2,=4
.load:
ldrh r3,[r1],#2
strh r3,[r0],#2
subs r2,r2,#1
bne .load

.loop:
b .loop

I tested this code on Linux VisualBoyAdvance , WindowsXp VisualBoyAdvance , Linux Boycott but all pixels that are displayed on the screen are BLUE (VBA) or WHITE (boycott).
When i write this programm in goldroad asm then it is ok , but GNU as dosn't work.

The next programm in gas works:

ldr r0,=0x06000000
ldrh r1,=0x1FFF
strh r1,[r0]

the displayed pixel color is ok

I don't know where is the problem , maybe someone can help me.

PS: Sory for my anglish

#21472 - sajiimori - Sat May 29, 2004 7:25 pm

You're not writing back to r0 and r1 in the loop.

#21480 - realV - Sat May 29, 2004 9:46 pm

I found some error:

bitmap: .word 0x1FFF1FFF

main:
ldr r0,=0x04000000
ldrh r1,=0x0403
strh r1,[r0]

ldr r0,=0x06000000
ldr r1,=bitmap

ldr r2,[r1]
str r2,[r0] --> now the walue at address r0 should be 0x1FFF1FFF but
--> VisualBoyAdvance (windows) disassemble tool shows
--> that the walue 0x06000000 = 464c457f so the first 2 pixels are not YELLOW

but where is the bug in my code , please help ?

PS: Sorry for my anglish

#21484 - realV - Sat May 29, 2004 10:39 pm

Low level hacking is realy cool :)
The code should look like:

...

ldr r0,=0x06000000
ldr r1,=bitmap

str r1,[r0] @now 0x06000000=0x1FFF1FFF

...

Now it works ...