ICALL stack underflow bug still present in Studio 4.12 SP4

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I saw the earlier forum posts regarding this bug, but I would like to confirm that it is still present in AVR Studio 4.12 SP4 build 498.

Here is asm code that generates the bug, when simulated in AVR Studio:

; Includes
.include "m128def.inc"

; Reset vector
rjmp MAIN

FUNCTION:
ret

; Main function loop
MAIN:
; Initialise stack pointer to end of RAM
ldi R16,low(RAMEND)
out SPL,R16
ldi R16,high(RAMEND)
out SPH,R16

; Initialise Z
ldi ZL,low(FUNCTION)
ldi ZH,high(FUNCTION)

icall

LOOP:
rjmp LOOP

This bug actually crops up when using the stream routines, e.g. printf, putchar,..., because the FILE structure contains a function pointer to the "putchar(...)" function. Here is C code that demonstrates the bug when simulated in AVR Studio:

#include

int PRINTF_iPutChar(char cData, FILE* pxStream);

static FILE PRINTF_xStream = FDEV_SETUP_STREAM(PRINTF_iPutChar,NULL,_FDEV_SETUP_WRITE);

int PRINTF_iPutChar(char cData, FILE* pxStream)
{
return 0;
}

int main(void)
{
stdout = &PRINTF_xStream;

putchar('A');

printf('B');
}

What is the ETA on Service Pack 5?

Regards,
Pieter
http://piconomic.co.za

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What is the ETA on Service Pack 5?

But this stack underflow thing is just a spurious warning isn't it? It doesn't actually affect the operation of the simulation apart from being "annoying". Obviously it must eventually be fixed but I doubt it'd be the sole justification for a release of SP5.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
It doesn't actually affect the operation of the simulation apart from being "annoying".

As far as I remember (I have gone back to an earlier version now, so I can't verify this now), it breaks the simulation every time it happens. If this happens to be somewhere in the code that is frequently accessed, then it goes from being just annoying to a royal pain in the rear part. I once had to go through several hundreds of these warnings before I finally arrived at the breakpoint I needed.