machdep.s 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. .define ___Get_PC, ___Set_PC, ___u_LiB
  2. .sect .text; .sect .rom; .sect .data
  3. ! $Id$
  4. ! This is the machine-dependant part of the ACK debugger support.
  5. ! ___Get_PC takes a frame pointer (local base) argument and returns the
  6. ! return address from this frame.
  7. ! ___Set_PC takes a frame pointer (local base) argument plus a return
  8. ! address and sets the return address of this frame to the
  9. ! return address supplied.
  10. ! ___u_LiB saves the scratch registers and then calls ___uX_LiB;
  11. ! when ___uX_LiB returns, the scratch registers are restored.
  12. ! ___u_LiB is the solution chosen for the Intel 80386 back-end.
  13. ! Other back-ends could choose different solutions.
  14. ! The local base of ___uX_LiB is kind of special: because of ___u_LiB,
  15. ! the "interesting" return address of this particular stack-frame is found
  16. ! in a different place than the one of a normal stack-frame:
  17. ! the "interesting" return address is in fact the return address of
  18. ! ___u_LiB. Therefore, we save the local base of ___uX_LiB in sv_bp.
  19. .sect .data
  20. sv_bp:
  21. .data4 0
  22. .sect .text
  23. ___Get_PC:
  24. mov ebx,esp
  25. mov eax,4(ebx)
  26. or eax,eax
  27. je 1f
  28. cmp (sv_bp),eax
  29. je 2f
  30. mov eax,4(eax)
  31. 1:
  32. ret
  33. 2:
  34. mov eax,28(eax)
  35. ret
  36. ___Set_PC:
  37. mov ebx,esp
  38. mov eax,4(ebx)
  39. mov ebx,8(ebx)
  40. or eax,eax
  41. je 1f
  42. cmp (sv_bp),eax
  43. je 2f
  44. mov 4(eax),ebx
  45. 1:
  46. ret
  47. 2:
  48. mov 28(eax),ebx
  49. ret
  50. ___u_LiB:
  51. push eax
  52. push ebx
  53. push ecx
  54. push edx
  55. push (sv_bp)
  56. mov eax,esp
  57. sub eax,8
  58. mov (sv_bp),eax ! this is the LB of __uX_LiB
  59. call ___uX_LiB
  60. pop (sv_bp)
  61. pop edx
  62. pop ecx
  63. pop ebx
  64. pop eax
  65. ret