1 /* -*- mode: asm; tab-width: 4 -*- */
2 /****************************** asmpart.c **************************************
4 * is an assembly language file, but called .c to fake the preprocessor. *
5 * It contains the Java-C interface functions for Alpha processors. *
7 * Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst *
9 * See file COPYRIGHT for information on usage and disclaimer of warranties *
11 * Authors: Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at *
12 * Andreas Krall EMAIL: cacao@complang.tuwien.ac.at *
14 * Last Change: 1997/04/26 *
16 *******************************************************************************/
87 /********************* exported functions and variables ***********************/
89 .globl has_no_x_instr_set
90 .globl synchronize_caches
91 .globl asm_calljavamethod
92 .globl asm_call_jit_compiler
93 .globl asm_dumpregistersandcall
94 .globl asm_handle_exception
95 .globl asm_handle_nat_exception
96 .globl asm_signal_exception
97 .globl new_builtin_checkcast
98 .globl new_builtin_checkarraycast
99 .globl new_builtin_aastore
100 .globl new_builtin_monitorenter
101 .globl new_builtin_monitorexit
102 .globl new_builtin_idiv
103 .globl new_builtin_irem
104 .globl new_builtin_ldiv
105 .globl new_builtin_lrem
106 .globl perform_alpha_threadswitch
107 .globl initialize_thread_stack
108 .globl asm_switchstackandcall
111 /*************************** imported variables *******************************/
116 /*************************** imported functions *******************************/
118 .globl compiler_compile
119 .globl builtin_monitorexit
120 .globl builtin_throw_exception
121 .globl builtin_trace_exception
122 .globl class_java_lang_Object
124 /*********************** function has_no_x_instr_set ***************************
126 * determines if the byte support instruction set (21164a and higher) *
129 *******************************************************************************/
131 .ent has_no_x_instr_set
134 .long 0x47e03c20 # amask 1,$0
135 jmp zero,(ra) # return
137 .end has_no_x_instr_set
140 /********************* function synchronize_caches ****************************/
142 .ent synchronize_caches
145 call_pal PAL_imb # synchronise instruction cache
146 jmp zero,(ra) # return
148 .end synchronize_caches
151 /********************* function asm_calljavamethod *****************************
153 * This function calls a Java-method (which possibly needs compilation) *
154 * with up to 4 parameters. *
156 * This functions calls the JIT-compiler which eventually translates the *
157 * method into machine code. *
159 * An possibly throwed exception will be returned to the caller as function *
160 * return value, so the java method cannot return a fucntion value (this *
161 * function usually calls 'main' and '<clinit>' which do not return a *
165 * javaobject_header *asm_calljavamethod (methodinfo *m, *
166 * void *arg1, void *arg2, void *arg3, void *arg4); *
168 *******************************************************************************/
170 #define MethodPointer -8
171 #define FrameSize -12
176 #define ExTableSize -32
177 #define ExTableStart -32
179 #define ExEntrySize -32
182 #define ExHandlerPC -24
183 #define ExCatchType -32
185 .ent asm_calljavamethod
188 .ascii "calljavamethod\0\0"
191 .quad 0 # catch type all
192 .quad calljava_xhandler # end pc
193 .quad calljava_xhandler # end pc
194 .quad asm_calljavamethod # start pc
195 .long 1 # extable size
200 .long 32 # frame size
201 .quad 0 # method pointer (pointer to name) @@@@@
206 lda sp,-32(sp) # allocate stack space
207 stq gp,24(sp) # save global pointer
208 stq ra,0(sp) # save return address
210 stq $16,16(sp) # save method pointer for compiler
211 lda $0,16(sp) # pass pointer to method pointer via $0
213 bis $17,$17,$16 # pass the remaining parameters
218 lda $28,asm_call_jit_compiler # fake virtual function call
219 stq $28,8(sp) # store function address
220 bis sp,sp,$28 # set method pointer
222 ldq pv,8($28) # method call as in Java
223 jmp ra,(pv) # call JIT compiler
225 lda pv,-64(ra) # asm_calljavamethod-calljava_jit(ra) !!!!!!
229 ldq ra,0(sp) # restore return address
230 ldq gp,24(sp) # restore global pointer
231 lda sp,32(sp) # free stack space
232 ldl $0,newcompiler # load newcompiler flag
233 subq $0,1,$0 # negate for clearing $0
234 beq $0,calljava_ret # if newcompiler skip ex copying
235 bis $1,$1,$0 # pass exception to caller (C)
241 ldq gp,24(sp) # restore global pointer
243 jsr ra,builtin_throw_exception
244 ldq ra,0(sp) # restore return address
245 lda sp,32(sp) # free stack space
247 .end asm_calljavamethod
250 /****************** function asm_call_jit_compiler *****************************
252 * invokes the compiler for untranslated JavaVM methods. *
254 * Register R0 contains a pointer to the method info structure (prepared *
255 * by createcompilerstub). Using the return address in R26 and the *
256 * offset in the LDA instruction or using the value in methodptr R28 the *
257 * patching address for storing the method address can be computed: *
259 * method address was either loaded using *
260 * M_LDQ (REG_PV, REG_PV, a) # invokestatic/special ($27) *
261 * M_LDA (REG_PV, REG_RA, low) *
262 * M_LDAH(REG_PV, REG_RA, high) # optional *
264 * M_LDQ (REG_PV, REG_METHODPTR, m) # invokevirtual/interface ($28) *
265 * in the static case the method pointer can be computed using the *
266 * return address and the lda function following the jmp instruction *
268 *******************************************************************************/
271 .ent asm_call_jit_compiler
272 asm_call_jit_compiler:
275 ldl $22,-8(ra) # load instruction LDQ PV,xxx($yy)
276 srl $22,16,$22 # shift right register number $yy
277 and $22,31,$22 # isolate register number
278 subl $22,28,$22 # test for REG_METHODPTR
280 ldl $22,0(ra) # load instruction LDA PV,xxx(RA)
282 sra $22,48,$22 # isolate offset
283 addq $22,ra,$28 # compute update address
284 ldl $22,4(ra) # load instruction LDAH PV,xxx(PV)
285 srl $22,16,$22 # isolate instruction code
286 lda $22,-0x177b($22) # test for LDAH
288 ldl $22,0(ra) # load instruction LDA PV,xxx(RA)
289 sll $22,16,$22 # compute high offset
290 addl $22,0,$22 # sign extend high offset
291 addq $22,$28,$28 # compute update address
293 lda sp,-14*8(sp) # reserve stack space
294 stq $16,0*8(sp) # save all argument registers
295 stq $17,1*8(sp) # they could be used by method
306 stq $28,12*8(sp) # save method pointer
307 stq ra,13*8(sp) # save return address
309 ldq $16,0($0) # pass 'methodinfo' pointer to
310 jsr ra,compiler_compile # compiler
313 call_pal PAL_imb # synchronise instruction cache
315 ldq $16,0*8(sp) # load argument registers
327 ldq $28,12*8(sp) # load method pointer
328 ldq ra,13*8(sp) # load return address
329 lda sp,14*8(sp) # deallocate stack area
331 ldl $22,-8(ra) # load instruction LDQ PV,xxx($yy)
333 sra $22,48,$22 # isolate offset
335 addq $22,$28,$22 # compute update address via method pointer
336 stq $0,0($22) # save new method address there
338 bis $0,$0,pv # load method address into pv
340 jmp zero, (pv) # and call method. The method returns
341 # directly to the caller (ra).
343 .end asm_call_jit_compiler
346 /****************** function asm_dumpregistersandcall **************************
348 * This funtion saves all callee saved registers and calls the function *
349 * which is passed as parameter. *
351 * This function is needed by the garbage collector, which needs to access *
352 * all registers which are stored on the stack. Unused registers are *
353 * cleared to avoid interferances with the GC. *
355 * void asm_dumpregistersandcall (functionptr f); *
357 *******************************************************************************/
359 .ent asm_dumpregistersandcall
360 asm_dumpregistersandcall:
361 lda sp,-16*8(sp) # allocate stack
362 stq ra,0(sp) # save return address
364 stq $9,1*8(sp) # save all callee saved registers
365 stq $10,2*8(sp) # intialize the remaining registers
380 bis zero,zero,$0 # intialize the remaining registers
426 bis $16,$16,pv # load function pointer
427 jmp ra,(pv) # and call function
429 ldq ra,0(sp) # load return address
430 lda sp,16*8(sp) # deallocate stack
431 jmp zero,(ra) # return
433 .end asm_dumpregistersandcall
436 /********************* function asm_handle_exception ***************************
438 * This function handles an exception. It does not use the usual calling *
439 * conventions. The exception pointer is passed in REG_ITMP1 and the *
440 * pc from the exception raising position is passed in REG_ITMP2. It searches *
441 * the local exception table for a handler. If no one is found, it unwinds *
442 * stacks and continues searching the callers. *
444 * void asm_handle_exception (exceptionptr, exceptionpc); *
446 *******************************************************************************/
448 .ent asm_handle_nat_exception
449 asm_handle_nat_exception:
451 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
453 sra t0,48,t0 # isolate offset
454 addq t0,ra,pv # compute update address
455 ldl t0,4(ra) # load instruction LDAH PV,xxx(PV)
456 srl t0,16,t0 # isolate instruction code
457 lda t0,-0x177b(t0) # test for LDAH
458 bne t0,asm_handle_exception
459 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
460 sll t0,16,t0 # compute high offset
461 addl t0,0,t0 # sign extend high offset
462 addq t0,pv,pv # compute update address
464 .aent asm_handle_exception
465 asm_handle_exception:
467 lda sp,-18*8(sp) # allocate stack
468 stq t0,0*8(sp) # save possible used registers
469 stq t1,1*8(sp) # also registers used by builtin_checkcast
487 lda t3,1(zero) # set no unwind flag
489 lda sp,-5*8(sp) # allocate stack
490 stq xptr,0*8(sp) # save used register
497 ldq a1,MethodPointer(pv)
500 br ra,ex_trace # set ra for gp loading
502 ldgp gp,0(ra) # load gp
503 jsr ra,builtin_trace_exception # builtin_trace_exception(xptr,methodptr)
505 ldq xptr,0*8(sp) # restore used register
510 lda sp,5*8(sp) # deallocate stack
512 ldl t0,ExTableSize(pv) # t0 = exception table size
513 beq t0,empty_table # if empty table skip
514 lda t1,ExTableStart(pv) # t1 = start of exception table
517 ldq t2,ExStartPC(t1) # t2 = exception start pc
518 cmple t2,xpc,t2 # t2 = (startpc <= xpc)
519 beq t2,ex_table_cont # if (false) continue
520 ldq t2,ExEndPC(t1) # t2 = exception end pc
521 cmplt xpc,t2,t2 # t2 = (xpc < endpc)
522 beq t2,ex_table_cont # if (false) continue
523 ldq a1,ExCatchType(t1) # arg1 = exception catch type
524 beq a1,ex_handle_it # NULL catches everything
525 mov xptr,a0 # arg0 = exception pointer
527 lda sp,-7*8(sp) # allocate stack
528 stq t0,0*8(sp) # save used register
536 br ra,ex_gpload # set ra for gp loading
538 ldgp gp,0(ra) # load gp
539 jsr ra,builtin_checkcast # builtin_checkcast(xptr,catchtype)
541 ldq t0,0*8(sp) # restore used register
548 lda sp,7*8(sp) # deallocate stack
550 beq v0,ex_table_cont # if (false) continue
554 ldq xpc,ExHandlerPC(t1) # xpc = exception handler pc
556 beq t3,ex_jump # if (!(no stack unwinding) skip
558 ldq t0,0*8(sp) # restore possible used registers
559 ldq t1,1*8(sp) # also registers used by builtin_checkcast
576 lda sp,18*8(sp) # deallocate stack
579 jmp zero,(xpc) # jump to the handler
582 lda t1,ExEntrySize(t1) # next exception table entry
583 subl t0,1,t0 # decrement entry counter
584 bgt t0,ex_table_loop # if (t0 > 0) next entry
587 beq t3,ex_already_cleared # if here the first time, then
588 lda sp,18*8(sp) # deallocate stack and
589 clr t3 # clear the no unwind flag
591 ldl t0,IsSync(pv) # t0 = SyncOffset
592 beq t0,no_monitor_exit # if zero no monitorexit
593 addq sp,t0,t0 # add Offset to stackptr
594 ldq a0,-8(t0) # load monitorexit pointer
596 lda sp,-7*8(sp) # allocate stack
597 stq t0,0*8(sp) # save used register
605 br ra,ex_mon_load # set ra for gp loading
607 ldgp gp,0(ra) # load gp
608 jsr ra,builtin_monitorexit # builtin_monitorexit(objectptr)
610 ldq t0,0*8(sp) # restore used register
617 lda sp,7*8(sp) # deallocate stack
620 ldl t0,FrameSize(pv) # t0 = frame size
621 addq sp,t0,sp # unwind stack
622 mov sp,t0 # t0 = pointer to save area
623 ldl t1,IsLeaf(pv) # t1 = is leaf procedure
624 bne t1,ex_no_restore # if (leaf) skip
625 ldq ra,-8(t0) # restore ra
628 mov ra,xpc # the new xpc is ra
629 ldl t1,IntSave(pv) # t1 = saved int register count
630 br t2,ex_int1 # t2 = current pc
632 lda t2,44(t2) # lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!!!!
633 negl t1,t1 # negate register count
634 s4addq t1,t2,t2 # t2 = ex_int_sav - 4 * register count
635 jmp zero,(t2) # jump to save position
644 s8addq t1,t0,t0 # t0 = t0 - 8 * register count
646 ldl t1,FltSave(pv) # t1 = saved flt register count
647 br t2,ex_flt1 # t2 = current pc
649 lda t2,48(t2) # lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!!!!
650 negl t1,t1 # negate register count
651 s4addq t1,t2,t2 # t2 = ex_flt_sav - 4 * register count
652 jmp zero,(t2) # jump to save position
662 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
664 sra t0,48,t0 # isolate offset
665 addq t0,ra,pv # compute update address
666 ldl t0,4(ra) # load instruction LDAH PV,xxx(PV)
667 srl t0,16,t0 # isolate instruction code
668 lda t0,-0x177b(t0) # test for LDAH
670 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
671 sll t0,16,t0 # compute high offset
672 addl t0,0,t0 # sign extend high offset
673 addq t0,pv,pv # compute update address
676 .end asm_handle_exception
679 /********************* function asm_signal_exception ***************************
681 * This function handles an exception which was catched by a signal. *
683 * void asm_signal_exception (exceptionptr, signalcontext); *
685 *******************************************************************************/
687 #define sigctxstack 0*8 /* sigstack state to restore */
688 #define sigctxmask 1*8 /* signal mask to restore */
689 #define sigctxpc 2*8 /* pc at time of signal */
690 #define sigctxpsl 3*8 /* psl to retore */
691 #define sigctxr00 4*8 /* processor regs 0 to 31 */
692 #define sigctxr01 5*8
693 #define sigctxr02 6*8
694 #define sigctxr03 7*8
695 #define sigctxr04 8*8
696 #define sigctxr05 9*8
697 #define sigctxr06 10*8
698 #define sigctxr07 11*8
699 #define sigctxr08 12*8
700 #define sigctxr09 13*8
701 #define sigctxr10 14*8
702 #define sigctxr11 15*8
703 #define sigctxr12 16*8
704 #define sigctxr13 17*8
705 #define sigctxr14 18*8
706 #define sigctxr15 19*8
707 #define sigctxr16 20*8
708 #define sigctxr17 21*8
709 #define sigctxr18 22*8
710 #define sigctxr19 23*8
711 #define sigctxr20 24*8
712 #define sigctxr21 25*8
713 #define sigctxr22 26*8
714 #define sigctxr23 27*8
715 #define sigctxr24 28*8
716 #define sigctxr25 29*8
717 #define sigctxr26 30*8
718 #define sigctxr27 31*8
719 #define sigctxr28 32*8
720 #define sigctxr29 33*8
721 #define sigctxr30 34*8
722 #define sigctxr31 35*8
724 #define sigctxfpuse 36*8 /* fp has been used */
725 #define sigctxf00 37*8 /* fp regs 0 to 31 */
726 #define sigctxf01 38*8
727 #define sigctxf02 39*8
728 #define sigctxf03 40*8
729 #define sigctxf04 41*8
730 #define sigctxf05 42*8
731 #define sigctxf06 43*8
732 #define sigctxf07 44*8
733 #define sigctxf08 45*8
734 #define sigctxf09 46*8
735 #define sigctxf10 47*8
736 #define sigctxf11 48*8
737 #define sigctxf12 49*8
738 #define sigctxf13 50*8
739 #define sigctxf14 51*8
740 #define sigctxf15 52*8
741 #define sigctxf16 53*8
742 #define sigctxf17 54*8
743 #define sigctxf18 55*8
744 #define sigctxf19 56*8
745 #define sigctxf20 57*8
746 #define sigctxf21 58*8
747 #define sigctxf22 59*8
748 #define sigctxf23 60*8
749 #define sigctxf24 61*8
750 #define sigctxf25 62*8
751 #define sigctxf26 63*8
752 #define sigctxf27 64*8
753 #define sigctxf28 65*8
754 #define sigctxf29 66*8
755 #define sigctxf30 67*8
756 #define sigctxf31 68*8
758 #define sigctxhfpcr 69*8 /* floating point control register */
759 #define sigctxsfpcr 70*8 /* software fpcr */
761 .ent asm_signal_exception
762 asm_signal_exception:
767 ldq v0,sigctxr00(sp) # restore possible used registers
791 ldq t10,sigctxr24(sp)
795 br asm_handle_nat_exception
796 .end asm_signal_exception
799 /********************* function new_builtin_monitorenter ***********************
801 * Does null check and calls monitorenter or throws an exception *
803 *******************************************************************************/
805 .ent new_builtin_monitorenter
806 new_builtin_monitorenter:
809 lda pv,builtin_monitorenter
810 beq a0,nb_monitorenter # if (null) throw exception
811 jmp zero,(pv) # else call builtin_monitorenter
814 ldq xptr,proto_java_lang_NullPointerException
815 lda xpc,-4(ra) # faulting address is return adress - 4
816 br asm_handle_nat_exception
817 .end new_builtin_monitorenter
820 /********************* function new_builtin_monitorexit ************************
822 * Does null check and calls monitorexit or throws an exception *
824 *******************************************************************************/
826 .ent new_builtin_monitorexit
827 new_builtin_monitorexit:
830 lda pv,builtin_monitorexit
831 beq a0,nb_monitorexit # if (null) throw exception
832 jmp zero,(pv) # else call builtin_monitorexit
835 ldq xptr,proto_java_lang_NullPointerException
836 lda xpc,-4(ra) # faulting address is return adress - 4
837 br asm_handle_nat_exception
838 .end new_builtin_monitorenter
841 /************************ function new_builtin_idiv ****************************
843 * Does null check and calls idiv or throws an exception *
845 *******************************************************************************/
847 .ent new_builtin_idiv
852 beq a1,nb_idiv # if (null) throw exception
853 jmp zero,(pv) # else call builtin_idiv
856 ldq xptr,proto_java_lang_ArithmeticException
857 lda xpc,-4(ra) # faulting address is return adress - 4
858 br asm_handle_nat_exception
859 .end new_builtin_idiv
862 /************************ function new_builtin_ldiv ****************************
864 * Does null check and calls ldiv or throws an exception *
866 *******************************************************************************/
868 .ent new_builtin_ldiv
873 beq a1,nb_ldiv # if (null) throw exception
874 jmp zero,(pv) # else call builtin_ldiv
877 ldq xptr,proto_java_lang_ArithmeticException
878 lda xpc,-4(ra) # faulting address is return adress - 4
879 br asm_handle_nat_exception
880 .end new_builtin_ldiv
883 /************************ function new_builtin_irem ****************************
885 * Does null check and calls irem or throws an exception *
887 *******************************************************************************/
889 .ent new_builtin_irem
894 beq a1,nb_irem # if (null) throw exception
895 jmp zero,(pv) # else call builtin_irem
898 ldq xptr,proto_java_lang_ArithmeticException
899 lda xpc,-4(ra) # faulting address is return adress - 4
900 br asm_handle_nat_exception
901 .end new_builtin_irem
904 /************************ function new_builtin_lrem ****************************
906 * Does null check and calls lrem or throws an exception *
908 *******************************************************************************/
910 .ent new_builtin_lrem
915 beq a1,nb_lrem # if (null) throw exception
916 jmp zero,(pv) # else call builtin_lrem
919 ldq xptr,proto_java_lang_ArithmeticException
920 lda xpc,-4(ra) # faulting address is return adress - 4
921 br asm_handle_nat_exception
922 .end new_builtin_lrem
925 /*********************** function new_builtin_checkcast ************************
927 * Does the cast check and eventually throws an exception *
929 *******************************************************************************/
931 .ent new_builtin_checkcast
932 new_builtin_checkcast:
935 lda sp,-16(sp) # allocate stack space
936 stq ra,0(sp) # save return address
937 stq a0,8(sp) # save object pointer
938 jsr ra,builtin_checkcast # builtin_checkcast
940 beq v0,nb_ccast_throw # if (false) throw exception
941 ldq ra,0(sp) # restore return address
942 ldq v0,8(sp) # return object pointer
943 lda sp,16(sp) # free stack space
947 ldq xptr,proto_java_lang_ClassCastException
948 ldq ra,0(sp) # restore return address
949 lda sp,16(sp) # free stack space
950 lda xpc,-4(ra) # faulting address is return adress - 4
951 br asm_handle_nat_exception
952 .end new_builtin_checkcast
955 /******************* function new_builtin_checkarraycast ***********************
957 * Does the cast check and eventually throws an exception *
959 *******************************************************************************/
961 .ent new_builtin_checkarraycast
962 new_builtin_checkarraycast:
965 lda sp,-16(sp) # allocate stack space
966 stq ra,0(sp) # save return address
967 stq a0,8(sp) # save object pointer
968 jsr ra,builtin_checkarraycast # builtin_checkarraycast
970 beq v0,nb_carray_throw # if (false) throw exception
971 ldq ra,0(sp) # restore return address
972 ldq v0,8(sp) # return object pointer
973 lda sp,16(sp) # free stack space
977 ldq xptr,proto_java_lang_ClassCastException
978 ldq ra,0(sp) # restore return address
979 lda sp,16(sp) # free stack space
980 lda xpc,-4(ra) # faulting address is return adress - 4
981 br asm_handle_nat_exception
982 .end new_builtin_checkarraycast
985 /******************* function new_builtin_aastore ******************************
987 * Does the cast check and eventually throws an exception *
989 *******************************************************************************/
991 .ent new_builtin_aastore
995 beq a0,nb_aastore_null # if null pointer throw exception
996 ldl t0,offarrsize(a0) # load size
997 lda sp,-24(sp) # allocate stack space
998 stq ra,0(sp) # save return address
999 s8addq a1,a0,t1 # add index*8 to arrayref
1000 cmpult a1,t0,t0 # do bound check
1001 beq t0,nb_aastore_bound # if out of bounds throw exception
1002 mov a2,a1 # object is second argument
1003 stq t1,8(sp) # save store position
1004 stq a1,16(sp) # save object
1005 jsr ra,builtin_canstore # builtin_canstore(arrayref,object)
1007 ldq ra,0(sp) # restore return address
1008 ldq a0,8(sp) # restore store position
1009 ldq a1,16(sp) # restore object
1010 lda sp,24(sp) # free stack space
1011 beq v0,nb_aastore_throw # if (false) throw exception
1012 stq a1,offobjarr(a0) # store objectptr in array
1016 ldq xptr,proto_java_lang_NullPointerException
1017 mov ra,xpc # faulting address is return adress
1018 br asm_handle_nat_exception
1021 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
1022 lda sp,24(sp) # free stack space
1023 mov ra,xpc # faulting address is return adress
1024 br asm_handle_nat_exception
1027 ldq xptr,proto_java_lang_ArrayStoreException
1028 mov ra,xpc # faulting address is return adress
1029 br asm_handle_nat_exception
1031 .end new_builtin_aastore
1034 /********************** function initialize_thread_stack ***********************
1036 * initialized a thread stack *
1038 *******************************************************************************/
1040 .ent initialize_thread_stack
1041 initialize_thread_stack:
1062 .end initialize_thread_stack
1065 /******************* function perform_alpha_threadswitch ***********************
1067 * void perform_alpha_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1068 * performs a threadswitch *
1070 *******************************************************************************/
1072 .ent perform_alpha_threadswitch
1073 perform_alpha_threadswitch:
1114 .end perform_alpha_threadswitch
1117 /********************* function asm_switchstackandcall *************************
1119 * Switches to a new stack, calls a function and switches back. *
1120 * a0 new stack pointer *
1121 * a1 function pointer *
1123 *******************************************************************************/
1126 .ent asm_switchstackandcall
1127 asm_switchstackandcall:
1128 lda a0,-2*8(a0) # allocate new stack
1129 stq ra,0(a0) # save return address
1130 stq sp,1*8(a0) # save old stack pointer
1131 mov a0,sp # switch to new stack
1133 mov a1,pv # load function pointer
1134 jmp ra,(pv) # and call funciton
1136 ldq ra,0(sp) # load return address
1137 ldq sp,1*8(sp) # switch to old stack
1139 jmp zero,(ra) # return
1141 .end asm_switchstackandcall