Pristine Ack-5.5
[Ack-5.5.git] / mach / m68020 / 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:07:48 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 MC68020 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_a6.
22
23 .sect .data
24 sv_a6:
25         .data4 0
26
27 .sect .text
28 ___Get_PC:
29         move.l  (4,sp),d0
30         beq     1f
31         move.l  d0,a0
32         cmp.l   (sv_a6),d0
33         beq     2f
34         move.l  (4,a0),d0
35 1:
36         rts
37 2:
38         move.l  (32,a0),d0
39         rts
40
41 ___Set_PC:
42         move.l  (4,sp),d0
43         beq     1f
44         move.l  d0,a0
45         cmp.l   (sv_a6),d0
46         beq     2f
47         move.l  (8,sp),(4,a0)
48 1:
49         rts
50 2:
51         move.l  (8,sp),(32,a0)
52         rts
53
54 ___u_LiB:
55         movem.l d0/d1/d2/a0/a1,-(sp)
56         move.l  (sv_a6),-(sp)
57         move.l  sp,d0
58         sub.l   #8,d0
59         move.l  d0,(sv_a6)      ! this is the LB of __uX_LiB
60         jsr (___uX_LiB)
61         move.l  (sp)+,(sv_a6)
62         movem.l (sp)+,d0/d1/d2/a0/a1
63         rts