
 1010         .TF B.MEYER.1
 1020  *SAVE S.MEYER.1
 1030  *--------------------------------
 1040  *   SETUP AND HANDLER ROUTINES
 1050  *   TO ALLOW INTERNAL JSRS AND
 1060  *   JMPS IN A RELOCATABLE MACHINE
 1070  *   LANGUAGE ROUTINE
 1080   
 1090  *   BY PETER MEYER, 11/3/82
 1100  *--------------------------------
 1110  *   LOCATIONS
 1120   
 1130  INDEX      .EQ $5E,5F
 1140  STACK      .EQ $100 - $1FF
 1150  VECTOR     .EQ $3F5 - $3F7
 1160  *--------------------------------
 1170  *   MACRO DEFINITIONS
 1180    
 1190         .MA JSR
 1200  :1     LDA #]1-:1-7
 1210         LDY /]1-:1-7
 1220         TSX
 1230         JSR VECTOR
 1240         .EM
 1250   
 1260         .MA JMP
 1270  :1     LDA #]1-:1-7
 1280         LDY /]1-:1-7
 1290         TSX
 1300         JSR $FF58
 1310         JMP VECTOR
 1320         .EM
 1330  *--------------------------------
 1340  *   HEADER PART 1
 1350   
 1360  SETUP  JSR $FF58    FIND OURSELVES
 1370         TSX
 1380         CLC
 1390         LDA #HANDLER-SETUP-2
 1400         .DA #$7D,STACK-1   FORCE ABS,X MODE
 1410         STA VECTOR+1
 1420   
 1430         LDA /HANDLER-SETUP-2
 1440         ADC STACK,X
 1450         STA VECTOR+2
 1460   
 1470         LDA #$4C     "JMP"
 1480         STA VECTOR
 1490         BNE MAIN.ROUTINE   ALWAYS
 1500  *--------------------------------
 1510  *   HEADER PART 2
 1520   
 1530  HANDLER
 1540   
 1550  *   ON ENTRY A,Y HOLD OFFSET
 1560  *   FOR JMP OR JSR FROM ROUTINE
 1570  *   X IS STACK POINTER FROM BEFORE LAST JSR
 1580   
 1590         CLC
 1600         .DA #$7D,STACK-1   FORCE ABS,X MODE
 1610         STA INDEX
 1620         TYA
 1630         ADC STACK,X
 1640         STA INDEX+1
 1650         JMP (INDEX)
 1660  *--------------------------------
 1670  *      MAIN ROUTINE, FOR EXAMPLE
 1680  *--------------------------------
 1690  MSG    .EQ $06 AND $07
 1700  CH     .EQ $24
 1710  CV     .EQ $25
 1720  INVFLG .EQ $32
 1730  COUNT  .EQ $3C
 1740  SETTXT .EQ $FB39
 1750  VTABZ  .EQ $FC24
 1760  HOME   .EQ $FC58
 1770  COUT   .EQ $FDED
 1780  *--------------------------------
 1790  MAIN.ROUTINE
 1800         JSR SETTXT
 1810         JSR HOME
 1820  MAIN.LOOP
 1830         LDA #190
 1840         STA COUNT
 1850  .1     LDA #AALQT-PRINT.MESSAGE
 1860         STA MSG
 1870         LDA /AALQT-PRINT.MESSAGE
 1880         STA MSG+1
 1890         >JSR PRINT.MESSAGE
 1900         DEC COUNT
 1910         BNE .1
 1920         LDA #LONGQT-PRINT.MESSAGE
 1930         STA MSG
 1940         LDA /LONGQT-PRINT.MESSAGE
 1950         STA MSG+1
 1960         >JSR PRINT.MESSAGE
 1970         >JMP FORWRD
 1980   
 1990  *--------------------------------
 2000  PRINT.MESSAGE
 2010         CLC
 2020         LDA MSG      CHANGE RELATIVE ADDRESS TO
 2030         ADC INDEX    AN ABSOLUTE ADDRESS, BY
 2040         STA MSG      ADDING THE OFFSET
 2050         LDA MSG+1
 2060         ADC INDEX+1
 2070         STA MSG+1
 2080         LDY #0       POINT AT FIRST CHAR OF MSG
 2090  .1     LDA (MSG),Y  GET NEXT CHAR OF MSG
 2100         BMI .2       IT IS LAST CHAR
 2110         ORA #$80     MAKE APPLE VIDEO FORM
 2120         JSR COUT     PRINT IT
 2130         INY          ADVANCE POINTER
 2140         BNE .1       ...ALWAYS
 2150  .2     JMP COUT     PRINT AND RETURN
 2160  *--------------------------------
 2170  *   256 BYTES TO JUMP OVER, JUST FOR ILLUSTRATION
 2180   
 2190         .BS $100
 2200  *--------------------------------
 2210  *   TOGGLE INVERSE FLAG, AND HOME CURSOR
 2220   
 2230  FORWRD LDA INVFLG
 2240         EOR #$C0
 2250         STA INVFLG
 2260         LDA #0
 2270         STA CH
 2280         STA CV
 2290         JSR VTABZ
 2300         >JMP MAIN.LOOP
 2310  *--------------------------------
 2320  AALQT  .AT /AAL /
 2330  LONGQT .HS 0D0D
 2340         .AS / A P P L E   A S S E M B L Y   L I N E /
 2350         .HS 0D02
 2360         .AT /  S - C   S O F T W A R E   C O R P .  /

