Version used: C:\sdcc\bin>sdcc -v SDCC : mcs51/z80 3.0.1 #6064 (Nov 21 2010) (MINGW32)
Compile command line: C:\SDCC\BIN\sdcc sips.c -mz80 -c --codeseg CODE5 Code will compile wrong: if (Sip_pCurLcb->pReqUri) free(Sip_pCurLcb->pReqUri); Sip_pCurLcb->pReqUri = heap_save_str(pBuf); if (Sip_pCurLcb->pInvUri) free(Sip_pCurLcb->pInvUri); Sip_pCurLcb->pInvUri = heap_save_str(pBuf); heap_save_str will call malloc and return point, but Sip_pCurLcb->pReqUri and Sip_pCurLcb->pInvUri are both 0 in result, asm related part in the end. After rearrange code to: if (Sip_pCurLcb->pReqUri) free(Sip_pCurLcb->pReqUri); if (Sip_pCurLcb->pInvUri) free(Sip_pCurLcb->pInvUri); Sip_pCurLcb->pReqUri = heap_save_str(pBuf); Sip_pCurLcb->pInvUri = heap_save_str(pBuf); This will compile and get correct result. Previous 2.9.0 does not have this problem. Wrong related asm: ;sips.c:2090: if (Sip_pCurLcb->pReqUri) free(Sip_pCurLcb->pReqUri); ld hl,(_Sip_pCurLcb) ld bc, #0x0054 add hl,bc ld c, l ld b, h ld l, c ld a,(hl) inc hl or a,(hl) jr Z,00132$ ld hl,(_Sip_pCurLcb) ld a,l add a,#0x54 ld c,a ld a,h adc a,#0x00 ld h, a ld l, c ld a,(hl) inc hl ld h,(hl) ld l,a push de push hl call _free pop af pop de 00132$: ;sips.c:2091: Sip_pCurLcb->pReqUri = heap_save_str(pBuf); ld hl,#0 add hl,sp ld a,l add a,#0x54 ld (hl),a ld a,h adc a,#0x00 inc hl ld (hl),a push de push de call _heap_save_str pop af ld b,h ld c,l pop de ld iy,#0 add iy,sp ld l,0 (iy) ld h,1 (iy) ld (hl),c inc hl ld (hl),b ;sips.c:2092: if (Sip_pCurLcb->pInvUri) free(Sip_pCurLcb->pInvUri); ld hl,(_Sip_pCurLcb) ld bc, #0x0052 add hl,bc ld c, l ld b, h ld l, c ld a,(hl) inc hl or a,(hl) jr Z,00134$ ld hl,(_Sip_pCurLcb) ld a,l add a,#0x52 ld c,a ld a,h adc a,#0x00 ld h, a ld l, c ld a,(hl) inc hl ld h,(hl) ld l,a push de push hl call _free pop af pop de 00134$: ;sips.c:2093: Sip_pCurLcb->pInvUri = heap_save_str(pBuf); ld hl,#0 add hl,sp ld a,l add a,#0x52 ld (hl),a ld a,h adc a,#0x00 inc hl ld (hl),a push de push de call _heap_save_str pop af ld b,h ld c,l pop de ld iy,#0 add iy,sp ld l,0 (iy) ld h,1 (iy) ld (hl),c inc hl ld (hl),b Correct related asm: ;sips.c:2090: if (Sip_pCurLcb->pReqUri) free(Sip_pCurLcb->pReqUri); ld hl,(_Sip_pCurLcb) ld bc, #0x0054 add hl,bc ld c, l ld b, h ld l, c ld a,(hl) inc hl or a,(hl) jr Z,00132$ ld hl,(_Sip_pCurLcb) ld a,l add a,#0x54 ld c,a ld a,h adc a,#0x00 ld h, a ld l, c ld a,(hl) inc hl ld h,(hl) ld l,a push hl call _free pop af 00132$: ;sips.c:2091: if (Sip_pCurLcb->pInvUri) free(Sip_pCurLcb->pInvUri); ld hl,(_Sip_pCurLcb) ld bc, #0x0052 add hl,bc ld c, l ld b, h ld l, c ld a,(hl) inc hl or a,(hl) jr Z,00134$ ld hl,(_Sip_pCurLcb) ld a,l add a,#0x52 ld c,a ld a,h adc a,#0x00 ld h, a ld l, c ld a,(hl) inc hl ld h,(hl) ld l,a push hl call _free pop af 00134$: ;sips.c:2092: Sip_pCurLcb->pReqUri = heap_save_str(pBuf); ld hl,(_Sip_pCurLcb) ld de, #0x0054 add hl, de ld e, l ld a,h ld d,a push de ld iy,#2 add iy,sp ld l,0 (iy) ld h,1 (iy) push hl call _heap_save_str pop af ld b,h ld c,l pop hl ld (hl),c inc hl ld (hl),b ;sips.c:2093: Sip_pCurLcb->pInvUri = heap_save_str(pBuf); ld hl,(_Sip_pCurLcb) ld de, #0x0052 add hl, de ld e, l ld a,h ld d,a ld hl,#0x0007 add hl,sp ld iy,#2 add iy,sp ld 0 (iy),l ld 1 (iy),h push de ld l,0 (iy) ld h,1 (iy) push hl call _heap_save_str pop af ld b,h ld c,l pop hl ld (hl),c inc hl ld (hl),b Woody http://palmmicro.com/woody/ ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Sdcc-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sdcc-user
