#85 256 byte arrays into paged area?



it would be nice if char arrays of 256 byte length were
automagically allocated
to a paged (256 byte aligned) area:


This might allow to reduce the overhead for an xdata
array access
xdata unsigned char buf[256];


; buf[ head ] = c;
; genPlus
mov a,_head
add a,#_buf
mov dpl,a
clr a
addc a,#(_buf >> 8)
mov dph,a
mov a,r2
movx @dptr,a

Down to:

; buf[ head ] = c;
; genPlus
; genPlus aligned array
mov dpl,_head
mov dph,#(_buf >> 8)
mov a,r2
movx @dptr,a

(SDCC generates this code if an absolute address like
"at 0x8000" was
specified for the array. This request is somewhat
similar to RFE #774501
but it doesn't require an additional keyword)


  • Maarten Brock

    Maarten Brock - 2004-10-19

    Logged In: YES

    Feel free to store it in pdata instead of xdata

  • Frieder Ferlemann

    Logged In: YES

    Hi Maarten,
    thanks a lot for adding pdata access!) !)

    When I filed this request, I had buffers (like those two
    256 byte buffers in sdcc/device/lib/serial.c) in my mind.
    I wouldn't want to loose the newly won memory space
    for only one of those buffers;)

  • Maarten Brock

    Maarten Brock - 2004-11-29

    Logged In: YES

    Looked into this. It's probably not so hard to make the linker
    move such arrays to the front of the list and thereby
    allocating them to page boundaries. This assumes xdata
    starts at a page boundary. (Not true if pdata is used and
    <256 and no xstack. Also not true if --xram-loc says so.)

    But the problem is that the compiler doesn't know all this. So
    a special keyword might be in place. Maybe something like "at
    page" instead of "at 0x0000"?

  • Frieder Ferlemann

    Logged In: YES

    These 256byte arrays could be allocated before the pdata
    addressed section of xdata memory.
    Alternately maybe the linker could be convinced
    to allocate some areas (here the 256byte arrays) top down?

  • Maarten Brock

    Maarten Brock - 2004-11-30

    Logged In: YES

    Ok, after some more thought it "only" requires an extra
    segment. And indeed if put before pdata, we have one issue
    less. Allthough it won't work if --xram-loc is used. And the
    only solution I know to that problem is to skip to the next
    page (with warning?). Or we need an option to tell the
    compiler not to use this optimization.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks