I have been trying to modify the ICE program-launching source code to allow it to execute another program after the execution of the one it called is complete. The only problem is I am really bad overall at ASM. It launches the program correctly, but when the program it launched completes I get the following error
I'm not sure what I'm doing wrong, because, again, I still don't completely understand ASM.
Here is the source code (and I apologize for my badly-formatted, probably redundant code):
Code:
Quote:
NMI reset caused by writing to the stack limit at address 0xd19881. Hint: Probably a stack overflow (aka too much recursion).
I'm not sure what I'm doing wrong, because, again, I still don't completely understand ASM.
Here is the source code (and I apologize for my badly-formatted, probably redundant code):
Code:
public _RunPrgm
extern __exitsp
_RunPrgm:
call 0021A3Ch ; _DrawStatusBar
ld de, 0D09466h ; plotSScreen
ld hl, StartRunProgram
ld bc, EndRunProgram - StartRunProgram
ldir
jp 0D09466h ; plotSScreen
StartRunProgram:
; Copy the name to OP1
pop hl
pop hl ; HL points to the program name
ld de, 0D005F9h ; OP1 + 1
push de
ld bc, 8
ldir
pop hl
dec hl
ld (hl), 5 ; ProgObj
; Cleanup C things
ld sp, (__exitsp + 1);
pop iy
pop af
ex (sp), hl
ld (hl), a
call 00004F0h ; usb_ResetTimers
pop hl
; Remove CESH from UserMem
ld hl, 0D1A881h ; userMem
ld de, (0D0118Ch) ; asm_prgm_size
call 0020590h ; _DelMem
; Copy the new program to UserMem and jump to it
call 002050Ch ; _ChkFindSym
ex de, hl
call 0021D9Ch ; _LoadDEInd_s
inc hl
inc hl
push hl
push de
ex de, hl
call 002072Ch ; _ErrNotEnoughMem
pop hl
ld (0D0118Ch), hl ; asm_prgm_size
ld de, 0D1A881h ; userMem
push de
call 0020514h ; _InsertMem
pop de
pop hl
ld bc, (0D0118Ch) ; asm_prgm_size
add hl, bc
ldir
ld hl, RunShell
ld bc, EndRunShell - RunShell
ldir
; And finally run the program!
jp 0D1A881h ; userMem
EndRunProgram:
RunShell:
call 0021A3Ch ; _DrawStatusBar
ld de, 0D09466h ; plotSScreen
ld hl, StartRunShell
ld bc, EndRunShell - StartRunShell
ldir
ld hl, de
dec hl
dec hl
dec hl
dec hl
dec hl
jp 0D09466h ; plotSScreen
StartRunShell:
; Copy the name to OP1
ld de, 0D005F9h ; OP1 + 1
push de
ld bc, 8
ldir
pop hl
dec hl
ld (hl), 5 ; ProgObj
; Remove current program from UserMem
ld hl, 0D1A881h ; userMem
ld de, (0D0118Ch) ; asm_prgm_size
call 0020590h ; _DelMem
; Copy the shell to UserMem and jump to it
call 002050Ch ; _ChkFindSym
ex de, hl
call 0021D9Ch ; _LoadDEInd_s
inc hl
inc hl
push hl
push de
ex de, hl
call 002072Ch ; _ErrNotEnoughMem
pop hl
ld (0D0118Ch), hl ; asm_prgm_size
ld de, 0D1A881h ; userMem
push de
call 0020514h ; _InsertMem
pop de
pop hl
ld bc, (0D0118Ch) ; asm_prgm_size
add hl, bc
ldir
; And finally run the shell!
jp 0D1A881h ; userMem
db "CESH",0,0,0,0
EndRunShell: