Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ncar!boulder!ccncsu!haines From: haines@debussy.cs.colostate.edu (Matt Haines) Newsgroups: comp.sys.hp Subject: HPPA Context switching code - still having problems Message-ID: <7748@ccncsu.ColoState.EDU> Date: 29 Jun 90 21:28:32 GMT Sender: news@ccncsu.ColoState.EDU Organization: Colorado State Computer Science Department Lines: 122 Hi again. I'm still working on the HPPA context-switching code, and I'm still having some problems. I fixed my problem with doubles (the dynamic storage allocator wasn't aligning things on full word boundaries), but it still core dumps sometimes. I say sometimes because for some programs it seems to work fine. Anyway, I have included the crux of the code. There are two routines, Save and Restore. They both take an argument of an integer array whose elements are used to save arguments 1 & 2, the PC and the SP, in that order. Two external variables are also used to save/restore the SP and PC. If there are any obvious errors in my assembly, please let me know. I'm having a helluva time getting this thing to run. (BTW, I did the Decstation - Sparc - code in about a day and it worked fine; if anyone needs that stuff, let me know). Thanks in advance, Matt. ------------------------------------------------------------------------- .CODE Save .PROC ; declare a procedure .CALLINFO CALLER,FRAME=48 .ENTRY LDO 96(30),30 ; make room on the stack ; for saved registers. ; ; save gr registers %gr19 .. %gr22 ; STW 19,-52(0,30) STW 20,-56(0,30) STW 21,-60(0,30) STW 22,-64(0,30) ; ; save fp registers %fr8 .. %fr11 ; LDO -72(30),3 FSTDS %fr8,0(0,3) LDO -80(30),3 FSTDS %fr9,0(0,3) LDO -88(30),3 FSTDS %fr10,0(0,3) LDO -96(30),3 FSTDS %fr11,0(0,3) ; ; Store the pc and sp to the argment array, elements 2 & 3. ; STW 2,8(0,26) ; save the pc STW 30,12(0,26) ; save the sp ; ; Get new values for sp and pc from external variables ; ADDIL L%WorkerSP-$global$,27 LDW R%WorkerSP-$global$(0,1),30 ; restore the sp ADDIL L%WorkerPC-$global$,27 LDW R%WorkerPC-$global$(0,1),2 ; restore the pc ; ; Ok, now go ... ; BE 0(0,2) NOP .EXIT .PROCEND .IMPORT WorkerPC,DATA .IMPORT WorkerSP,DATA .IMPORT $global$,DATA .EXPORT Save ; ***************************************************************************** .CODE Restore .PROC ; declare a procedure .CALLINFO CALLER,FRAME=0 .ENTRY ; ; Restore the pc and sp from the argument array, elements 2 & 3 ; LDW 8(0,26),2 ; reset the pc LDW 12(0,26),30 ; reset the sp ; ; restore gr registers %gr19 .. %gr22 ; LDW -52(30),19 LDW -56(30),20 LDW -60(30),21 LDW -64(30),22 ; ; restore fp registers %fr4 .. %fr11 ; LDO -72(30),3 FLDDS 0(0,3),%fr8 LDO -80(30),3 FLDDS 0(0,3),%fr9 LDO -88(30),3 FLDDS 0(0,3),%fr10 LDO -96(30),3 FLDDS 0(0,3),%fr11 ; ; Re-adjust the sp ; LDO -96(30),30 ; ; Go ... ; BE 0(0,2) ; start thread NOP .EXIT .PROCEND .EXPORT Restore ----------------------------------------------------------------------------- -- Matt Haines | "Don't take life too seriously ... Colorado State University, CS Dept. | nobody gets out of here alive!" 503 University Services Center | - Jim Morrison Ft. Collins, CO 80523 | (303) 491-1943 |