[hatari-devel] Re: BM407 + symbols

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]



When looking at the generated caller information for that symbol:

callee: caller: calls: calltype:
  |       |       |   /
0x379:  0x155 = 144 r, 0x283 = 112 b, 0x2ef = 112 b, 0x378 = 72 s
583236/359708265/1631189180 72/4419020/19123430, end_addwall
           |                       |                 |
inclusive costs              exclusive costs     callee name
      (for calls from 0x378 address)

Calltypes:
- b: jump/branch
- n: PC  just moved to next address
- r: subroutine return
- s: subroutine call

It claims that most "calls" to "end_addwall" were subroutine call
returns (=r) to it from address 0x155.  Which is true as previous
instruction at 0x378 was subroutine call, and return from that
call returns to 0x379:

I don't think that is correct. 'end_addwall' is not a subroutine for anything. It is part of a flat chain, where pieces of the chain may change. In fact there are no subroutine calls involved in that chain.

e.g.

command_base -> AddUpperWall -> end_addwall -> end_normal_wall -> command_base
command_base -> AddLowerWall -> end_addwall -> end_normal_wall -> command_base
command_base -> AddLowerWall -> end_addwall -> end_dummy_wall -> command_base

 
----------
p:0155  00000c         (04 cyc)  rts
....
p:0378  0f7130         (04 cyc)  jsgt p:$0130
end_addwall:
p:0379  699b00         (02 cyc)  move y:$001b,r1
----------


p:0155 is probably 'close_ceil_r_edge' which is one of several floor/ceiling-related subroutines of the main wall insertion functions (e.g. AddMidWall). These subroutines are called by the 'jsgt' you see there to $130 (and I expect $155) from AddMidWall.

AddXXXWall then jumps (or falls through) to the 'end_addwall' merge point for all walls, and from here the finalization code is selected from a function pointer and it hops there, and then to command_base.

There is no JSR/RTS involved anywhere except for the subroutine calls to the floor/ceiling stuff, and to one wall init function from each wall inserter. It's a flat chain.


I can see that from "end_addwall" we always end in "end_dummy_addwall"
which leads to "command_base", which none of them have RTS:

That's correct, because there are no subroutine calls involved. Just path selection and jumps. No stack is involved.


When exactly subroutine calls to "end_addwall" will actually
lead to RTS?  And will it do that twice when "end_addwall"
gets subroutine call to from previous instruction?

There are no subroutine calls to end_addwall. Flow reaches there by a series of jmp's from command_base, and then all flow leads back to command_base.
 
The c&p refuses to work on my pc at the moment, need to restart (yes, a weird longstanding issue with windows and Uedit after it's been on too long :). I'll paste some source later which may make things clearer.

D


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/