|
|
Atari coding BBS
Built in obsolescence DSP help |
Posted by: Laurent Sallafranque
|
Jan,14.2010-00:18
|
Hello,
I've got a stack overflow under hatari with the Built in Obsolescence demo (in the DSP code).
I don't understand why.
Ok, let's go for the explanations :
The beginning of the DSP code :
0000: jmp p:0x0040
...
0040: movec #0x00,sr
0041: movep #0x000000,x:0xfffe
0043: movep #0x000c00,x:0xffff
0045: movep #0x000001,x:0xffe0
0047: movep #0x000004,x:0xffe8
0049: andi #0x00,omr
004a: jmp p:0x004a
It just initialize DSP, starts interrupts (andi) and loops forever at address $4a
the interrupt code : (here is the problem)
001e: jmp p:0x004b
(Here, they use a JMP, so according to the Motorola doc, it's a short interrupt), is it correct ?
004b: movec ssl,x0
004c: movec x0,sr
004d: movec #0xffffff,m0
004f: movec sp,r0
0050: nop
0051: lua (r0)-,r0
0052: nop
0053: movec r0,sp
As SP=0 when we enter here for the first time, the lua gives a $ffff value and the last movec gives a $3c value (stack overflow).
I think they've included a bug, as the instruction at $1e should have been a JSR. (the opcode is 0af080 00004b : JMP $4b)
So, when the programs continues :
0054: jsr p:0x007d
007d: jclr #0,x:0xffe9,p:0x007d
And here, I get a second interrupt at $1e (but the first one hasn't finished yet)
001e: jmp p:0x004b
The code repeats and finishes by a Stack overflow,
...
0051: lua (r0)-,r0
Reg: r0: 0x0030 -> 0x002f
0052: nop
0053: movec r0,sp
Reg: sp: 0x30 -> 0x2f
Dsp: Stack Overflow
0054: jsr p:0x007d
0002: nop // Stack overflow vector
0003: nop // Stack overflow vector
007d: jclr #0,x:0xffe9,p:0x007d
007f: rts
0000: jmp p:0x0040
And because of the stack overflow, SP is lost, so is the return address, the DSP program restarts and loops forever at address $4a.
What's wrong here with hatari ?
The demo works on a real falcon, so I don't understand !
The problem seems to be the second interrupt that arrives too early (the first one hasn't finished), but this is a fast interrupt
In this case, the DSP adds the 2 instructions which are at the vector address in the prefetch list, and allows again the interrupts, no ?
Somebody can help me to understand here ?
Best regards,
Laurent
|
[All messages in this thread] [Start new thread]
What's the anti-troll code? That's your personal code to be able to add comments and messages on the dhs.nu site.
Don't have a code or forgot it? Fix it here.
|
|
|