Some fix for scrolling with lasso.
[tangerine.git] / arch / x86_64-all / dispatch.s
blob25dc115a7de8c9201cc15abe5f995bb7ad7520fa
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id: dispatch.s 12742 2001-12-08 18:32:01Z chodorowski $
5 Desc: Exec function Dispatch()
6 Lang: english
7 */
9 /******************************************************************************
11 NAME
12 AROS_LH0(void, Dispatch,
14 LOCATION
15 struct ExecBase *, SysBase, 10, Exec)
17 FUNCTION
19 INPUTS
21 RESULT
23 NOTES
25 EXAMPLE
27 BUGS
29 SEE ALSO
31 INTERNALS
33 HISTORY
35 ******************************************************************************/
37 #include "machine.i"
39 .text
40 .balign 32 /* twice align of i386??? */
41 .globl AROS_SLIB_ENTRY(Dispatch,Exec)
42 .type AROS_SLIB_ENTRY(Dispatch,Exec),@function
44 AROS_SLIB_ENTRY(Dispatch,Exec):
45 /* Push all registers */
46 push %rax
47 push %rbx
48 push %rcx
49 push %rdx
50 push %rdi
51 push %rsi
52 push %rbp
53 push %r8
54 push %r9
55 push %r10
56 push %r11
57 push %r12
58 push %r13
59 push %r14
60 push %r15
62 /* block all signals */
63 call AROS_CSYMNAME(os_disable)
65 /* Get SysBase again */
66 movl 64+56(%rsp),%rcx
68 /* Store sp */
69 mov ThisTask(%rcx),%rdx
70 mov %rsp,tc_SPReg(%rdx)
72 /* Switch bit set? */
73 testb $TF_SWITCH,tc_Flags(%rdx)
74 je 1f
75 mov tc_Switch(%rdx),%rax
76 call *%rax
79 /* Store IDNestCnt */
80 movb IDNestCnt(%rcx),%al
81 movb %al,tc_IDNestCnt(%rdx)
82 movb $-1,IDNestCnt(%rcx)
84 /* Get task from ready list */
85 mov TaskReady(%rcx),%rdx
86 mov (%rdx),%rax
87 mov %rax,TaskReady(%rcx)
88 mov (%rdx),%rax
89 lea TaskReady(%rcx),%rbx
90 mov %rbx,8(%rax)
91 mov %rdx,ThisTask(%rcx)
93 /* Use as current task */
94 movb $TS_RUN,tc_State(%rdx)
95 movb tc_IDNestCnt(%rdx),%al
96 movb %al,IDNestCnt(%rcx)
98 /* Launch bit set? */
99 cmpb $0,tc_Flags(%rdx)
100 jge 2f
101 mov tc_Launch(%rdx),%rax
102 call *%rax
105 /* Get new sp */
106 mov tc_SPReg(%rdx),%rax
108 /* Compare agains SPLower */
109 cmp %rax,tc_SPLower(%rdx)
110 ja 3f
112 /* Compare against SPUpper */
113 cmp %rax,tc_SPUpper(%rdx)
114 ja 4f
117 /* Call Alert() */
118 push %rcx
119 push $(AT_DeadEnd|AN_StackProbe)
120 lea Alert(%rcx),%rax
121 call *%rax
122 /* Function does not return */
127 /* Put the SP into the correct register after checking */
128 mov %rax,%rsp
130 /* Unblock signals if necessary */
131 cmpb $0,tc_IDNestCnt(%rdx)
132 jge 5f
134 /* If called from the signal handler don't do it. */
135 cmp $0,AROS_CSYMNAME(supervisor)
136 jne 5f
137 call AROS_CSYMNAME(os_enable)
140 /* Except bit set? */
141 testb $TF_EXCEPT,tc_Flags(%rdx)
142 je 6f
144 /* Raise task exception in Disable()d state */
145 push %rcx
147 /* leal Disable(%rcx),%rax
148 call *%rax */
149 lea Exception(%rcx),%rax
150 call *%rax
151 /* mov (%rsp),%rcx
152 lea Enable(%rcx),%rax */
153 call *%rax
154 add $8,%rsp
156 /* Restore registers and return */
158 pop %r15
159 pop %r14
160 pop %r13
161 pop %r12
162 pop %r11
163 pop %r10
164 pop %r9
165 pop %r8
166 pop %rbp
167 pop %rsi
168 pop %rdi
169 pop %rdx
170 pop %rcx
171 pop %rbx
172 pop %rax