print the maximal stack pointer value when pressing shift

This commit is contained in:
Mirko Scholz 2020-09-09 09:40:26 +02:00
parent 2a9801e676
commit a491ab0461
6 changed files with 30 additions and 2 deletions

View File

@ -4,7 +4,7 @@ SDCCOPTS ?= --code-size $(STCCODESIZE) --xram-size 256 --idata-loc 0x80
#SDCCOPTS ?= --code-size $(STCCODESIZE) --xram-size 256 --stack-auto --model-large
FLASHFILE ?= main.hex
LARGE_LDFLAGS += -L/usr/share/sdcc/lib/large/
# CFLAGS += -DSTACK_DEBUG # write the stack pointer to P3_4
# CFLAGS += -DSTACK_DEBUG -DSHOW_STACK # write the stack pointer to P3_4
SRC = src/lcd.c src/key.c src/utils.c src/decn/decn.c src/calc.c src/stack_debug.c

View File

@ -285,3 +285,15 @@ void LCD_Clear() {
col = 0;
}
void TERMIO_PrintU8(uint8_t x) {
uint8_t i;
for (i = 2; i; i--) {
const uint8_t upper_nibble = (x & 0xf0) >> 4;
if (upper_nibble <= 9) {
TERMIO_PutChar(upper_nibble + '0');
} else {
TERMIO_PutChar((upper_nibble - 0x0a) + 'A');
}
x <<= 4;
}
}

View File

@ -31,6 +31,7 @@ void LCD_GoTo(uint8_t row, uint8_t col);
void LCD_OutString(__xdata const char* string, uint8_t max_chars);
void LCD_OutString_Initial(__code const char* string);
short TERMIO_PutChar(unsigned char letter);
void TERMIO_PrintU8(uint8_t x);
void LCD_OutNibble(uint8_t x);
void LCD_ClearToEnd(uint8_t curr_row);

View File

@ -523,6 +523,10 @@ int main()
//print shifted status
if (IsShifted){
TERMIO_PutChar('^');
#if defined(STACK_DEBUG) && defined(SHOW_STACK)
TERMIO_PutChar(' ');
TERMIO_PrintU8(stack_max);
#endif
}
#ifdef DESKTOP

View File

@ -84,8 +84,15 @@ stack_debug_3$:
__endasm;
}
#if defined(STACK_DEBUG) && defined(SHOW_STACK)
__xdata uint8_t stack_max = 0x00;
#endif
void stack_debug(uint8_t marker) {
#ifdef SHOW_STACK
if (SP > stack_max) stack_max = SP;
#endif
stack_debug_write(marker);
stack_debug_write(SP);
}
#endif // !defined(DESKTOP)
#endif // defined(STACK_DEBUG)

View File

@ -35,6 +35,10 @@ void stack_debug_write(uint8_t value) __naked;
#define stack_debug(marker)
#endif
#if defined(STACK_DEBUG) && defined(SHOW_STACK)
extern __xdata uint8_t stack_max;
#endif
#if defined(DESKTOP) || defined(STACK_DEBUG)
#define backlight_on()
#define backlight_off()