Bugs item #1230165, was opened at 2005-06-30 06:43
Message generated for change (Comment added) made by frief
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1230165&group_id=599
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: msc51(8051) target
Group: non bugs
Status: Closed
Resolution: Rejected
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: PSW register does not get saved in interrupt routines.
Initial Comment:
c:> sdcc klaum1 // compile instructions sdcc version
2.50
; 8051 Disassembly of klaum1.hex compiled with
SDCC ver 2.5.0
org 0
X0000: ljmp X005c ; 0000 02
00 5c ; reset
reti ; 0003
32
org 0bh
ljmp X0013 ; 000b 02
00 13 ; timer 0 isr end
X000e: lcall X003a ; 000e 12
00 3a
X0011: sjmp X0011 ; 0011 80
fe
X0013: push acc ; 0013 c0
e0 ; save acc
mov a,rb1r0 ; 0015 e5
08
jz X001b ; 0017 60
02
sjmp X002a ; 0019 80
0f
X001b: mov rb1r0,#1 ; 001b 75 08 01
clr p1.0 ; 001e c2
90
mov th0,#0fah ; 0020 75 8c fa
mov tl0,#0f5h ; 0023 75 8a f5
clr tf0 ; 0026 c2
8d
sjmp X0037 ; 0028 80
0d
X002a: mov rb1r0,#0 ; 002a 75 08 00
setb p1.0 ; 002d d2
90
mov th0,#0c3h ; 002f 75 8c c3
mov tl0,#94h ; 0032 75 8a 94
clr tf0 ; 0035 c2
8d
X0037: pop acc ; 0037 d0
e0 ; restore acc
reti ; 0039 32
; timer 0 isr end
X003a: setb ea ; 003a d2
af
setb et0 ; 003c d2
a9
clr tr0 ; 003e c2
8c
clr tf0 ; 0040 c2
8d
anl tmod,#0f0h ; 0042 53
89 f0
orl tmod,#1 ; 0045 43
89 01
mov th0,#0c3h ; 0048 75 8c c3
mov tl0,#94h ; 004b 75 8a 94
mov rb1r0,#1 ; 004e 75 08 01
clr p1.0 ; 0051 c2
90
setb tr0 ; 0053 d2
8c
X0055: sjmp X0055 ; 0055 80
fe
ret ; 0057
22
X0058: mov dpl,#0 ; 0058 75
82 00
ret ; 005b
22
X005c: mov sp,#8 ; 005c 75
81 08 start of main program
lcall X0058 ; 005f 12
00 58
mov a,dpl ; 0062 e5
82
jz X0069 ; 0064 60
03
ljmp X000e ; 0066 02
00 0e
X0069: mov r1,#0 ; 0069 79
00
mov a,r1 ; 006b
e9
orl a,#0 ; 006c 44
00
jz X008b ; 006e 60
1b
mov r2,#0 ; 0070 7a
00
mov dptr,#X00b8 ; 0072 90
00 b8
mov r0,#0 ; 0075 78
00
mov p2,#0 ; 0077 75
a0 00
X007a: clr a ; 007a
e4
movc a,@a+dptr ; 007b 93
movx @r0,a ; 007c
f2
inc dptr ; 007d
a3
inc r0 ; 007e
08
cjne r0,#0,X0084 ; 007f b8
00 02
inc p2 ; 0082 05
a0
X0084: djnz r1,X007a ; 0084 d9 f4
djnz r2,X007a ; 0086 da f2
mov p2,#0ffh ; 0088 75 a0 ff
X008b: clr a ; 008b
e4
mov r0,#0ffh ; 008c 78 ff
X008e: mov @r0,a ; 008e
f6
djnz r0,X008e ; 008f d8 fd
mov r0,#0 ; 0091 78
00
mov a,r0 ; 0093
e8
orl a,#0 ; 0094 44
00
jz X00a2 ; 0096 60
0a
mov r1,#0 ; 0098 79
00
mov p2,#0 ; 009a 75
a0 00
clr a ; 009d
e4
X009e: movx @r1,a ; 009e
f3
inc r1 ; 009f
09
djnz r0,X009e ; 00a0 d8 fc
X00a2: mov r0,#0 ; 00a2 78
00
mov a,r0 ; 00a4
e8
orl a,#0 ; 00a5 44
00
jz X00b5 ; 00a7 60
0c
mov r1,#0 ; 00a9 79
00
mov dptr,#X0000 ; 00ab 90
00 00
clr a ; 00ae
e4
X00af: movx @dptr,a ; 00af
f0
inc dptr ; 00b0
a3
djnz r0,X00af ; 00b1 d8 fc
djnz r1,X00af ; 00b3 d9 fa
X00b5: ljmp X000e ; 00b5 02
00 0e
X00b8 equ 0b8h
end
----------------------------------------------------------------------
>Comment By: Frieder Ferlemann (frief)
Date: 2005-06-30 10:05
Message:
Logged In: YES
user_id=589052
Hi Maarten, sorry for the inconvenience caused. My fault!
----------------------------------------------------------------------
Comment By: Maarten Brock (maartenbrock)
Date: 2005-06-30 08:16
Message:
Logged In: YES
user_id=888171
Frieder, Adam?
I assume this is about the code from address 0013 to 0039.
Why are you so anxious to see PSW pushed and popped? I
see no instruction that modifies any flag in PSW nor any
instruction that needs a modified PSW. Remember Z is not a
flag in PSW, it's not even a real flag. Z is a combinatorial
combination of the bits in A.
And back to the original problem... You should not use F0 for
storage inside or outside an interrupt. Any using statement
will overwrite it for instance. And maybe this time PSW
wasn't needed, but a small change in your code might need it
and then PSW will be pushed and popped. In short just use a
static char or bit variable, just as this version of the code
already does. (rb1r0 is not r0 in register bank 1, but a normal
global or static char.)
Maarten
----------------------------------------------------------------------
Comment By: Frieder Ferlemann (frief)
Date: 2005-06-30 07:06
Message:
Logged In: YES
user_id=589052
This bug report was triggered by the thread "General Pulse
Width Modulation on 8051" on http://www.8052.com.
http://www.8052.com/forum/read.phtml?id=95926
The original source provided there doesn't trigger the
problem. Charles (?) could you provide more information?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1230165&group_id=599
|