Re: A82: ASH Routine
[Prev][Next][Index][Thread]
Re: A82: ASH Routine
At 04:17 PM 4/10/98 -0700, you wrote:
>> I need an ASH routine that will exit to ASH no matter how deep in
>>subroutines I am. I know I can inc the sp register that many times and
>>then ret but this routine may be called from many different points in my
>>program and I won't know how many subroutines I will be in when it is
>>called.
>
>This works in CrASH too BTW. This uses self-modifying code - if you
>don't understand it, don't worry about it.
>
>At very beginning of program:
>
>ld hl,0
>add hl,sp
>ld (SAVED_SP+1),hl
>
>...
>
>Then later:
>
>EXIT_2_CRASH:
>SAVED_SP:
>ld sp,0
>ret
>
>
>To return to CrASH, do jp EXIT_2_CRASH
This won't work for OShell-82/OS-82 unless you use PROGRAM_ADDR. Here is a
modified routine using PROGRAM_ADDR:
At very beginning of program:
ld hl,0
add hl,sp
ld ix,SAVED_SP+1
ld de,(PROGRAM_ADDR)
add ix,de
ld (ix),l
ld (ix+1),h
...
Then later:
EXIT_2_OSHELL:
SAVED_SP:
ld sp,0
ret
To return to OShell-82/OS-82, do JUMP_(EXIT_2_OSHELL)
This is VERY unoptimized, but it does the same job if you want to port,
using this method, to OS-82.
Thomas J. Hruska -- thruska@tir.com
Shining Light Productions -- "Meeting the needs of fellow programmers"
http://www.geocities.com/SiliconValley/Heights/8504
http://shinelight.home.ml.org
Follow-Ups:
References: