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
$97.19
Apple Inc.
+2.47
MSFT
$44.87
Microsoft Corpora
+0.04
GOOG
$595.98
Google Inc.
+1.24

MacTech Search:
Community Search:

Software Updates via MacUpdate

Firefox 31.0 - Fast, safe Web browser. (...
Firefox for Mac offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals... Read more
Little Snitch 3.3.3 - Alerts you to outg...
Little Snitch gives you control over your private outgoing data. Track background activityAs soon as your computer connects to the Internet, applications often have permission to send any... Read more
Thunderbird 31.0 - Email client from Moz...
As of July 2012, Thunderbird has transitioned to a new governance model, with new features being developed by the broader free software and open source community, and security fixes and improvements... Read more
Together 3.2 - Store and organize all of...
Together helps you organize your Mac, giving you the ability to store, edit and preview your files in a single clean, uncluttered interface. Smart storage. With simple drag-and-drop functionality,... Read more
Cyberduck 4.5 - FTP and SFTP browser. (F...
Cyberduck is a robust FTP/FTP-TLS/SFTP browser for the Mac whose lack of visual clutter and cleverly intuitive features make it easy to use. Support for external editors and system technologies such... Read more
iExplorer 3.4 - View and transfer all th...
iExplorer is an iPhone browser for Mac lets you view the files on your iOS device. By using a drag and drop interface, you can quickly copy files and folders between your Mac and your iPhone or... Read more
Airmail 1.4 - Powerful, minimal email cl...
Airmail is a powerful, minimal mail client.It was designed to retain the same experience with a single or multiple accounts and provide a quick, modern and easy-to-use user experience. Airmail... Read more
Macs Fan Control 1.1.12 - Monitor and co...
Macs Fan Control allows you to monitor and control almost any aspect of your computer's fans, with support for controlling fan speed, temperature sensors pane, menu-bar icon, and autostart with... Read more
A Better Finder Rename 9.37 - File, phot...
A Better Finder Rename is the most complete renaming solution available on the market today. That's why, since 1996, tens of thousands of hobbyists, professionals and businesses depend on A Better... Read more
MacBook Air EFI Firmware Update 2.9 - Fo...
MacBook Air EFI Firmware Update is recommended for MacBook Air (Mid 2011) models. This update addresses an issue where systems may take longer to wake from sleep than expected and fixes a rare issue... Read more

Latest Forum Discussions

See All

Ex-Angry Birds Developers Release Monsu...
Ex-Angry Birds Developers Release Monsu Teaser Trailer Posted by Jennifer Allen on July 23rd, 2014 [ permalink ] Finnish developer Boomlagoon has released a teaser trailer of their forthcoming side-scrolling action platformer, | Read more »
Lots of New Modes Have Been Added to Can...
Lots of New Modes Have Been Added to Canabalt Posted by Jennifer Allen on July 23rd, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Stronghold 3: The Campaigns Review
Stronghold 3: The Campaigns Review By Jennifer Allen on July 23rd, 2014 Our Rating: :: DULL STRATEGIZINGiPad Only App - Designed for the iPad A cumbersome strategy game, Stronghold 3: The Campaigns has a few too many issues to... | Read more »
Table Tennis Touch on Sale for a Limited...
Table Tennis Touch on Sale for a Limited Time Posted by Jessica Fisher on July 23rd, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Secret Files Tunguska Review
Secret Files Tunguska Review By Jennifer Allen on July 23rd, 2014 Our Rating: :: CONSPIRACY-LITTERED ADVENTURINGUniversal App - Designed for iPhone and iPad Offering traditional adventuring with no fear of in-app purchases, Secret... | Read more »
Celebrate Summer With a Cat in the Hat L...
Celebrate Summer With a Cat in the Hat Learning Library Sale Posted by Ellis Spice on July 22nd, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Dragon Raiders Review
Dragon Raiders Review By Nadia Oxford on July 22nd, 2014 Our Rating: :: RUN, DRAGON, RUNUniversal App - Designed for iPhone and iPad Dragon Raiders is rough and scaly in some parts, but overall it’s an enjoyable level-based running... | Read more »
MyTaskList Review
MyTaskList Review By Jennifer Allen on July 22nd, 2014 Our Rating: :: EFFECTIVE IF PLAINUniversal App - Designed for iPhone and iPad It’s not the most stylish of task management apps, but MyTaskList has all the features you could... | Read more »
FlyCraft Herbie: Crazy Machines Review
FlyCraft Herbie: Crazy Machines Review By Jennifer Allen on July 22nd, 2014 Our Rating: :: TRICKY FLYINGUniversal App - Designed for iPhone and iPad A tough game of careful thrusting and navigation, FlyCraft Herbie: Crazy Machines... | Read more »
MTN Review
MTN Review By Jessica Fisher on July 22nd, 2014 Our Rating: :: ADORABLE, SERENE, AND AMUSINGUniversal App - Designed for iPhone and iPad MTN is an adorable, talking pet mountain that is less game and more zen garden.   | Read more »

Price Scanner via MacPrices.net

With The Apple/IBM Alliance, Is The iPad Now...
Almost since the iPad was rolled out in 2010, and especially after Apple made a 128 GB storage configuration available in 2012, there’s been debate over whether the iPad is a serious tool for... Read more
MacBook Airs on sale starting at $799, free s...
B&H Photo has the new 2014 MacBook Airs on sale for up to $100 off MSRP for a limited time. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels... Read more
Apple 27″ Thunderbolt Display (refurbished) a...
The Apple Store has Apple Certified Refurbished 27″ Thunderbolt Displays available for $799 including free shipping. That’s $200 off the cost of new models. Read more
WaterField Designs Unveils Cycling Ride Pouch...
High end computer case and bag maker WaterField Designs of San Francisco now enters the cycling market with the introduction of the Cycling Ride Pouch – an upscale toolkit with a scratch-free iPhone... Read more
Kingston Digital Ships Large Capacity Near 1T...
Kingston Digital, Inc., the Flash memory affiliate of Kingston Technology Company, Inc.,has announced its latest addition to the SSDNow V300 series, the V310. The Kingston SSDNow V310 solid-state... Read more
Apple’s Fiscal Third Quarter Results; Record...
Apple has announced financial results for its fiscal 2014 third quarter ended June 28, 2014, racking up quarterly revenue of $37.4 billion and quarterly net profit of $7.7 billion, or $1.28 per... Read more
15-inch 2.0GHz MacBook Pro Retina on sale for...
B&H Photo has the 15″ 2.0GHz Retina MacBook Pro on sale for $1829 including free shipping plus NY sales tax only. Their price is $170 off MSRP. B&H will also include free copies of Parallels... Read more
Apple restocks refurbished Mac minis for up t...
The Apple Store has restocked Apple Certified Refurbished Mac minis for up to $150 off the cost of new models. Apple’s one-year warranty is included with each mini, and shipping is free: - 2.5GHz Mac... Read more
Twelve South HiRise For MacBook – Height-Adju...
If you use your MacBook as a workhorse desktop substitute, as many of us do, a laptop stand combined with an external keyboard and pointing device are pretty much obligatory if you want to avoid... Read more
Why The Mac Was Not Included In The Apple/IBM...
TUAW’s Yoni Heisler cites Fredrick Paul of Network World whoi blogged last week that the Mac’s conspicuous absence from Apple and IBM’s landmark partnership agreement represents a huge squandered... Read more

Jobs Board

Sr Software Lead Engineer, *Apple* Online S...
**Job Summary** The Apple Online Store is looking for a highly motivated, entrepreneurial senior software engineer to join the Apple Online Store Publishing Systems Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Sr. Product Leader, *Apple* Store Apps - Ap...
**Job Summary** Imagine what you could do here. At Apple , great ideas have a way of becoming great products, services, and customer experiences very quickly. Bring Read more
Sr Software Lead Engineer, *Apple* Online S...
Sr Software Lead Engineer, Apple Online Store Publishing Systems Keywords: Company: Apple Job Code: E3PCAK8MgYYkw Location (City or ZIP): Santa Clara Status: Full 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
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.