TweetFollow Us on Twitter

Switcher
Volume Number:3
Issue Number:5
Column Tag:Forth Forum

Background Processing Under Switcher

By Jörg Langowski, MacTutor Editorial Board, Grenoble, France

Switcher is the closest thing to a multiprocessing system on the Macintosh (not counting Servant, a fully functional version of which has not seen the light of day as I write this, or Finder 6.0 which Apple is rumored to be developing). It is not really multiprocessing, since an application that is running in one partition of Switcher is put to sleep when you switch to another one. True multiprocessing is not easy to achieve on the Mac because it lacks memory management hardware (this, of course, has changed with the Mac II).

Switcher does support some background processing, however. The problem is that the application has to cooperate to allow background tasks to run. There is no way (no easy way, at least) that Switcher could interrupt a running application and transfer control to another one. It is the application itself that has to draw a clear line between foreground and background tasks, setting up pieces of its code to be run in the background that will by themselves transfer control back to Switcher.

This is very similar to the way multiprocessing is achieved in the various Forth and Forth-based systems that you've been reading about in this column. In those systems, tasks have to be cooperative and transfer control back to the task switcher at convenient points in their code (through words like PAUSE in MacForth and Mach2).

A Macintosh application under Switcher contains one interface point where control may be transferred to another task: the GetNextEvent routine. In fact, Switcher will only switch tasks on a call to GetNextEvent (when a switch request has been made).

It is at this point where background processing can take place. Every time an application calls GetNextEvent, Switcher will not only check whether you clicked the mouse on the double arrow or issued a keyboard command to initiate switching, but also check whether any of the installed applications contain background tasks that have to be run while they are inactive.

Such a background task routine may be a short piece of code that checks whether a character has come in from the serial port and stores it away in a file, or vice versa output from a file to a serial line. It may also run some ongoing calculations, collect data from an instrument, etc. It should return not too late after it has been called, in order not to cause too much slowing down of the active application. The backgound task will be part of an application installed under Switcher, where the task setup is done by the active part of the application and the task takes over when the application becomes inactive.

I'm sure none of you will be able to write a background task from these very general remarks. So how does one actually do it? A very useful document to read at this point is Inside Switcher (available through APDA). This document takes the same holistic approach as Inside Macintosh in that it requires you to understand all of it before you can make sense of the first paragraph (or nearly so), but otherwise gives a very good account about the things to observe when writing applications that are to run under Switcher.

First, lets look at the way task information is stored in Switcher. There is one global variable, SwitcherGlobals ($282), which contains a pointer to the beginning of the Switcher global variable area in the system heap. The structure of this area is described in Inside Switcher, and I'll shortly summarize it here.

The example listing contains the definitions for the Switcher tables. Each application is contained in a designated piece of memory, called a world, which is pointed to by one of the world pointers at the beginning of the Switcher globals. An application's world starts with an 18-byte header, followed by the application stack and heap area. The last 32K of a world are reserved for use by Switcher.

The header of a Switcher world contains in sequence:

- PSRPtr, a handle to the process state record of the application (explained later),

- a 2-byte flag field,

- BkgdProc, a pointer to a background procedure. Each installed application may have one BkgdProc associated with it, and Switcher calls them in sequence whenever a null event is fetched from the event queue. If this pointer is NIL, nothing is executed.

- SavScrBits, a handle to the part of memory that contains the saved screen bitmap of the application. If this is =0, the screen is not being saved.

- DAPtr, a window pointer to a virtual desk accessory that the Switcher uses for Clipboard conversion. (This procedure is explained in Inside Switcher, and I won't go into details here).

So all we'll have to do to execute a background routine under Switcher is to store a valid pointer to the routine in the BkgdProc field of the world header. Then Switcher will jump to that routine on each null event and probably come up with a beautiful bomb display unless the routine to execute is either extremely simple (such as RTS) or we have taken further precautions.

Ideally, we'd like to write the background task in Forth and execute it in our Forth system's world. To do this, you need some interface to the Forth code that can be jumped to directly and returns via an RTS. In Mach2, the Forth code itself has those properties, since it is subroutine threaded. In the case of MacForth (for example), we'll have to store the address of the routine's code field in the BkgdProc field of the Switcher world, and make sure the code returns via an RTS (and not through the Forth system's NEXT routine). The example program is in Mach2, but MacForth users will easily be able to adapt the code to their system following these principles. NEON users will have to define the background routine using :proc and ;proc, the words provided for defining routines whose addresses may be passed as parameters to toolbox traps.

The problem with executing a background task written in Forth using the surrounding support of the Forth system is of course that all existing Forth systems depend heavily on a set of registers in which parameter stack, return stack, user area pointers, loop indices, etc. are kept. The status of the registers, however, is completely undefined when Switcher calls the background routine. Therefore, the simple approach described above must fail.

In order to properly execute a background routine from outside, we have to do what is known as context switching, meaning that a) the register file has to be restored to the values used by the Forth system, and b) any system global variables that are used by the Forth system have to be restored as well. All this is done automatically by Switcher on switching applications, but not when calling a background task; that would be much too much overhead.

The full context switching is effected by Switcher through the information stored in the process state record of the application. This table is pointed to by the handle PSRPtr mentioned above. Its first four bytes contain its total size, followed by a copy of many of the low-memory globals used by the application. The location of important ones among them is given in Listing 1. Notice that StkLowPt and HeapEnd are contained here, these variables being consulted by the 'stack sniffer' to determine whether to display a System Error 28.

What interests us most here is that the last four bytes of the process state record contain the value of the stack pointer left behind when control was transferred to another application. The last thing saved on that stack before switching are registers A0-A6 and D0-D7, through a MOVEM.L A0-A6/D0-D7, -(A7).

Therefore, restoring A7 to the value left behind and then popping the other registers off the stack will leave us with a register set equal to the one left behind on switching. But... trying to do so is almost certain to get you a number 28 bomb, because A7 it totally out of line with the actual contents of StkLowPt and HeapEnd. There is an excellent chance that the stack sniffer will notice this and bang. The method I chose in the glue routine for calling background procedures is to use A0 as a temporary stack pointer and restore the registers from there. Since I do not change StkLowPt and HeapEnd, A7 must stay the same as well, so the A7 stack of the calling application is used for the background routine. This really doesn't make a big difference, as long as your routine doesn't do funny things with JSR return addresses left on the stack.

After the registers have been restored, of course, they're all valid for the context of the background task (including A5).

How does a background task know which Switcher world it is contained in (we need to know this to find the process state record and get the stack pointer)? Lets look at the example listing again at this point. I have provided a couple of words that are useful when running under Switcher. isSwitcher looks at the SwitcherGlobals pointer; if it is positive (i.e. the pointer is valid), Switcher is installed. Worlds will display the names of all installed applications. The way this is done is by looking at all of the eight world pointers, access the process state record for each application and display the string starting at PSR+344. This is where a copy of the system global AppName is kept. The general layout of the global variable space in the PSR can be seen from the listing; not all of the system globals are transferred on switching, but the variables for Quickdraw, Toolbox and the Segment Loader (starting at $800 in the 'real world') are saved consecutively starting at PSR+72.

ActiveWorld# displays the number of the world that the active application (Mach2, in this case) is currently running in. This routine gives interesting information, but is useless for code in a background routine to determine whether it is active or not (because we still don't know which application contains the background routine). Inside Switcher gives a recommendation: store the value of ApplZone (global $2AA) in variable space in your program when the application is initialized (storeApplZone does this), and later compare this saved value with the current value (IamActive is provided for this purpose).

I hope you're well enough 'primed' with some aspects of Switcher now so that we may continue with the actual problem of the day, installation of a Forth-written background routine that performs some useful task.

The routine that Switcher executes will be a glue routine that makes sure the register file is ok, calls the Forth routine that has to be executed, then restores the registers and returns to Switcher.

Switcher passes one parameter to the background routine, the task's WorldPtr in register A1. The glue routine first determines whether the application that contains the task is active or not. If the application is active, the process state record may be invalid (it is updated only when the application becomes inactive); therefore the actual background task will be skipped over in that case.

If the application is inactive, the glue routine gets the PSRPtr from the world header and restores the register file as described above. Then, control is passed to the background task. On return, everything is restored.

The background task in the example will open a text file and do a draft quality print (ASCII mode) on the Imagewriter. The program is adapted (rather heavily adapted) from an example given by Palo Alto Shipping on their demonstration disk. The original program was meant to print a file as a background task under Mach2, and therefore contained PAUSEs and async I/O calls. These features are not really needed here and have been removed. In fact, they're dangerous for what we are doing for the following reason:

It is not really possible to jump into the context of the Forth system by just restoring all registers and expecting everything else to behave. The problem is with the low memory system globals, which would have to be updated, too. It seems that anything that contains a PAUSE will bomb. One of the reasons for that might be that transfer will be given to other Mach2 tasks that try to write to the screen, and that is a no-no for background tasks according to Inside Switcher.

The other Forth routines, notably those which are called by offsetting from A5 or going through a jump table, will execute normally from the background. Macintalk will bomb; anything that requires calls to the Segment Loader, probably, too (I haven't tried this).

The printing routine, then, does the following: From the foreground, a file to print is selected. Then the background task is installed; when the application becomes inactive, it will start to read the file in 512-byte chunks and dump it on the printer. Meanwhile, you will be able to use other applications under Switcher. However: 512 byte blocks are really too large to make the other programs run smoothly. I haven't changed the block size in the example, but it is an easy matter to do so; it might even be better to transfer only one character on each call of the background task. Anyway, the example does illustrate the point, and you'll be able to install other background processes this way (and/or translate the whole thing to NEON or MacForth).

After a file has been printed, the SFGetFile dialog comes up again (in the foreground), and you can select another one. Cancelling the dialog will remove the printing routine from the Switcher worlds.

Concluding remarks

There is a lot more to be said about Switcher: how to access one application's variables from another program, how to deal with VBL routines and asynchronous I/O, how to switch automatically from within a program, clipboard conversion, suspend/resume events, etc. etc. But I cannot repeat Inside Switcher here, so I'd strongly suggest you to get a copy from APDA in case these subjects are of any interest to you.

Last time I had promised to give some more hints about DA programming from Forth; we'll put that off for a later column.

There is one last comment I have to make concerning the eternal MacForth vs. The Other Forths issue. I happen to use Mach2 for the examples in my column; this shouldn't be viewed as a bias on the part of MacTutor or myself for one particular system. It is just that I prefer to become familiar with one development system rather than trying to cover everything. I try to keep the Forth code quite generic, to facilitate translation into other dialects, or use assembler. Since (I hope) this column is also read by people who develop in other languages, it is also important to stay rather close to the toolbox, which Mach2 happens to do. Combine this with an assembler syntax which conforms to the Motorola syntax, and the code should be easily translatable into C or Pascal as well.

I realize that there are many of you readers out there who do a lot of development in other Forth dialects. As you know, I always welcome contributions by readers to add some variety to this column. So if you have an interesting example in MacForth, Mach2, MasterForth or another Forth, or NEON, by all means write it up and send it to me (directly to my address given in the masthead).

We're hoping to hear from you. Until next month, happy threading.

Listing 1: Switcher background printing example
( Forth background applications under Switcher )
( Feb 1987 J. Langowski / MacTutor )
( raw printing example adopted from Mach2 example disk )
( for background printing under Switcher )

only forth also assembler also mac 
HEX

( =============== File System Equates ============= )


1CONSTANT fsRdPerm ( read-only)
2CONSTANT fsWrPerm ( write-only)
3CONSTANT fsRdWrPerm ( read-write)

0CONSTANT fsAtMark
1CONSTANT fsFromStart
2CONSTANT fsFromLEOF
3CONSTANT fsFromMark

3CONSTANT stdFile

0CONSTANT    rGood
6CONSTANT    rVolume
ACONSTANT    rName

CCONSTANT ioCompletion
10 CONSTANT ioResult
12 CONSTANT ioFileName
16 CONSTANT ioVRefNum
18 CONSTANT ioRefNum
1A CONSTANT ioFileType
1B CONSTANT ioPermssn
1C CONSTANT ioMisc
20 CONSTANT ioBuffer
24 CONSTANT ioReqCount
28 CONSTANT ioActCount
2C CONSTANT ioPosMode
2E CONSTANT ioPosOffset

FFD9  CONSTANT PastEOF 
 ( error code -39. used in file read operations )  
DECIMAL
HEADER  typeList
 DC.B 'TEXT'

HEADER  sfReplyA
 DC.B 0 ( good )
 DC.B 0 ( copy   pg.25 PackSF )
 DC.B 'TEXT'( fType )
 DC.W 0 ( vRefNum )
 DC.W 0 ( version )
 DCB.B  64,0( fName [string 63] )  
HEADER  PortBOut
 DC.B 5
 DC.B '.Bout'
 
( ====  Various Imagewriter commands ======= )

( Top-Of-Form    CTRL-L   $0C  )
( Software Reset ESC C    $1B $63  )
( LF's after CR'sESC D @ CTRL-@ $1B  $44 $80 $00  )
( No LF's after CR's ESC Z @ CTRL-@ $1B      $5A $80 $00  )
( cancels all unprinted   CTRL-X   $18  )

HEADER AddLFs  
 DC.B $1B
 DC.B $44
 DC.B $80
 DC.B $00
 
HEADER AddTabs 
 DC.B $1B
 DC.B $28
 DC.B '008,016,024,032,040,048,056,064'
 
HEADER FormFeed
 DC.B $0C
 
DECIMAL
LABEL CRCounter
 DS.L 1
 
LABEL LeavePrintFlag
 DS.W 1
 
LABEL MyBuffer
 DS.B 512
 
LABEL FilePBlock
 DS.B 50
 
LABEL PrintPBlock
 DS.B 50
 

( These are the old routines )
( given by Palo Alto Shipping in the Mach 2.0 examples. )
( Since it's all in assembler, we can be sure that no calls )
( are made to the multitasking system which would interfere )
( with our background processing )

( ====  Get File Info ====== )

( Ask for the file to be converted)

CODE GetFInfo
 MOVE.W #80,-(A7)( where.h )
 MOVE.W #50,-(A7)( where.v )
 CLR.L  -(A7)    ( prompt not used )
 CLR.L  -(A7)    ( we don't need filter )
 MOVE.W #1,-(A7) ( look for 1 type )
 PEA    typeList ( pointer to typeList )
 CLR.L  -(A7)    ( no dlgHook )
 PEA    sfReplyA ( push address of reply record)
 MOVE.W #2,-(A7) ( for SFGetFile )
 _Pack3 ( call package )
 LEA    sfReplyA,A0( Point to sfReply )
 TST.B  rGood(A0)(If cancel was clicked, return)
 BEQ.S  @2
 
( Open the source file)

 LEA    filePBlock,A1( Point to param block )
 CLR.L  ioCompletion(A1)  ( No completion routine )
 PEA    rName(A0)( Point to file name )
 MOVE.L (A7)+,ioFileName(A1)
 ( Store pointer in diskPBlock)
 MOVE.W rVolume(A0),ioVRefNum(A1) 
 ( Store vRefNum in diskPBlock)
 CLR.B  ioFileType(A1)  ( Must set file type = 0 )
 MOVE.B #fsRdPerm,ioPermssn(A1) 
 ( Open for read only )
 CLR.L  ioMisc(A1) ( Use system buffer  )
 MOVE.L A1,A0    ( A0 points to diskPBlock  )
 _Open  ( Open the file )
 TST.B  D0
 BNE.S  @1
 MOVE.W 24(A0),22(A0)
 ( move ioRefNum into position)
 MOVE.W #1,44(A0)( ioPosMode from beginning)
 CLR.L  46(A0)   ( ioPosOffset of 0)
 _SetFPos ( this will reset the file)
 LEA  CRCounter,A0
 CLR.L  (A0)
 RTS
@1 MOVE.W #1,-(A7)
 _SysBEEP
@2 _ExitToShell
END-CODE


( ***** Initialize Port B  ***** )

CODE InitPortB ( SerOpenBOut) 
 LEA    PrintPBlock,A0  ( Head of PBBlock)  
 CLR.L  $C(A0)   ( No completion routine )
 LEA    PortBOut,A1( ioNamePtr )
 MOVE.L A1,$12(A0) 
 MOVE.B #0,$1B(A0) ( Ask for all permission )
 MOVE.W #-9,$18(A0)( ioRefNum )
 _Open

( SerRstBOut)  
 LEA    PrintPBlock,A0  ( Head of block )
 MOVE.W #-9,$18(A0)( ioRefNum  )
 MOVE.W #$0008,$1A(A0)  ( Control number )
 MOVE.W #$CC0A,$1C(A0)  
 ( 9600 Baud,8d,2s,no parity )
 _Control
 
( Configure)
 LEA    PrintPBlock,A0
 CLR.L  12(A0)   ( ioCompletion )
 LEA    AddLFs,A1
 MOVE.L A1,32(A0)( ioBuffer  )
 MOVE.L #4,36(A0)( ioReqCount )
 _Write
 LEA    PrintPBlock,A0
 CLR.L  12(A0)   ( ioCompletion )
 LEA    AddTabs,A1
 MOVE.L A1,32(A0)( ioBuffer )
 MOVE.L #34,36(A0) ( ioReqCount )
 _Write
 
( ClrLeaveFlag)  
 LEA    LeavePrintFlag,A0
 CLR.W  (A0)
 RTS
END-CODE
 
 
( ====   Read a block from the file ======= )

CODE ReadBlock
 LEA  FilePBlock,A0
 CLR.L  12(A0)   ( ioCompletion)
 LEA    MyBuffer,A1
 MOVE.L A1,32(A0)( ioBuffer)
 MOVE.L #512,36(A0)( ioReqCount)
 CLR.W  44(A0) ( ioPosMode, from current mark)
 _Read 
 
@3 CMPI.L #512,40(A0)( ioActCount )
 BEQ.S  @2
 
 LEA    LeavePrintFlag,A1
 MOVE.W #$FF,(A1)
@2 RTS
END-CODE


( ***** Put in the page breaks ***** )

( Search thru MyBuffer for CR's -> $0D. 
  In place of every 60th one, I will insert a $0C, 
  which, when sent to an Imagewriter, will generate a form feed.  )

CODE PutPageBreaks
 LEA    FilePBlock,A0
 MOVE.L 40(A0),D0( ioActCount  )
 LEA    MyBuffer,A1
 LEA    CRCounter,A0
 CLR.L  D1
@1 CMPI.B #$0D,0(A1,D1) (  carriage returns )
 BEQ.S  @2
@3 ADDQ.L #1,D1  ( increment address offset )
 SUBQ.L #1,D0  ( decrement byte counter )
 BNE.S  @1
 RTS    ( ***** this is the exit point *** )
 
@2 ADDQ.L #1,(A0)
 CMPI.L #60,(A0)
 BNE.S  @3( if this is the 60th CR )
 
 MOVE.B #$0C,0(A1,D1)( then insert a FF char  )
 CLR.L  (A0)( and reset the crcounter )
 BRA.S  @3
END-CODE
 
 
( *****  Write out a block to port B ***** )

CODE WriteBlock
 LEA  PrintPBlock,A0
 CLR.L  12(A0)   ( ioCompletion)
 LEA  MyBuffer,A1
 MOVE.L A1,32(A0)( ioBuffer)
 LEA  FilePBlock,A1
 MOVE.L 40(A1),36(A0)
 ( move ActCount into ReqCount)
 _Write 
 RTS
END-CODE
 
( *****   Feed the final form feed  ***** )

CODE DoFormFeed
 LEA  PrintPBlock,A0
 CLR.L  12(A0)   ( ioCompletion )
 LEA  FormFeed,A1
 MOVE.L A1,32(A0)( ioBuffer )
 MOVE.L #1,36(A0)( ioReqCount)
 _Write
 RTS
END-CODE
 
( ***** Close the file ***** )

CODE ClFile
 LEA    FilePBlock,A0
 CLR.L  12(A0) ( ioCompletion)
 _Close ( ioRefNum should still be there)
 RTS
END-CODE
 
( *****  Main Thing ***** )
: Print.bkg
 LeavePrintFlag W@ 0=
 IF   ( 5 call sysbeep )  ( for testing )
 ReadBlock( read a block in from file )
 PutPageBreaks ( insert form feeds every 60 lines)
 WriteBlock ( write the block to port B )
 THEN
;

( **** globals )
HEX
282 CONSTANT SwitcherGlobals
286 CONSTANT MemToSwitch
2AA CONSTANT ApplZone
910 CONSTANT CurApName
DECIMAL

( **** Switcher globals )
 0 CONSTANT World0 ( pointer )
 4 CONSTANT World1 ( pointer )
 8 CONSTANT World2 ( pointer )
12 CONSTANT World3 ( pointer )
16 CONSTANT World4 ( pointer )
20 CONSTANT World5 ( pointer )
24 CONSTANT World6 ( pointer )
28 CONSTANT World7 ( pointer )
32 CONSTANT HostTask ( pointer )
36 CONSTANT TheTask( pointer )
40 CONSTANT Flags( word )
50 CONSTANT ArrowEnable ( byte )
51 CONSTANT ClipConvert ( byte )
52 CONSTANT Hibernation ( word )
54 CONSTANT MainZone ( pointer )
58 CONSTANT CoreTable( 6 LongInts )
90 CONSTANT NextTask ( pointer )
96 CONSTANT SwitcherName  ( Str255 )

( **** structure of a world )
 0 CONSTANT PSRPtr ( pointer to PSR )
 4 CONSTANT WorldFlags  ( word )
 6 CONSTANT BkgdProc ( pointer to background routine )
10 CONSTANT SavScrBits  ( pointer to saved Screenbits )
14 CONSTANT DAPtr( pointer to virtual DA )
18 CONSTANT StackHeap( stack & heap starts here... )

( **** Switcher process state record )
 0 CONSTANT Size ( LongInt : PSR size )
 4 CONSTANT myMonkey ( word )
 6 CONSTANT MemTop ( address of end of RAM for this process)
10 CONSTANT BufPtr ( address of end of jump table )
14 CONSTANT StkLowPt ( lowest stack address )
18 CONSTANT HeapEnd( address of top of heap )
22 CONSTANT TheZone( address of current heap zone )
26 CONSTANT ApplLimit( application heap limit )
30 CONSTANT SEvtEnb( 4 bytes )
34 CONSTANT MyApplZone  ( application heap zone )
38 CONSTANT MinStack
72 CONSTANT GrafBegin
332 CONSTANT MyA5( hex 14C )
344 CONSTANT MyName
836 CONSTANT DefVCBPtr  ( pointer to default VCB )

( **** event record structure )
 0 CONSTANT      what     ( Integer )
 2 CONSTANT      message  ( LongInt )
 6 CONSTANT      when     ( LongInt ) 
10 CONSTANT      where    ( Point )
14 CONSTANT      modifiers  ( Integer )

VARIABLE thisApplZone ( for intermediate storage )

( **** definitions )

: =string { aStr bStr | -- flag }
 aStr count 65536 * bStr count rot + swap
 call CmpString 0=
;

: isSwitcher SwitcherGlobals @ 0> ;

: Worlds { | SwGl -- }
 SwitcherGlobals @ -> SwGl 
 SwGl 0> 
 IF
 8 0 DO
 I 4 * SwGl + @ ?dup ( world # i non-NIL ? )
 IF 
 cr ." World No." i . ." : "
 @ @ MyName + count type 
 THEN
 LOOP
 THEN
;

: ActiveWorld# { | SwGl wn -- world number }
 SwitcherGlobals @ -> SwGl
 -1 -> wn 
 SwGl 0> 
 IF
 8 0 DO 
 I 4 * SwGl + @ ?dup ( world # i non-NIL ? )
 IF 
 @ @ MyApplZone + @ ApplZone @ =
 IF I -> wn leave THEN
 THEN
 LOOP
 THEN
 wn
;

( this routine should be called immediately after launch )
( or in any case before a background routine is installed )
: storeApplZone ApplZone @ thisApplZone ! ;

: IamActive thisApplZone @ ApplZone @ = ;

HEADER tempA7    DC.L 0
HEADER myWorld   DC.L 0
HEADER myPSRPtr  DC.L 0

CODE Bkg.glue
 MOVE.W   SR,-(A7)
 MOVEM.L  D0-D7/A0-A6,-(A7)
 LEA    tempA7,A0
 MOVE.L   A7,(A0)
 LEA    myWorld,A0
 MOVE.L   A1,(A0)
 MOVE.L   (A1),A1( PSRPtr -> A1 )
 LEA    myPSRPtr,A0
 MOVE.L   (A1),(A0)
 LEA    SwitcherGlobals,A0
 MOVE.L   (A0),A0
 CMPA.L theTask(A0),A1
 BEQ.S  @1
 ( we're active, so don't execute background )
 MOVE.L   (A1),A1( start of PSR )
 MOVE.L   (A1),A0( size of PSR )
 ADDA.L   A1,A0  
 SUBQ.L   #4,A0  (left stack pointer behind here)
 MOVE.L   (A0),A0
 MOVEM.L  (A0)+,D0-D7/A0-A6  
 ( restore MACH2 register set, except A7 )
 LEA    myPSRPtr,A0
 MOVE.L   (A0),A1   
 ( just in case the background routine needs it )

 JSR    print.bkg

@1 LEA  tempA7,A0
 MOVE.L   (A0),A7
 MOVEM.L  (A7)+,D0-D7/A0-A6
 MOVE.W   (A7)+,SR
 RTS
END-CODE MACH


1000 6000 BACKGROUND printer
 
: initBkg
 IamActive IF
 GetFInfo ( open file to print, exit if cancel )
 ['] Bkg.Glue
 SwitcherGlobals @ ActiveWorld# 4 * + @
 BkgdProc +
 !
 InitPortB
 THEN
;

: rmvBkg
 IamActive IF
 0
 SwitcherGlobals @ ActiveWorld# 4 * + @
 BkgdProc +
 !
 THEN
;

: startme
 storeapplzone
 BEGIN
 initbkg
 BEGIN PAUSE LeavePrintFlag w@ UNTIL
 rmvbkg
 AGAIN
;

: backgo ACTIVATE startme ;

: main  printer BUILD
 printer backgo
;
 
(  turnkey main backprint 
 would now create the background printing application. )
 
AAPL
$111.78
Apple Inc.
-0.87
MSFT
$47.66
Microsoft Corpora
+0.14
GOOG
$516.35
Google Inc.
+5.25

MacTech Search:
Community Search:

Software Updates via MacUpdate

NeoOffice 2014.6 - Mac-tailored, OpenOff...
NeoOffice is a complete office suite for OS X. With NeoOffice, users can view, edit, and save OpenOffice documents, PDF files, and most Microsoft Word, Excel, and PowerPoint documents. NeoOffice 3.x... Read more
LibreOffice 4.3.5.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
CleanApp 5.0.0 Beta 5 - Application dein...
CleanApp is an application deinstaller and archiver.... Your hard drive gets fuller day by day, but do you know why? CleanApp 5 provides you with insights how to reclaim disk space. There are... Read more
Monolingual 1.6.2 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least... Read more
NetShade 6.1 - Browse privately using an...
NetShade is an Internet security tool that conceals your IP address on the web. NetShade routes your Web connection through either a public anonymous proxy server, or one of NetShade's own dedicated... Read more
calibre 2.13 - Complete e-library manage...
Calibre is a complete e-book library manager. Organize your collection, convert your books to multiple formats, and sync with all of your devices. Let Calibre be your multi-tasking digital librarian... Read more
Mellel 3.3.7 - Powerful word processor w...
Mellel is the leading word processor for OS X and has been widely considered the industry standard since its inception. Mellel focuses on writers and scholars for technical writing and multilingual... Read more
ScreenFlow 5.0.1 - Create screen recordi...
Save 10% with the exclusive MacUpdate coupon code: AFMacUpdate10 Buy now! ScreenFlow is powerful, easy-to-use screencasting software for the Mac. With ScreenFlow you can record the contents of your... Read more
Simon 4.0 - Monitor changes and crashes...
Simon monitors websites and alerts you of crashes and changes. Select pages to monitor, choose your alert options, and customize your settings. Simon does the rest. Keep a watchful eye on your... Read more
BBEdit 11.0.2 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more

Latest Forum Discussions

See All

Galaxy Trucker Pocket (Games)
Galaxy Trucker Pocket 1.0.8 Device: iOS iPhone Category: Games Price: $2.99, Version: 1.0.8 (iTunes) Description: Galaxy Truckers Wanted!================================================================= (5/5) "Galaxy Trucker isn’t... | Read more »
Make your own Tribez Figures (and More)...
Make your own Tribez Figures (and More) with Toyze Posted by Jessica Fisher on December 19th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
So Many Holiday iOS Sales Oh My Goodness...
The holiday season is in full-swing, which means a whole lot of iOS apps and games are going on sale. A bunch already have, in fact. Naturally this means we’re putting together a hand-picked list of the best discounts and sales we can find in order... | Read more »
It’s Bird vs. Bird in the New PvP Mode f...
It’s Bird vs. Bird in the New PvP Mode for Angry Birds Epic Posted by Jessica Fisher on December 19th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Telltale Games and Mojang Announce Minec...
Telltale Games and Mojang Announce Minecraft: Story Mode – A Telltale Games Series Posted by Jessica Fisher on December 19th, 2014 [ permalink ] | Read more »
WarChest and Splash Damage Annouce Their...
WarChest and Splash Damage Annouce Their New Game: Tempo Posted by Jessica Fisher on December 19th, 2014 [ permalink ] WarChest Ltd and Splash Damage Ltd are teaming up again to work | Read more »
BulkyPix Celebrates its 6th Anniversary...
BulkyPix Celebrates its 6th Anniversary with a Bunch of Free Games Posted by Jessica Fisher on December 19th, 2014 [ permalink ] BulkyPix has | Read more »
Indulge in Japanese cuisine in Cooking F...
Indulge in Japanese cuisine in Cooking Fever’s new sushi-themed update Posted by Simon Reed on December 19th, 2014 [ permalink ] Lithuanian developer Nordcurrent has yet again updated its restaurant simulat | Read more »
Badland Daydream Level Pack Arrives to C...
Badland Daydream Level Pack Arrives to Celebrate 20 Million Downloads Posted by Ellis Spice on December 19th, 2014 [ permalink ] | Read more »
Far Cry 4, Assassin’s Creed Unity, Desti...
Far Cry 4, Assassin’s Creed Unity, Destiny, and Beyond – AppSpy Takes a Look at AAA Companion Apps Posted by Rob Rich on December 19th, 2014 [ permalink ] These day | Read more »

Price Scanner via MacPrices.net

Holiday sale: 13-inch 128GB MacBook Air for $...
 Best Buy has the 2014 13-inch 1.4GHz 128GB MacBook Air on sale for $849.99, or $150 off MSRP, on their online store. Choose free home shipping or free local store pickup (if available). Price valid... Read more
13-inch 2.6GHz Retina MacBook Pro on sale for...
Best Buy has lowered their price on the 2014 13″ 2.6GHz/128GB Retina MacBook Pro to $1149.99 on their online store for a limited time. That’s $150 off MSRP and the lowest price available for this... Read more
Kodak Returns to CES With New Consumer Produ...
Former photography colossus Kodak is returning to CES for the first time in three years where the Kodak booth (#21818 South Hall 1) will showcase a wide range of innovative, imaging-related products... Read more
Invaluable Launches New Eponymously -Named A...
Invaluable, the world’s largest online live auction marketplace, hhas announced the official launch of the Invaluable app for iPad, now available for download in the iTunes App Store. Invaluable... Read more
IDC Reveals Worldwide Mobile Enterprise Appli...
International Data Corporation (IDC) last week hosted the IDC FutureScape: Worldwide Mobile Enterprise Applications and Solutions 2015 Predictions Web conference. The session provided organizations... Read more
Hello Vino Wine App Launches “Safe Ride Home”...
Hello Vino has announced addition of a new “Get a Safe Ride Home” feature in its Food & Drink app with a direct connection to Uber, the technology platform that connects users with rides. The... Read more
DEVON-technologies Releases DEVONthink To Go...
Coeur d’Alene, Idaho based DEVON-technologies, LLC has updated DEVONthink To Go, its mobile companion to DEVONthink, to version 1.5. The update includes an iOS 8 extension, compatibility with the... Read more
The Apple Store offering free next-day shippi...
The Apple Store is now offering free next-day shipping on all in stock items if ordered before 12/23/14 at 10:00am PT. Local store pickup is also available within an hour of ordering for any in stock... Read more
It’s 1992 Again At Sony Pictures, Except For...
Techcrunch’s John Biggs interviewed a Sony Pictures Entertainment (SPE) employee, who quite understandably wished to remain anonymous, regarding post-hack conditions in SPE’s L.A office, explaining “... Read more
OtterBox Defender Series Case For iPad mini 3...
With their innovative Touch ID technology and ultrathin profile, the latest tranche of Apple iPads are more desirable than ever, and OtterBox has just announced the Defender Series custom-engineered... Read more

Jobs Board

*Apple* Store Leader Program (US) - Apple, I...
…Summary Learn and grow as you explore the art of leadership at the Apple Store. You'll master our retail business inside and out through training, hands-on experience, Read more
Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.