DOSWARMSTART.txt

(95 KB) Pobierz
******************************************************************
*                                                                *
*                    DOS's warmstart routine                     *
*                                                                *
*----------------------------------------------------------------*
*                                                                *
*     The DOS cold- and warmstart routines represent the focal   *
* points from which DOS begins processing information.  It       *
* therefore seems logical that the novice should launch his trek *
* into DOS from these routines.  However, the cold- and warm-    *
* start routines are difficult to understand because:            *
*     1) Program execution bounces back and forth between DOS,   *
*        BASIC and monitor ROM.                                  *
*     2) Both the cold- and warmstart routines are riddled with  *
*        references to an obscure version of Applesoft that most *
*        people don't even realize exits.                        *
*     3) The DOS coldstart routine uses part of the warmstart    *
*        routine.  In order to distinguish between these two     *
*        execution patterns, it is important to pay close        *
*        attention to the condition of the status register and   *
*        several different flags.                                *
*                                                                *
* ABOUT PROGRAM EXECUTION AND THE I/O HOOKS.                     *
*     The interconnection between DOS, BASIC and monitor ROM is  *
* accomplished by DOS's control over the input (KSW, $36,$37)    *
* and output (CSW, $38,$39) hooks.  (These hooks are collectively*
* referred to as the I/O hooks, the KSW/CSW hooks or the         *
* keyboard/character switches.)  In order to understand how DOS  *
* controls these hooks, lets first see what happens when DOS is  *
* NOT present:                                                   *
* - Ordinarily, data output flows through a monitor ROM routine  *
*   called "COUT" ($FDED).  COUT contains a "JMP (CSW)"instruc-  *
*   tion.  CSW points to the address of the peripheral to which  *
*   output should be sent.  For instance, if output is destined  *
*   for the screen, CSW points to a monitor routine called       *
*   "COUT1" ($FDF0).  After COUT1 does some homework, it sends   *
*   the character to the screen.  Similarly, input normally      *
*   flows through the "RDKEY" ($FD0C) routine located in monitor *
*   ROM.  This routine contains a "JMP (KSW)" instruction.  KSW  *
*   normally points to the monitor routine known as "KEYIN"      *
*   ($FD1D).  KEYIN accepts input from the keyboard.             *
* Now, let's put DOS back into the picture:                      *
* - When a coldstart is done, the INITIOHK ($A851) routine in    *
*   DOS initializes the I/O hooks to point to DOS's own input    *
*   (INPTINCP, $9E81) and output (OPUTINCP, $9E8D) handlers.     *
*   Therefore, when DOS is up, any routine that requests input   *
*   or output, must go through DOS's own I/O handlers to be      *
*   screened.  The I/O handlers decide whether the input is to   *
*   be taken from the keyboard or the disk and whether output    *
*   should be sent to the screen, the disk, the printer or any   *
*   other output device.  For example, let's assume that we are  *
*   running a BASIC program that calls for a character to be     *
*   printed on the screen.  When BASIC's "PRINT" statement is    *
*   encountered, execution flows to the "JMP (CSW)" instruction  *
*   in the monitor at COUT ($FDED).   Because the output hook    *
*   (CSW) points to DOS's output handler, execution flows to     *
*   OPUTINCP ($9E8D).  OPUTINCP looks at the command line and    *
*   discovers that the character is to be sent to the screen.    *
*   It then calls PREP4DOS ($9ED1) to repoint the output hook at *
*   the true output handler (COUT1, $FDF0) and JSR's to COUT1.   *
*   After COUT1 puts the character on the screen, execution      *
*   returns to DOS.  DOS does some homework and then execution   *
*   flows back to BASIC.  Before DOS is exited however, it again *
*   calls the INITIOHK routine to reset the I/O hooks to point   *
*   at DOS'S own I/O handlers.                                   *
* In otherwords, DOS acts like and omnipotent peeping Tom.  He   *
* screens all input and output and then takes whatever action he *
* deems appropriate.                                             *
*                                                                *
* PARLEZ VOUS APPLESOFT?                                         *
*     The first three models of Apple II computers were based    *
* on two different versions of ROM.  Old Apple II's contained    *
* Integer basic in ROM whereas the newer Apple II+/IIe's were    *
* built with Applesoft basic in ROM.  In order to accommodate    *
* both types of machines and their hapless programmers, Apple    *
* made the DOS Master disk bilingual.  When you boot with this   *
* disk, DOS determines what kind of machine you're using and     *
* what language to load on the RAM card.  For example, if you    *
* are using a II+ or IIe, the sytem master disk automatically    *
* runs the "HELLO" program.  The "HELLO" program then loads a    *
* file called "INTBASIC" onto the RAM card.  (INTBASIC is a      *
* binary file which represents an image of the Integer basic     *
* language.)  Similarly, if you're using an old Apple II         *
* machine, the sytem master will run an Integer program          *
* (confusingly called, "APPLESOFT") which loads a file called    *
* "FPBASIC" onto the language card.  (FPBASIC is a binary file   *
* which represents an image of Applesoft Floating Point Basic.)  *
* Because this ram-resident version of Applesoft has gone        *
* through several evolutionary stages, it is referred to in the  *
* literature by several different names:  disk-based Applesoft,  *
* Applesoft RAM, cassette Applesoft, RAM Applesoft and A(RAM).   *
*     Therefore, because the language card can contain a         *
* different language than the motherboard, the cold- and warm-   *
* start routines must determine not only which language is       *
* presently active, but also if the active language is on the    *
* card or motherboard.                                           *
*                                                                *
* FLAGS AND EXECUTION PATTERNS.                                  *
*     The status register is used to distinguish between the     *
* cold- and warmstart execution patterns.  In some cases (ex.    *
* CMWRMCLD,$9DD1), the carry flag is used to determine if a      *
* cold- or warmstart is being executed.  However, in other cases *
* (ex.  OPUTINCP, $9E8D and INPTINCPT, $9E81), a specific memory *
* location is used as a flag.  Because several flags appear to   *
* have similar connotations but are set and tested at different  *
* times, one must keep close tabs on the different flag          *
* conditions:                                                    *
*     (AA51)                                                     *
*     CONDNFLG = I/O condition flag.                             *
*              = $00 = warmstart.                                *
*              = $01 = reading a file.                           *
*              = $C0 = using A(RAM).                             *
*     (AA52)                                                     *
*     OPUTCOND = character output condition flag.                *
*              = $00 = evaluate start of input line.             *
*              = $01 = got a DOS control character, so collect   *
*                      the DOS command.                          *
*              = $02 = not a DOS command, so just print a <cr>   *
*                      and return to the caller.                 *
*              = $03 = get ready to process an INPUT statement.  *
*              = $04 = writing data to the disk.                 *
*              = $05 = evaluate the first char of the data line  *
*                      read from the disk.                       *
*              = $06 = ignore a question mark prompt & reset to  *
*                      condition 0.                              *
*     (AAB3)                                                     *
*     EXECFLAG = non-zero value (actually first char of the      *
*                name of the exec file) = presently EXECing.     *
*              = $00 = not EXECing a file.                       *
*     (AAB6)                                                     *
*     ACTBSFLG = active basic flag.                              *
*              = $00 = integer.                                  *
*              = $40 = A(ROM).                                   *
*              = $80 = A(RAM).                                   *
*     (AAB7)                                                     *
*     RUNTRUPT = run intercept flag.                             *
*              = $00 = RUN command was NOT interrupted.          *
*              = $40 = RUN command was interrupted to load       *
*                      a file when using A(ROM).                 *
*              = $80 = RUN command was interrupted to load       *
*                      a file when using A(RAM).                 *
*     (E000)                                                     *
*     BASICCLD = BASIC's coldstart routine.                      *
*                (First byte distinguishes type of ROM used.)    *
*              = $20 = opcode for "JSR", denotes Integer.        *
*              = $40 = opcode for "JMP", denotes A(ROM).         *
*                                                     ...
Zgłoś jeśli naruszono regulamin