#751 Interrupt overwrites r2 from Registerpage 0

closed-fixed
5
2013-05-25
2004-05-11
Anonymous
No

This Programm use Registerpage 1 for interrupts.
The Registerpage is set to 0 before a call to
small/_moduint.asm is done fromout the interrupt.

Then moduint overwrites R2.

The compiler is SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.4.0 (May 11 2004) (UNIX)

----test.c----
volatile unsigned int test=12345;

main()
{
char c=123;

while(c)c++; //use r2
return 0;
}

void ser_handler (void) interrupt 4 using 1
{
test=test%5;
}
--------------

gives this

---test.asm-----
.
.
.

; function ser_handler
; -----------------------------------------
_ser_handler:
ar2 = 0x0a
ar3 = 0x0b
ar4 = 0x0c
ar5 = 0x0d
ar6 = 0x0e
ar7 = 0x0f
ar0 = 0x08
ar1 = 0x09
push acc
push b
push dpl
push dph
push psw
mov psw,#0x08
;test.c:10: test=test%5;
; genAssign
clr a
mov (__moduint_PARM_2 + 1),a
mov __moduint_PARM_2,#0x05
; genCall
mov dpl,_test
mov dph,(_test + 1)

mov psw,#0x00

---Here is the call (page0), R2 is never saved.

lcall __moduint
mov psw,#0x08
mov _test,dpl
mov (_test + 1),dph
00101$:
pop psw
pop dph
pop dpl
pop b
pop acc
reti
.area CSEG (CODE)
.area XI
.
.
.

------------------------

-----small/_moduint.asm------
.
.
.

; # 105 "_moduint.c"
mov a,(__moduint_PARM_2) ; avoid
endless loop
orl a,(__moduint_PARM_2 + 1)
jz div_by_0
mov r2,#1
loop1:
mov a,(__moduint_PARM_2) ; b <<= 1
.
.
.

-------------------

Discussion

  • Erik Petrich

    Erik Petrich - 2004-05-19

    Logged In: YES
    user_id=635249

    Fixed in src/SDCCopt.c 1.48

     
  • Erik Petrich

    Erik Petrich - 2004-05-19
    • milestone: --> fixed
    • assigned_to: nobody --> epetrich
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks