English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 26 November 2021, 19:15   #1
sq7bti
Registered User
 
Join Date: May 2019
Location: Eindhoven
Posts: 12
Interrupt code with gcc-2.95.3 vs gcc-6.5.0b

Does gnu-gcc-6.5.0b (bebbo) require different handling of ISR than it used to be with gcc-2.95.3 (cahirwpz)?
I am attempting to port a very simple tool that works OK (perhaps by chance) when compiled with 2.95.3, but crashes as soon as the isr is called. If that matter, compiler/linker options includes fbaserel, and isr has an attribute __saveds.
sq7bti is offline  
Old 27 November 2021, 01:18   #2
Samurai_Crow
Total Chaos forever!
 
Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
The packager on both GCCs allow for the use of the SDI headers. Try using the SDI compiler header's macro definition for SAVEDS in place of the old GCC's __saveds and you can try different Amiga compilers almost at will.
Samurai_Crow is offline  
Old 27 November 2021, 18:18   #3
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
Quote:
Originally Posted by Samurai_Crow View Post
The packager on both GCCs allow for the use of the SDI headers. Try using the SDI compiler header's macro definition for SAVEDS in place of the old GCC's __saveds and you can try different Amiga compilers almost at will.

AFAIK the meanings did not change.



You must not use __interrupt for the Amiga software interrupts. Why? Because __interrupt means the function uses rte to exit instead of rts.


__saveds still means that together with -fbaserel (and friends) the a4 register gets initialized.
bebbo is offline  
Old 27 November 2021, 19:32   #4
sq7bti
Registered User
 
Join Date: May 2019
Location: Eindhoven
Posts: 12
Quote:
Originally Posted by bebbo
You must not use __interrupt for the Amiga software interrupts. Why? Because __interrupt means the function uses rte to exit instead of rts.

Once the handler has finished its business, it must return to Exec by executing an RTS (return from subroutine) instruction rather than an RTE (return from exception) instruction.


Regardless of __interrupt attribute 2.95.3 compiles with RTS at the ISR exit. There is more differences but this is the interesting part:
Code:
 /* Interrupt service routine. */
-__interrupt __saveds void pca9564_isr(pca9564_state_t *sp __asm("a1"))
+__saveds void pca9564_isr(pca9564_state_t *sp __asm("a1"))
 {
      fbe:      4e55 ffe8       link.w a5,#-24
      fc2:      48e7 202a       movem.l d2/a2/a4/a6,-(sp)
@@ -2177,2112 +2177,2109 @@
 }
     159e:      4ced 5404 ffd8  movem.l -40(a5),d2/a2/a4/a6
     15a4:      4e5d            unlk a5
-    15a6:      4a80            tst.l d0
-    15a8:      4e75            rts
-    15aa:      0000            Address 0x00000000000015ac is out of bounds.
-.short 0x0000
+    15a6:      4e75            rts
6.5.0b does the job correctly though. This time the whole "diff":

Code:
--- i2cset.6.5._interrupt.s     2021-11-27 18:55:47.575086289 +0100
+++ i2cset.6.5.s        2021-11-27 19:04:38.441899656 +0100
@@ -1595,10 +1595,10 @@
 00000f22 00000f22 <pca9564_isr>:
 
 /* Interrupt service routine. */
-__saveds __interrupt void pca9564_isr(pca9564_state_t *sp __asm("a1"))
+__saveds void pca9564_isr(pca9564_state_t *sp __asm("a1"))
 {
      f22:      4e55 ffc8       link.w a5,#-56
-     f26:      48e7 ffea       movem.l d0-a2/a4/a6,-(sp)
+     f26:      48e7 3f2a       movem.l d2-d7/a2/a4/a6,-(sp)
      f2a:      4eb9 0000 00d0  jsr d0 d0 <__restore_a4>        f2c: RELOC32    .text
      f30:      2b49 ffca       move.l a1,-54(a5)
        UBYTE v;
@@ -2202,9 +2202,9 @@
     1546:      4268 0028       clr.w 40(a0)
 #endif /* DEBUG */
 }
-    154a:      4ced 57ff ff94  movem.l -108(a5),d0-a2/a4/a6
+    154a:      4ced 54fc ffa4  movem.l -92(a5),d2-d7/a2/a4/a6
     1550:      4e5d            unlk a5
-    1552:      4e73            rte
+    1552:      4e75            rts
 
 00001554 00001554 <__nocommandline>:
     1554:      4e55 ff80       link.w a5,#-128
Quote:
Originally Posted by bebbo
__saveds still means that together with -fbaserel (and friends) the a4 register gets initialized.

Thanks Bebbo and Samurai! Both compilers are now producing working code!
sq7bti is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga GCC 8.3+gdb extension for Visual Studio Code Bartman Coders. C/C++ 117 11 March 2023 20:06
MUI and GCC >3 ciVic Coders. System 4 30 December 2022 09:13
gcc and NDK3.2 alancfrancis Coders. C/C++ 2 17 August 2021 14:36
gcc linker mritter0 Coders. C/C++ 3 21 December 2014 16:54
GCC and GCCFindHit tygre Coders. Language 2 20 February 2012 16:45

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 16:21.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09143 seconds with 15 queries