#21 Missing statement in ASM

closed-fixed
nobody
5
2000-09-30
2000-09-17
Anonymous
No

The comiler produced assembly code missed a statement from the original c code.

unsigned char i2bcd(unsigned char i)
{
unsigned char ret;

ret = 0;

if (i > 9) {
ret = ((i / 10) << 4);
i %= 10; <---- Missed in ASM
}

if (i > 0)
ret |= i;

return ret;
}

Assembly code:
; -----------------------------------------
; function i2bcd
; -----------------------------------------
_i2bcd:
; num.c 30
mov r2,dpl
; num.c 20
mov r3,#0x00
; num.c 22
clr c
mov a,#0x09
subb a,r2
; Peephole 108 removed ljmp by inverse jump logic
jnc 00102$
00109$:
; num.c 23
mov b,#0x0a
mov a,r2
div ab
; Peephole 105 removed redundant mov
mov r4,a
swap a
anl a,#0xf0
mov r3,a
00102$:
; num.c 27
clr c
; Peephole 180 changed mov to clr
clr a
subb a,r2
; Peephole 108 removed ljmp by inverse jump logic
jnc 00104$
00110$:
; num.c 28
mov a,r2
orl ar3,a
00104$:
; num.c 30
mov dpl,r3
00105$:
C$num.c$31$1$1 ==.
XG$i2bcd$0$0 ==.
ret

Discussion

  • Sandeep Dutta
    Sandeep Dutta
    2000-09-30

    Fixed in latest source tree

     
  • Sandeep Dutta
    Sandeep Dutta
    2000-09-30

    • status: open --> closed-fixed