Re: A83: calls


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

Re: A83: calls




Sorry, but Olle and I are right. Look at it from the z80's point of view:

9327: call 932ah
932a: call 932dh
932d: ret

Log of events:

PC    Stack                      Instruction
9327  {Return to OS}             call 932ah
      {Return to OS, 932a}       (= first push pc+3 as a new return
address...)
                                 (...and then jump)
932a  {Return to OS, 932a}       call 932dh
      {Return to OS, 932a, 932d} (= first push pc+3 as a new return
address...)
                                 (...and then jump)
932d  {Return to OS, 932a, 932d} ret (= pop pc)
932d  {Return to OS, 932a}
             but here we find a: ret (= pop pc)
932a  {Return to OS}             call 932dh
      {Return to OS, 932d}       (= first push pc+3 as a new return
address...)
                                 (...and then jump)
932d  {Return to OS, 932d}       ret (= pop pc)
932d  {Return to OS}             ret (= pop pc)
Back in TI-OS

It's right that the second time the ret is invoked, the z80 jumps back and
executes a call instruction, but as you can see, the third time it is invoked
it just jumps back to the ret immediately. Thus, there is no loop.

Linus


On 26-Sep-98, Jkhum98@aol.com wrote:


>In a message dated 09/26/98 1:29:08 PM, oh@hem.passagen.se writes:

>>Its not gonna be a loop because after he calles third label, he rets
>>back to after the call to label and then rets out of the program...
>>
>>go through it again and I'm sure you will find that I am right :)
>>
>>//Olle

>Hmm, nope. I see that it will pass through the _Label_ "third_label" and
carry
>out another "ret", but Go one step further, and after returning from the very
>First call, it will then pass through the _Label_ "second_label" and once
>again does "call third label". Find, in my lil diagram, the words "(second
>return spot)" and then you'll see the little arrow that points down, and from
>there That is why a loop is created... 

>--Jason K.
>>>      first_label:
>>>        call second_label
>>> |-->    (second return spot)
>>> |                |
>>> |               V
>>> |     second_label:
>>> |       call third_label   -|
>>> |  |--->(first return spot)   |
>>> |  |             |                         |
>>> |  |            V                      |
>>> |  |  third_label:       <------|
>>> |  |----ret(first time)
>>> |------  (second time)



Follow-Ups: References: