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