assembly - Any idea why this code is not loading my data properly? -


i new assembly, , working on simple kernal raspberry pi in assembly. have function prints 16-bit characters binary file including .incbin directive. reason though, can't print characters. here snippets of have context:

i have .incbin directive .align 4 loads binary 16-bit font file kernal. places beginning of font characters @ 0x9010.

i passing 0x41 character function capital 'a'. letter begins @ 0x9420.

i loading font base address ldr instruction:

ldr fontaddr, =font 

then, multiplying character 16 , adding address 0x9420 address.

add fontaddr, fontaddr, r0, lsl #4 

r0 input of character code. in loop, getting 1 byte @ time , drawing pixels based on each bit in byte. incrementing fontaddr after each load.

ldrb row, [fontaddr], #1 

my loop , other code works perfectly. tested separately hardcoded data, , printed every pixel of 8x16 character block. also, if change above statement to:

mov row, #0b10101001 

or that, prints 4 vertical lines 16 pixels tall should. error seems in loading of character data. in list file ldr instruction @ 0x8104 , reads memory pointer located @ 0x815c. 0x815c contains .word 0x00009010, points beginning of font data.

80fc:   e59f6048    ldr r6, [pc, #72]   ; 814c <charpixelnodraw$+0x2c>  8100:   e0866200    add r6, r6, r0, lsl #4  8104:   e4d67001    ldrb    r7, [r6], #1  814c:   00009010    .word   0x00009010 

those relevant lines .list file.

from kernal.img file (this 'a' character):

00009420  00 00 00 10 28 28 28 44 44 7c c6 82 00 00 00 00 

could font data far away code accesses it? remember reading not being able have branches or references far apart or exceeds distance instruction can reference.

also, kernal.img file, , can see font data @ correct address, can see 'a' character @ right address, , looks good.

any appreciated. let me know if need supply more info.

thanks!

edit: here complete code listings function:

drawcharacter: push {r4, r5, r6, r7, r8, r9, r10, lr}  x .req r4 y .req r5 orgx .req r9 charaddr .req r6 rows .req r10  mov rows, #0 mov orgx, r1 mov x, r1 mov y, r2  ldr charaddr, =font add charaddr, r0, lsl #4  lineloop$:     bits .req r7     mask .req r8     ldrb bits, [charaddr], #1     mov mask, #0b10000000      charpixelloop$:         tst bits, mask         beq charpixelnodraw$          mov r0, x         mov r1, y         bl drawpixel      charpixelnodraw$:         add x, #1         movs mask, mask, lsr #1         bne charpixelloop$      .unreq mask     .unreq bits     mov x, orgx     add y, #1     add rows, #1     cmp rows, #15     bne lineloop$  pop {r4, r5, r6, r7, r8, r9, r10, pc} 

i removed few irrelevant lines. now, output of .list file:

80e8 <drawcharacter>: 80e8:   e92d47f0    push    {r4, r5, r6, r7, r8, r9, sl, lr} 80ec:   e3a0a000    mov sl, #0 80f0:   e1a09001    mov r9, r1 80f4:   e1a04001    mov r4, r1 80f8:   e1a05002    mov r5, r2 80fc:   e59f6048    ldr r6, [pc, #72]   ; 814c <charpixelnodraw$+0x2c> 8100:   e0866200    add r6, r6, r0, lsl #4  8104 <lineloop$>: 8104:   e4d67001    ldrb    r7, [r6], #1 8108:   e3a08080    mov r8, #128    ; 0x80  810c <charpixelloop$>: 810c:   e1170008    tst r7, r8 8110:   0a000002    beq 8120 <charpixelnodraw$> 8114:   e1a00004    mov r0, r4 8118:   e1a01005    mov r1, r5 811c:   ebffffc0    bl  8024 <drawpixel>  8120 <charpixelnodraw$>: 8120:   e2844001    add r4, r4, #1 8124:   e1b080a8    lsrs    r8, r8, #1 8128:   1afffff7    bne 810c <charpixelloop$> 812c:   e1a04009    mov r4, r9 8130:   e2855001    add r5, r5, #1 8134:   e28aa001    add sl, sl, #1 8138:   e35a000f    cmp sl, #15 813c:   1afffff0    bne 8104 <lineloop$> 8140:   e8bd87f0    pop {r4, r5, r6, r7, r8, r9, sl, pc} 8144:   00009000    .word   0x00009000 8148:   00009004    .word   0x00009004 814c:   00009010    .word   0x00009010 

i know of code has excess register usage , variables, have been trying things out , breaking try find issue. and, mentioned, works, when hard code byte data.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -