View Single Post
Old 12 December 2015, 16:41   #1
sodapop
Registered User
 
sodapop's Avatar
 
Join Date: Oct 2010
Location: France
Posts: 99
movem.l d0-d7/a0-a6,-(SP) inside a subroutine ?

Hi !

Could someone with a better knowledge than mine explain me why a "movem.l d0-d7/a0-a6,-(SP)" inside my SAVE_ALL subroutine will cause a guru, whereas it will work ok when outside the subroutine (put in between "bsr SAVE_ALL" and "bsr InitMusic"). BTW, don't pay any attention at my code pertinency (only for testing purposes !)
Thank you !

Code:
    move.l $4,a6
    lea gfxname,a1
    jsr -408(a6)
    move.l d0,a1

    bsr SAVE_ALL
    bsr InitMusic
    bsr RESTORE_ALL
    rts

InitMusic:
    move.w #%1000001000001111,$dff096    ; DMA Sound
    bsr mt_init
VBL:    
    move.l    $dff004,d7
    and.l    #$1ff00,d7
    cmp.l    #303<<8,d7
    bne.s    VBL
    bsr mt_music
    btst #6,$bfe001
    bne.s VBL
    bsr mt_end    
    rts

SAVE_ALL:
    move.l $26(a1),old_COP1        ; save old copperlist 1
    move.l $32(a1),old_COP2        ; save old copperlist 2
    jsr -414(a6)            ; close lib

    move.w $DFF01c,old_IRQ        ; Save IRQ enable flags
    move.w $DFF002,old_DMA        ; Save DMACON register

    move.w #%0111111111111111,$DFF09a    ; Disable IRQs
    move.w #%0111111111111111,$DFF096    ; Disable DMAs
    movem.l d0-d7/a0-a6,-(SP)
    rts
    
RESTORE_ALL:
    move.l old_COP1,$DFF080        ; restore copperlist 1
    move.l old_COP2,$DFF084        ; restore copperlist 2
    move.w old_DMA,d0        ; restore dma control register
    ori.w #$8000,d0            ; Set high bit to enable 'set'
    move.w d0,$DFF096        ; Re-enable DMAs

    move.w old_IRQ,d0        ; Restore IRQ enabled register
    ori.w #$8000,d0
    move.w d0,$DFF09a        ; Re-enable IRQs
    movem.l (SP)+,d0-d7/a0-a6
    rts

gfxname:
    dc.b "graphics.library",0
    even

old_COP1: ds.l 1
old_COP2: ds.l 1
old_IRQ: ds.w 1
old_DMA: ds.w 1

Last edited by sodapop; 12 December 2015 at 16:47.
sodapop is offline  
 
Page generated in 0.04333 seconds with 10 queries