Re: A86: Program flow


[Prev][Next][Index][Thread]

Re: A86: Program flow




Bowser797@aol.com wrote:
>  ......
> 
> keyloop
>   some code for getting a string
> 
> How do I return from the key loop to where I left off in the code?  Does the
> ret function do this, or that only to quit to the TI-OS?  I will need to call
> the getstring function from many different places in my program, so I can't
> just use a jump.  This is probably an easy question, so I hope I'm not making

  Use a call instead of a jp.
  Then, at the end of keyloop put a ret. A call puts in the stack (push)
  the address of the instrution right after the call and jumps to the
address
  indicated as a parameter tothe call. A ret gets (pop) a value from the
  stack and jumps to it.
  So, as an example, the sequence:

     ld    a, 1
     call  ld_a_0
     ld    b, 1
     ...
   ld_a_0:
     ld    a, 0
     ret

  actually executes as if it where:

     ld    a, 1
     ld    a, 0
     ld    b, 1
     ...

  Any question?

  NSJ aka Viriato
  l41324@alfa.ist.utl.pt
  nmasj@camoes.rnl.ist.utl.pt
  http://camoes.rnl.ist.utl.pt/~nmasj - DemoAdict/TaradoPorDemos


References: