Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: fb39ca4 on January 08, 2014, 10:14:43 pm
-
I was trying to figure out why the calculator kept on freezing after Bad Apple finished, and it turns out iff1 and iff2 were disabled. I enable interrupts and set the interrupt mode to 1 immediately before doing bjump(_JForceCmdNoChar). iff1 and iff2 are enabled when that happens, but sometime after the bjump, the interrupts get disabled. What is going on here?
-
You probably need to set interrupt mode to 1, THEN enable interrupts again, not the other way around.
You also need to disable the crystal timers. The OS interrupts requires one of them, I think. Also, did you reset the normal interrupts?
NOTE: This post was edited too many times shortly after the initial post. I really need to collect my thoughts better.
-
I am already doing im 1 first and then ei. The crystal timers are disabled by writing 0 to ports $30-$38, and the regular interrupts are restored by writing $0B to port $03.
-
Posting the relevant parts of the code may help. Also, posting how you set up the interrupt may also be helpful.
-
This code will fix the interrupts. If it crashes after this, interrupts are not the issue. Also, you don't need to enable interrupts when you quit, the OS takes care of that for you.
di
im 1
ld a, $0B
out (03), a
xor a
out ($31), a
out ($34), a
out ($37), a
-
Setting up the interrupts:
;set up interrupt vector table from $9900 to $9A00 to always go to $9A9A
ld hl, $9900
ld b, 0
ld d, $9A
IvtLoop:
ld (hl), d
inc hl
djnz IvtLoop
ld (hl), d
;disable all other interrupts
ld a, %01000
out ($03), a
ld a, $99
ld i, a
im 2
ei
Cleanup:
di
;turn off timers
ld a, 0
out ($30), a
out ($31), a
out ($32), a
out ($33), a
out ($34), a
out ($35), a
out ($36), a
out ($37), a
out ($38), a
;restore regular interrupts
ld a, 0
out ($03), a
ld a, $0B
out ($03), a
;set LCD to row auto increment
ld a, $05
call LCD_BUSY_QUICK
out ($10), a
;set CPU to 6MHz
ld a, 0
out ($20), a
;statVars was used to store code, so it needs to be invalidated
b_call _DelRes
;enable auto power down
set apdAble,(IY+apdFlags)
im 1
ei
bjump(_JForceCmdNoChar)
EDIT: Tried thepenguin77's code, and it looks like interrupts are not the problem.
-
Are you doing any RAM page swapping or stack pointer manipulation?