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
$116.47
Apple Inc.
+0.16
MSFT
$47.98
Microsoft Corpora
-0.72
GOOG
$537.50
Google Inc.
+2.67

MacTech Search:
Community Search:

Software Updates via MacUpdate

Cobook 3.0.7 - Intelligent address book....
Cobook Contacts is an intuitive, engaging address book. Solve the problem of contact management with Cobook Contacts and its simple interface and powerful syncing and integration possibilities.... Read more
StatsBar 1.9 - Monitor system processes...
StatsBar gives you a comprehensive and detailed analysis of the following areas of your Mac: CPU usage Memory usage Disk usage Network and bandwidth usage Battery power and health (MacBooks only)... Read more
Cyberduck 4.6 - 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
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
Evernote 6.0.1 - Create searchable notes...
Evernote allows you to easily capture information in any environment using whatever device or platform you find most convenient, and makes this information accessible and searchable at anytime, from... Read more
calibre 2.11 - 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... Read more
Herald 5.0.1 - Notification plugin for M...
Note: Versions 2.1.3 (for OS X 10.7), 3.0.6 (for OS X 10.8), and 4.0.8 (for OS X 10.9) are no longer supported by the developer. Herald is a notification plugin for Mail.app, Apple's Mac OS X email... Read more
Firetask 3.7 - Innovative task managemen...
Firetask uniquely combines the advantages of classical priority-and-due-date-based task management with GTD. Stay focused and on top of your commitments - Firetask's "Today" view shows all relevant... Read more
TechTool Pro 7.0.6 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
PhotoDesk 3.0.1 - Instagram client for p...
PhotoDesk lets you view, like, comment, and download Instagram pictures/videos! (NO Uploads! / Image Posting! Instagram forbids that! AND you *need* an *existing* Instagram account). But you can do... Read more

Latest Forum Discussions

See All

Ubisoft Gives Everyone Two New Ways to E...
Ubisoft Gives Everyone Two New Ways to Earn In-Game Stuff for Far Cry 4 Posted by Jessica Fisher on November 21st, 2014 [ permalink ] | Read more »
Golfinity – Tips, Tricks, Strategies, an...
Dig this: Would you like to know what we thought of being an infinite golfer? Check out our Golfinity review! Golfinity offers unlimited ways to test your skills at golf. Here are a few ways to make sure your score doesn’t get too high and your... | Read more »
Dark Hearts, The Sequel to Haunting Meli...
Dark Hearts, The Sequel to Haunting Melissa, is Available Now Posted by Jessica Fisher on November 21st, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Meowza! Toyze Brings Talking Tom to Life...
Meowza! | Read more »
Square Enix Announces New Tactical RPG f...
Square Enix Announces New Tactical RPG for Mobile, Heavenstrike Rivals. Posted by Jessica Fisher on November 21st, 2014 [ permalink ] With their epic stories and gorgeous graphics, | Read more »
Quest for Revenge (Games)
Quest for Revenge 1.0.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.0 (iTunes) Description: The great Kingdom of the west has fallen. The gods ignore the prayers of the desperate. A dark warlord has extinguished... | Read more »
Threadz is a New Writing Adventure for Y...
Threadz is a New Writing Adventure for You and Your Friends Posted by Jessica Fisher on November 21st, 2014 [ permalink ] In the tradition of round-robin storytelling, | Read more »
SteelSeries Stratus XL Hardware Review
Made by: SteelSeries Price: $59.99 Hardware/iOS Integration Rating: 4 out of 5 stars Usability Rating: 4.5 out of 5 stars Reuse Value Rating: 4.25 out of 5 stars Build Quality Rating: 4.5 out of 5 stars Overall Rating: 4.31 out of 5 stars | Read more »
ACDSee (Photography)
ACDSee 1.0.0 Device: iOS iPhone Category: Photography Price: $1.99, Version: 1.0.0 (iTunes) Description: Capture, perfect, and share your photos with ACDSee. The ACDSee iPhone app combines an innovative camera, a powerful photo... | Read more »
ProTube for YouTube (Entertainment)
ProTube for YouTube 2.0.2 Device: iOS Universal Category: Entertainment Price: $1.99, Version: 2.0.2 (iTunes) Description: ProTube is the ultimate, fully featured YouTube app. With it's highly polished design, ProTube offers ad-free... | Read more »

Price Scanner via MacPrices.net

Save up to $400 with Apple refurbished 2014 1...
The Apple Store has restocked Apple Certified Refurbished 2014 15″ Retina MacBook Pros for up to $400 off the cost of new models. An Apple one-year warranty is included with each model, and shipping... Read more
New 13-inch 1.4GHz MacBook Air on sale for $8...
 Adorama has the 2014 13″ 1.4GHz/128GB MacBook Air on sale for $899.99 including free shipping plus NY & NJ tax only. Their price is $100 off MSRP. B&H Photo has the 13″ 1.4GHz/128GB MacBook... Read more
Apple Expected to Reverse Nine-Month Tablet S...
Apple and Samsung combined accounted for 62 percent of the nearly 36 million branded tablets shipped in 3Q 2014, according to early vendor shipment share estimates from market intelligence firm ABI... Read more
Stratos: 30 Percent of US Smartphone Owners t...
Stratos, Inc., creator of the Bluetooth Connected Card Platform, has announced results from its 2014 Holiday Mobile Payments Survey. The consumer survey found that nearly one out of three (30 percent... Read more
2014 1.4GHz Mac mini on sale for $449, save $...
 B&H Photo has lowered their price on the new 1.4GHz Mac mini to $449.99 including free shipping plus NY tax only. Their price is $50 off MSRP, and it’s the lowest price available for this new... Read more
Check Apple prices on any device with the iTr...
MacPrices is proud to offer readers a free iOS app (iPhones, iPads, & iPod touch) and Android app (Google Play and Amazon App Store) called iTracx, which allows you to glance at today’s lowest... Read more
64GB iPod touch on sale for $249, save $50
Best Buy has the 64GB iPod touch on sale for $249 on their online store for a limited time. Their price is $50 off MSRP. Choose free shipping or free local store pickup (if available). Sale price for... Read more
15″ 2.2GHz Retina MacBook Pro on sale for $17...
 B&H Photo has the 2014 15″ 2.2GHz Retina MacBook Pro on sale for $1799.99 for a limited time. Shipping is free, and B&H charges NY sales tax only. B&H will also include free copies of... Read more
New Logitech AnyAngle Case/Stand Brings Flexi...
Logitec has announced the newest addition to its suite of tablet products — the Logitech AnyAngle. A protective case with an any-angle stand for iPad Air 2 and all iPad mini models, AnyAngle is the... Read more
Notebook PC Shipments Rise Year-Over-Year as...
According to preliminary results from the upcoming DisplaySearch Quarterly Mobile PC Shipment and Forecast Report, the global notebook PC market grew 10 percent year-over-year in Q3’14 to 49.4... Read more

Jobs Board

*Apple* Solutions Consultant (ASC)- Retail S...
**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
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* Store Leader Program - College Gradu...
Job Description: Job Summary As an Apple Store Leader Program agent, you can continue your education as you major in the art of leadership at the Apple Store. You'll 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
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.