#68 access to array of struct uses unneeded add

open
nobody
None
1
2004-04-01
2004-04-01
No

Accessing a member within an array of struct causes
an unnecessary addition at runtime:

xdata struct
{
int a;
int b;
} c[3];

void test( unsigned char i)
{
c[i].b = 0;
}

;rfe.c:9: c[i].b = 0;
; genMult
; genMultOneByte
mov a,dpl
mov r2,a
mov b,#0x04
mul ab
; genPlus
add a,#_c ; -> add a,#(_c + 0x02)
mov r2,a
mov a,b
addc a,#(_c >> 8) ; -> addc a,#((_c + 0x02) >> 8)
mov r3,a
; genPlus
; genPlusIncr
mov a,#0x02 ; adding 0x02 could be done at compile-time
add a,r2
mov dpl,a
clr a
addc a,r3
mov dph,a
; genPointerSet
; genFarPointerSet
clr a
movx @dptr,a
inc dptr
movx @dptr,a

Discussion


Log in to post a comment.

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks