#153284 - yaazz - Thu Mar 27, 2008 6:22 pm
I am trying to write a simple asm program to draw a square on the screen. I am using the concept of Y * W + X will give you the correct index but it doesnt seem to work. Does anyone see any obvious problem with my code?
Code: |
.arm .text .global main main: mov r0, #0x4000000 mov r1, #0x400 add r1, r1, #3 str r1, [r0] mov r0, #0x6000000 @ address of VRAM mov r1, #0x6500 @ some pinkish color add r1, r1, #0x9E mov r2, #0xF0 @ the width of the screen mov r3, #0x64 @X=100 mov r4, #0x32 @Y=50 mov r5, #0x32 @W & H = 50 loop1: mul r6, r4, r5 @curposition = Y * Width add r6, r6, r3 @curposition += X loop2: strh r1, [r0,r6] @ will store the 16bit value in r1 into address in r0, then add r6,r6,#2 @ add 16bits to r6 subs r5, r5, #0x1 @ subtract 1 from W bne loop2 @ if W!=0 goto loop2 add r1, r1, #0x1 @make the color something else mov r5, #0x32 @Reset the W variable add r4, r4, #1 @add 1 to Y variable cmp r4, #100 @compare Y to 100 bne loop1 @if not equal goto loop 1 infin: @ an infinite loop b infin |