Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#419 Incorrect buffer address passed to funct

closed-fixed
Erik Petrich
z80 port (188)
7
2013-05-25
2002-12-07
Anonymous
No

The following code fragment produces the attached file
listing. The pointer passed to the 'xmit' function
points to the last character to the buffer 'xmitBuff'.
The HL gregister is loaded in line 198 and modified in
line 199. The data is moved with lines 202-204. In
line 208 the BC register has the correct value to be
pushed on to the stack. The next push at line 210, the
HL register contains the incorrect address. The HL
register should be reset to '#_xmitBuff'. The command
for the compiler is 'sdcc -mz80 -c badpgm.c'.

#define STX 0x02
#define ETX 0x03
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#define NAK 0x15
#define FS 0x1c

void transmit(char *, int);
void xmit(char *, int);

static int xmitState;
static char xmitBuff[514];

void transmit(char *buf, int inCnt)
{
int i, outCnt, lrc;

outCnt = 0; /* setup
buffer counter */
lrc = 0; /* setup lrc
register */
xmitBuff[outCnt++] = STX; /* store start
of text */

for(i = 0; i < inCnt; i++) /* loop
through data buffer */
{
xmitBuff[outCnt++] = buf[i]; /* save data to
packet buffer */
lrc ^= buf[i]; /* perform lrc
checksum */
}

xmitBuff[outCnt++] = ETX; /* store end
of text */
lrc ^= ETX; /* perform lrc
checksum */
xmitBuff[outCnt++] = lrc; /* store lrc
to packet buffer */
xmit(xmitBuff, outCnt); /* send packet */
}

void xmit(char *buf, int count)
{
;
}

My e-mail address is poppleglenn@rogers.com.

Discussion

  • Assembler list output

     
    Attachments
  • Johan Knol
    Johan Knol
    2003-01-15

    • priority: 5 --> 7
     
  • Johan Knol
    Johan Knol
    2003-01-25

    • assigned_to: nobody --> michaelh
     
  • Erik Petrich
    Erik Petrich
    2003-10-02

    • status: open --> closed
     
  • Erik Petrich
    Erik Petrich
    2003-10-02

    • milestone: --> fixed
    • assigned_to: michaelh --> epetrich
    • status: closed --> closed-fixed
     
  • Erik Petrich
    Erik Petrich
    2003-10-02

    Logged In: YES
    user_id=635249

    Recently fixed in src/z80/gen.c 1.117