/* This program (s51cell.c) just increments a counter
in
each tick interruption. The following sequence
produces
a memory fault with the CVS version of s51:
$ sdcc s51cell.c
$ s51 s51cell.ihx
uCsim 0.4.1-pre5, Copyright (C) 1997 Daniel Drotos,
Talker Bt.
uCsim comes with ABSOLUTELY NO WARRANTY; for details
type `show w'.
This is free software, and you are welcome to
redistribute it
under certain conditions; type `show c' for details.
193 words read from s51cell.ihx
0> b 0xb
Breakpoint 1 at 0x00000b: LJMP 0038
0> r
Simulation started, PC=0x000000
Stop at 0x00000b: (104) Breakpoint
0x00 00 00 00 00 00 00 00 00 ........
000000 00 . ACC= 0x00 0 . B= 0x00 DPTR= 0x0000
@DPTR= 0x00 0 .
000000 00 . PSW= 0x00 CY=0 AC=0 OV=0 P=0
F? 0x000b 02 00 38 LJMP 0038
F 0x00000b
0> s
0x00 00 00 00 00 00 00 00 00 ........
000000 00 . ACC= 0x00 0 . B= 0x00 DPTR= 0x0000
@DPTR= 0x00 0 .
000000 00 . PSW= 0x00 CY=0 AC=0 OV=0 P=0
? 0x0038 c0 e0 PUSH ACC
0> b s w 0x88
0> r
Simulation started, PC=0x000038
Memory fault (core dumped)
*/
sbit at 0xAF EA; /* Enable/Disable all interrupts */
sfr at 0x8C TH0; /* T0 counter high byte */
sfr at 0x8A TL0; /* T0 counter low byte */
sfr at 0x89 TMOD; /* Timer mode */
sbit at 0xA9 ET0; /* Enable/Disable timer 0
interruption */
sbit at 0xB9 PT0; /* Priority of timer 0 interruption
*/
sbit at 0x88 IT0; /* Trigger condition */
sbit at 0x8C TR0; /* Enable/Disable timer */
long c=0;
void tickISR() interrupt 1 _naked {
_asm
ar2 = 0x02
ar3 = 0x03
ar4 = 0x04
ar5 = 0x05
ar6 = 0x06
ar7 = 0x07
ar0 = 0x00
ar1 = 0x01
push acc
push b
push dpl
push dph
push ar0
push ar1
push ar2
push ar3
push ar4
push ar5
push ar6
push ar7
push psw
mov psw,#0x00
_endasm;
c++;
_asm
pop psw
pop ar7
pop ar6
pop ar5
pop ar4
pop ar3
pop ar2
pop ar1
pop ar0
pop dph
pop dpl
pop b
pop acc
reti
_endasm;
}
void main() {
EA=0; /* Disable all interruptions */
TH0=0x00; /* Initial count */
TL0=0x00;
TMOD=0x01; /* Mode 16 bits. */
ET0=1; /* Enable t0 overflow interruption */
PT0=1; /* High Priority */
IT0=0; /* Low level triggered */
TR0=1; /* Enable timer */
EA=1; /* Enable interruptions */
label:
goto label;
}
Logged In: YES
user_id=30977
s51 also often dies if you try to set a breakpoint at
location 0.
Even when it doesn't die, it won't stop there when you hit run
immediately after reset.
Logged In: YES
user_id=1438374
I had also s51 simulator memory fault when starting after
setting breakpoints. It was caused by a non-initialized
variable in s51. The patch for sdcc-2.5.0 / uCsim 0.5.4 is
very simple and is listed below.
*** sdcc.orig/sim/ucsim/sim.src/mem.cc 2004-07-27
15:42:52.000000000 +0200
--- sdcc/sim/ucsim/sim.src/mem.cc 2006-01-25
15:31:33.000000000 +0100
***************
*** 430,435 ****
--- 430,436 ----
flags= CELL_NON_DECODED;
width= 8;
*data= 0;
+ operators= 0;
#ifdef STATISTIC
nuof_writes= nuof_reads= 0;
Logged In: YES
user_id=568035
The uninitialized variable problem was solved 5.11.2005 in
sdcc version 1147.
Vladimir and bronson, can you please verify if the problem
is solved?
Borut
Logged In: YES
user_id=888171
Borut,
I followed the above sequence and got no memory fault. The
line "b s w 0x88" was not recognized, but "b sfr w 0x88"
was. Unfortunately I know close to nothing about the
simulator.
But the OP also filed a patch (756476) to fix this bug 3
months after the bug report ! And it took us developers
almost 3 years to implement? I feel ashamed.
I hope we can close this one soon.
Maarten
Logged In: YES
user_id=1312539
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 30 days (the time period specified by
the administrator of this Tracker).