|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: $E000-$FFFF - Kernal Rom, Standard Commodore Jump Table |
| 4 | +--- |
| 5 | +# $E000-$FFFF - Kernal Rom, Standard Commodore Jump Table |
| 6 | + |
| 7 | +# Kernal ROM |
| 8 | + |
| 9 | +## 65363 $FF53 JBOOT_CALL <a name="FF53"></a> |
| 10 | +It's an entry point for the Kernal BOOT_CALL routine at $F890 which attempts to load and execute the boot sector from an auto-boot disk in the given drive and device. The BOOT protocol is as follows: |
| 11 | + |
| 12 | +* Close all open files on boot device. |
| 13 | +* Read track 1 sector 0 into TBUFFR ($B00). |
| 14 | +* Check for auto-boot header, RTS if not. |
| 15 | +* If (blk# > 0), BLOCK READ sequential sectors into RAM at given (adrl, adrh, bank) location. |
| 16 | +* If LEN(filename) > 0, LOAD file into RAM-0 (normal load). |
| 17 | +* JSR to user code at location C above. |
| 18 | + |
| 19 | +On any error, the BOOT operation is aborted and the UI command is issued to the disk. A return may or may not be made to the caller depending upon the completion status and the BOOTed code. The BOOT sector has the following layout: |
| 20 | + |
| 21 | +|$00|$01|$02|$03|$04|$05|$06||A||B|C| |
| 22 | +|-|-|-|-|-|-|-|-|-|-|-|-| |
| 23 | +|C|B|M|adrl|adrh|bank|blk#|title|0|filename|0|code| |
| 24 | + |
| 25 | +<pre> |
| 26 | +where: A = $07 + LEN(title) |
| 27 | + B = A + LEN(filename) |
| 28 | + C = B + 1 |
| 29 | +</pre> |
| 30 | + |
| 31 | +The following examples illustrate the flexibility of this layout. This loads and runs a BASIC program: |
| 32 | + |
| 33 | +<pre> |
| 34 | +$00 -> "CBM" |
| 35 | +$03 -> $00, $00, $00, $00 // no other BOOT sector |
| 36 | +$07 -> "NAME",$00 // message "NAME" |
| 37 | +$0C -> $00 // no filename |
| 38 | +$0D -> // code |
| 39 | + $A2, $13, // LDX #$13 |
| 40 | + $A0, $0B, // LDY #$0B |
| 41 | + $4C, $A5, $AF // JMP $AFA5 (J_EXECUTE_A_LINE) |
| 42 | +$14 -> RUN"PROGRAM" // data (BASIC statement) |
| 43 | +$20 -> $00 |
| 44 | +</pre> |
| 45 | + |
| 46 | +This results in the message Booting NAME... being displayed and, utilizing a C128 BASIC jump table entry that finds and executes a BASIC statement, loads and runs the BASIC program named "PROGRAM". The same header can be used to load and execute a binary (machine code) program by simply changing RUN to BOOT. |
| 47 | + |
| 48 | +While the file auto-load feature of the boot header could be used to load binary files simply by furnishing a filename, to execute it you must know the starting address and JMP to it. BASIC's BOOT command does that, and allows a more generic mechanism. In the next example, a menu is displayed and you are asked to select the operating mode. Nothing else is loaded in this "configure"-type header: |
| 49 | + |
| 50 | +<pre> |
| 51 | +$00 -> "CBM" |
| 52 | +$03 -> $00, $00, $00, $00 // no other BOOT sector |
| 53 | +$07 -> $00 // no message |
| 54 | +$0C -> $00 // no filename |
| 55 | +$0D -> // code |
| 56 | + $20, $7D, $FF, // JSR $FF7D (JPRIMM) |
| 57 | + $0D, $53, $45, $4C, $45, // String start |
| 58 | + $43, $54, $20, $4D, $4F, |
| 59 | + $44, $45, $3A, $0D, $0D, |
| 60 | + $20, $31, $2E, $20, $43, |
| 61 | + $36, $34, $20, $20, $42, |
| 62 | + $41, $53, $49, $43, $0D, |
| 63 | + $20, $32, $2E, $20, $43, |
| 64 | + $31, $32, $38, $20, $42, |
| 65 | + $41, $53, $49, $43, $0D, |
| 66 | + $20, $33, $2E, $20, $43, |
| 67 | + $31, $32, $38, $20, $4D, |
| 68 | + $4F, $4E, $49, $54, $4F, |
| 69 | + $52, $0D, $0D, <b>$00</b>, // String ends with $0D |
| 70 | + $20, $E4, $FF, $C9, $31, |
| 71 | + $D0, $03, $4C, $4D, $FF, |
| 72 | + $C9, $32, $D0, $03, $4C, |
| 73 | + $03, $40, $C9, $33, $D0, |
| 74 | + $EB, $4C, $00, $B0 |
| 75 | +</pre> |
| 76 | + |
| 77 | +Starting from $0D, the first three bytes stands for |
| 78 | + |
| 79 | +<pre> |
| 80 | +JSR $FF7D |
| 81 | +</pre> |
| 82 | + |
| 83 | +which is a jump to $FF7D (JPRIMM). It prints on screen the |
| 84 | +string of character codes immediately following the JSR. |
| 85 | + |
| 86 | +So, the code above shows this message and waits for a key press: |
| 87 | + |
| 88 | +<pre> |
| 89 | +SELECT MODE: |
| 90 | + |
| 91 | + 1. C64 BASIC |
| 92 | + 2. C128 BASIC |
| 93 | + 3. C128 MONITOR |
| 94 | +</pre> |
| 95 | + |
| 96 | +The code after the string (starting with $20 after the $00 in bold): |
| 97 | + |
| 98 | +<pre> |
| 99 | +0000 20 E4 FF JSR $FFE4 |
| 100 | +0003 C9 31 CMP #$31 // Key code 1 |
| 101 | +0005 D0 03 BNE $000A (*+3) |
| 102 | +0007 4C 4D FF JMP $FF4D // Jump to JC64_MODE |
| 103 | +000A C9 32 CMP #$32 // Key code 2 |
| 104 | +000C D0 03 BNE $0011 (*+3) |
| 105 | +000E 4C 03 40 JMP $4003 // Jump to JSOFT_RESET |
| 106 | +0011 C9 33 CMP #$33 // Key code 3 |
| 107 | +0013 D0 EB BNE $0000 (*-15) |
| 108 | +0015 4C 00 B0 JMP $B000 // Jump to JMONINIT |
| 109 | +</pre> |
| 110 | + |
| 111 | +The loading of sequential sectors is designed primarily for specialized applications (such as CP/M or games) that do not need a disk directory entry. |
0 commit comments