fb_write:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
stmfd sp!, {r4, r5, r6, r7, r8, lr} store registers
ldr lr, .L245 @lr = 0x0004AFF8 original array start adress (local)
ldr ip, .L245+4 @ip = 38399 init of the counter
add lr, r0, lr @lr += r0 calculation of the full adress
mov r0, r1 @r0 = r1 change of base adress
mov r4, #248
mov r6, #252
.L240:
ldmia lr, {r7-r8} @r7 = LSW r8 = MSW example 0x008f8f8f and 0x001133ff (grey and red-orange)
and r2, r8, r4, asl #16 @r2 = r8 & (0xF8<<16) r2 = MSW & 0x00F80000 = 0x00100000 //MSW red
and r3, r8, r6, asl #8 @r3 = r8 & (0xFC<<8) r3 = MSW & 0x0000FC00 = 0x00003000 //MSW green
mov r1, r2, lsr #3 @r1 = r2 >> 3 r1 = 0x00100000 >> 3 = 0x00020000
orr r1, r1, r3, asl #11 @r1 = r1 | (r3 << 11) r1 = 0x00020000 | 0x01800000 = 0x01820000
and r3, r8, r4 @r3 = r8 & 0xF8 r3 = MSW & 0x000000F8 = 0x000000F8 //MSW blue
orr r1, r1, r3, asl #24 @r1 = r1 | (r3 << 24) r1 = 0x01820000 | 0xF8000000 = 0xF9820000
and r3, r7, r4, asl #16 @r3 = r7 & (0xF8<<16) r3 = LSW & 0x00F80000 = 0x00880000 //LSW red
orr r1, r1, r3, lsr #19 @r1 = r1 | (r3 >> 19) r1 = r1 | r3 = 0xF9820000 | 0x00000011 = 0xF9820011
and r3, r7, r6, asl #8 @r3 = r7 & (0xFC<<8) r3 = LSW & 0x0000FC00 = 0x0000F800 //LSW green
orr r1, r1, r3, lsr #5 @r1 = r1 | (r3>>5) r1 = r1 | r3 = 0xF9820011 | 0x000007C0 = 0xF98207D1
and r7, r7, r4 @r7 = r7 & 0x000000F8 r7 = LSW & 0x000000F8 = 0x00000088
orr r1, r1, r7, asl #8 @r1 = r1 | (r7 << 8) r1 = r1 | (r7 << 8) = 0xF98207D1 | 0x00008800 = 0xF9828FD1
str r1, [r0, ip, asl #2] @[r0 + (ip * 4)] = r1 write of r1 into the array
subs ip, ip, #1 @ip-- decrementation of ip
sub lr, lr, #8 @lr -= 8 decrementation of the original array pointer
bne .L240 @if (ip!=0) go back to .L240 loop condition
ldmfd sp!, {r4, r5, r6, r7, r8, pc} @restore registers
.L240: @original loop
mov r5, #0 @r5 = 0
ldmia lr, {r7-r8} @r7 = LSW r8 = MSW //example 0x008f8f8f and 0x001133ff (grey and red-orange)
mov r4, #16252928 @r4 = 0x00F80000
and r3, r7, r5 @r3 = r7 & r5 r3 = LSW & 0x00000000 = 0 //LSW ? (USELESS)
mov r6, #64512 @r6 = 0x0000FC00
and r2, r8, r4 @r2 = r8 & r4 r2 = MSW & 0x00F80000 = 0x00100000 //MSW red
mov r3, r3, lsr #21 @r3 >>= 21 r3 = 0 >> 21 = 0
and r4, r8, r6 @r4 = r8 & r6 r4 = MSW & 0x0000FC00 = 0x00003000 //MSW green
orr r3, r3, r4, asl #11 @r3 = r3 | (r4 << 11) r3 = r4 << 11 = 0x00003000 << 11 = 0x01800000
mov r5, #0 @r5 = 0
mov r1, r2, lsr #3 @r1 = r2 >> 3 r1 = 0x00100000 >> 3 = 0x00020000
orr r1, r1, r3 @r1 = r1 | r3 r1 = 0x00020000 | 0x01800000 = 0x01820000
mov r6, #248 @r6 = 0x000000F8
and r3, r7, r5 @r3 = r7 & r5 r3 = LSW & 0x00000000 = 0 //LSW ? (USELESS)
and r4, r8, r6 @r4 = r8 & r6 r4 = MSW & 0x000000F8 = 0x000000F8 //MSW blue
mov r3, r3, lsr #8 @r3 >>= 8 r3 = 0 >> 8 = 0 //USELESS
orr r3, r3, r4, asl #24 @r3 = r3 | (r4 << 24) r3 = r4 << 24 = 0x000000F8 << 24 = 0xF8000000
mov r5, #16252928 @r5 = 0x00F80000
orr r1, r1, r3 @r1 = r1 | r3 r1 = 0x01820000 | 0xF8000000 = 0xF9820000
mov r6, #0 @r6 = 0
and r3, r7, r5 @r3 = r7 & r5 r3 = LSW & 0x00F80000 = 0x00880000 //LSW red
and r4, r8, r6 @r4 = r8 & r6 r4 = MSW & 0 = 0 //USELESS
mov r3, r3, lsr #19 @r3 >>= 19 r3 = r3 >> 19 = 0x00880000 >> 19 = 0x00000011
orr r3, r3, r4, asl #13 @r3 = r3 | (r4 << 13) r3 = r3 //USELESS
mov r5, #64512 @r5 = 0x0000FC00
orr r1, r1, r3 @r1 = r1 | r3 r1 = r1 | r3 = 0xF9820000 | 0x00000011 = 0xF9820011
mov r6, #0 @r6 = 0
and r3, r7, r5 @r3 = r7 & r5 r3 = LSW & 0x0000FC00 = 0x0000F800 //LSW green
and r4, r8, r6 @r4 = r8 & r6 r4 = MSW & 0 = 0 //USELESS
mov r3, r3, lsr #5 @r3 >>= 5 r3 = r3 >> 5 = 0x0000F800 >> 5 = 0x000007C0
orr r3, r3, r4, asl #27 @r3 = r3 | (r4 << 27) r3 = r3 //USELESS
orr r1, r1, r3 @r1 = r1 | r3 r1 = r1 | r3 = 0xF9820011 | 0x000007C0 = 0xF98207D1
and r7, r7, #248 @r7 = r7 & 0x000000F8 r7 = LSW & 0x000000F8 = 0x00000088
orr r1, r1, r7, asl #8 @r1 = r1 | (r7 << 8) r1 = r1 | (r7 << 8) = 0xF98207D1 | 0x00008800 = 0xF9828FD1
str r1, [r0, ip, asl #2] @[r0 + (ip * 4)] = r1 write of r1 into the array //TODO use only ip
subs ip, ip, #1 @ip-- decrementation of ip
mov r4, r4, lsr #5 @r4 >>= 5 r4 = r4 >> 5 = 0 //USELESS
sub lr, lr, #8 @lr -= 8 decrementation of the original array pointer
bne .L240 @if (ip!=0) go back to .L240 loop condition
ldmfd sp!, {r4, r5, r6, r7, r8, pc} @restore registers
.L246:
.align 2
.L245:
.word 307192
.word 38399
.size fb_write, .-fb_write
.section .rodata.str1.4
.align 2