back to project page

CHAIN Disassembly

                   ********************************************************************************
                   * Disassembly of "CHAIN".                                                      *
                   *                                                                              *
                   * This seems to match the program on the DOS 3.3 system master disk.  It works *
                   * with Applesoft in RAM or ROM.                                                *
                   ********************************************************************************
                   MON_CSWL        .eq     $36               ;character output hook (lo)
                   MON_CSWH        .eq     $37               ;character output hook (hi)
                   MON_A1L         .eq     $3c               ;general purpose
                   MON_A2L         .eq     $3e               ;general purpose
                   MON_A4L         .eq     $42               ;general purpose
                   BAS_VARTAB      .eq     $69    {addr/2}   ;pointer to start of Applesoft variables (2b)
                   BAS_ARYTAB      .eq     $6b    {addr/2}   ;pointer to start of Applesoft array space (2b)
                   BAS_STREND      .eq     $6d    {addr/2}   ;pointer to end of numeric storage (2b)
                   BAS_FRETOP      .eq     $6f    {addr/2}   ;pointer to end of string storage (2b)
                   BAS_HIGHDS      .eq     $94    {addr/2}   ;block copy pointer (2b)
                   BAS_HIGHTR      .eq     $96    {addr/2}   ;block copy pointer (2b)
                   BAS_LOWTR       .eq     $9b    {addr/2}   ;general pointer (2b)
                   BAS_FAC         .eq     $9d    {addr/6}   ;floating point accumulator (6b)
                   BAS_FACSIGN     .eq     $a2               ;single byte sign of FAC
                   BAS_PRGEND      .eq     $af    {addr/2}   ;pointer to end of program (2b)
                   BAS_TXTPTR      .eq     $b8    {addr/2}   ;points at next char or token (2b)
                   BAS_REMSTK      .eq     $f8               ;stack pointer saved before each statement
                   DOS_CHARIO      .eq     $03ea             ;jumps to routine that connects DOS KSW/CSW
                   MON_MOVE        .eq     $fe2c             ;move bytes from A1 to A4 until A1=A2
                   MON_SETVID      .eq     $fe93             ;reset char output handler to ROM

                                   .org    $0208
0208: 20 85 03                     jsr     InitCalls         ;set up calls into Applesoft
020b: 20 a6 03                     jsr     GARBAG            ;collect garbage before doing work
020e: a9 07                        lda     #$07
0210: 85 8f                        sta     $8f
0212: a5 69                        lda     BAS_VARTAB
0214: a6 6a                        ldx     BAS_VARTAB+1
0216: 85 9d                        sta     BAS_FAC
0218: 86 9e                        stx     BAS_FAC+1
021a: e4 6c        L021A           cpx     BAS_ARYTAB+1
021c: d0 04                        bne     L0222
021e: c5 6b                        cmp     BAS_ARYTAB
0220: f0 05                        beq     L0227
0222: 20 7e 02     L0222           jsr     L027E
0225: f0 f3                        beq     L021A
0227: 85 9f        L0227           sta     BAS_FAC+2
0229: 86 a0                        stx     BAS_FAC+3
022b: a9 03                        lda     #$03
022d: 85 8f                        sta     $8f
022f: a5 9f        L022F           lda     BAS_FAC+2
0231: a6 a0                        ldx     BAS_FAC+3
0233: e4 6e        L0233           cpx     BAS_STREND+1
0235: d0 07                        bne     L023E
0237: c5 6d                        cmp     BAS_STREND
0239: d0 03                        bne     L023E
023b: 4c e0 02                     jmp     L02E0

023e: 85 9d        L023E           sta     BAS_FAC
0240: 86 9e                        stx     BAS_FAC+1
0242: a0 00                        ldy     #$00
0244: b1 9d                        lda     (BAS_FAC),y
0246: aa                           tax
0247: c8                           iny
0248: b1 9d                        lda     (BAS_FAC),y
024a: 08                           php
024b: c8                           iny
024c: b1 9d                        lda     (BAS_FAC),y
024e: 65 9f                        adc     BAS_FAC+2
0250: 85 9f                        sta     BAS_FAC+2
0252: c8                           iny
0253: b1 9d                        lda     (BAS_FAC),y
0255: 65 a0                        adc     BAS_FAC+3
0257: 85 a0                        sta     BAS_FAC+3
0259: 28                           plp
025a: 10 d3                        bpl     L022F
025c: 8a                           txa
025d: 30 d0                        bmi     L022F
025f: c8                           iny
0260: b1 9d                        lda     (BAS_FAC),y
0262: a0 00                        ldy     #$00
0264: 0a                           asl     A
0265: 69 05                        adc     #$05
0267: 65 9d                        adc     BAS_FAC
0269: 85 9d                        sta     BAS_FAC
026b: 90 02                        bcc     L026F
026d: e6 9e                        inc     BAS_FAC+1
026f: a6 9e        L026F           ldx     BAS_FAC+1
0271: e4 a0        L0271           cpx     BAS_FAC+3
0273: d0 04                        bne     L0279
0275: c5 9f                        cmp     BAS_FAC+2
0277: f0 ba                        beq     L0233
0279: 20 88 02     L0279           jsr     L0288
027c: f0 f3                        beq     L0271
027e: b1 9d        L027E           lda     (BAS_FAC),y
0280: 30 46                        bmi     L02C8
0282: c8                           iny
0283: b1 9d                        lda     (BAS_FAC),y
0285: 10 41                        bpl     L02C8
0287: c8                           iny
0288: b1 9d        L0288           lda     (BAS_FAC),y
028a: f0 3c                        beq     L02C8
028c: c8                           iny
028d: b1 9d                        lda     (BAS_FAC),y
028f: aa                           tax
0290: c8                           iny
0291: b1 9d                        lda     (BAS_FAC),y
0293: 85 9c                        sta     BAS_LOWTR+1
0295: 86 9b                        stx     BAS_LOWTR
0297: c5 b0                        cmp     BAS_PRGEND+1
0299: f0 02                        beq     L029D
029b: b0 2b                        bcs     L02C8
029d: 88           L029D           dey
029e: 88                           dey
029f: b1 9d                        lda     (BAS_FAC),y
02a1: 48                           pha
02a2: 38                           sec
02a3: a5 6f                        lda     BAS_FRETOP
02a5: 85 94                        sta     BAS_HIGHDS
02a7: f1 9d                        sbc     (BAS_FAC),y
02a9: c8                           iny
02aa: 91 9d                        sta     (BAS_FAC),y
02ac: 85 6f                        sta     BAS_FRETOP
02ae: c8                           iny
02af: a5 70                        lda     BAS_FRETOP+1
02b1: 85 95                        sta     BAS_HIGHDS+1
02b3: e9 00                        sbc     #$00
02b5: 91 9d                        sta     (BAS_FAC),y
02b7: 85 70                        sta     BAS_FRETOP+1
02b9: 68                           pla
02ba: 18                           clc
02bb: 65 9b                        adc     BAS_LOWTR
02bd: 85 96                        sta     BAS_HIGHTR
02bf: a5 9c                        lda     BAS_LOWTR+1
02c1: 69 00                        adc     #$00
02c3: 85 97                        sta     BAS_HIGHTR+1
02c5: 20 a9 03                     jsr     BLTU2
02c8: a5 8f        L02C8           lda     $8f
02ca: 18                           clc
02cb: 65 9d                        adc     BAS_FAC
02cd: 85 9d                        sta     BAS_FAC
02cf: 90 02                        bcc     L02D3
02d1: e6 9e                        inc     BAS_FAC+1
02d3: a5 9d        L02D3           lda     BAS_FAC
02d5: a6 9e                        ldx     BAS_FAC+1
02d7: a0 00                        ldy     #$00
02d9: 60                           rts

02da: c4 c1 cf cc  LoadCommand     .rstr   “LOAD”            ;Ctrl+M Ctrl+D LOAD
02de: 84                           .dd1    $84
02df: 8d                           .dd1    $8d

02e0: a9 00        L02E0           lda     #$00
02e2: 85 94                        sta     BAS_HIGHDS
02e4: 85 9c                        sta     BAS_LOWTR+1
02e6: 85 97                        sta     BAS_HIGHTR+1
02e8: a9 69                        lda     #$69
02ea: 85 9b                        sta     BAS_LOWTR
02ec: a9 71                        lda     #$71
02ee: 85 96                        sta     BAS_HIGHTR
02f0: a9 01                        lda     #$01
02f2: 85 95                        sta     BAS_HIGHDS+1
02f4: 20 a9 03                     jsr     BLTU2
02f7: a2 01                        ldx     #$01
02f9: b5 69        L02F9           lda     BAS_VARTAB,x
02fb: 95 9b                        sta     BAS_LOWTR,x
02fd: b5 6d                        lda     BAS_STREND,x
02ff: 95 96                        sta     BAS_HIGHTR,x
0301: b5 6f                        lda     BAS_FRETOP,x
0303: 95 94                        sta     BAS_HIGHDS,x
0305: ca                           dex
0306: f0 f1                        beq     L02F9
0308: 20 a9 03                     jsr     BLTU2
030b: a5 94                        lda     BAS_HIGHDS
030d: 85 a1                        sta     BAS_FAC+4
030f: a6 95                        ldx     BAS_HIGHDS+1
0311: e8                           inx
0312: 86 a2                        stx     BAS_FACSIGN
                   ; Issue DOS command to load new program.
0314: a0 06                        ldy     #$06
0316: b9 d9 02     L0316           lda     LoadCommand-1,y
0319: 20 a0 03                     jsr     OUTDO
031c: 88                           dey
031d: d0 f7                        bne     L0316
031f: c8                           iny
0320: b1 b8        :FileNameLoop   lda     (BAS_TXTPTR),y    ;extract filename
0322: f0 0a                        beq     L032E
0324: c9 22                        cmp     #‘"’              ;closing quote?
0326: f0 06                        beq     L032E
0328: 20 a0 03                     jsr     OUTDO
032b: c8                           iny
032c: d0 f2                        bne     :FileNameLoop
032e: a9 3c        L032E           lda     #<Continue
0330: 85 36                        sta     MON_CSWL
0332: a9 03                        lda     #>Continue
0334: 85 37                        sta     MON_CSWH
0336: 20 ea 03                     jsr     DOS_CHARIO        ;reconnect DOS
0339: 4c a3 03                     jmp     CRDO              ;print <return>

033c: 20 93 fe     Continue        jsr     MON_SETVID
033f: 20 ea 03                     jsr     DOS_CHARIO
0342: 20 9d 03                     jsr     SETPTRS
0345: 38                           sec
0346: a5 69                        lda     BAS_VARTAB
0348: e5 f8                        sbc     BAS_REMSTK
034a: 85 9d                        sta     BAS_FAC
034c: a5 6a                        lda     BAS_VARTAB+1
034e: e5 f9                        sbc     $f9
0350: 85 9e                        sta     BAS_FAC+1
0352: a2 fa                        ldx     #$fa
0354: 20 76 03                     jsr     L0376
0357: e8                           inx
0358: 20 76 03                     jsr     L0376
035b: a2 01                        ldx     #$01
035d: b5 fe        L035D           lda     $fe,x
035f: 95 6f                        sta     BAS_FRETOP,x
0361: 95 3e                        sta     MON_A2L,x
0363: b5 a1                        lda     BAS_FAC+4,x
0365: 95 3c                        sta     MON_A1L,x
0367: b5 69                        lda     BAS_VARTAB,x
0369: 95 42                        sta     MON_A4L,x
036b: ca                           dex
036c: f0 ef                        beq     L035D
036e: a0 00                        ldy     #$00
0370: 20 2c fe                     jsr     MON_MOVE
0373: 6c ae 03                     jmp     (NEWSTT_I)        ;start program?

0376: 18           L0376           clc
0377: b5 00                        lda     $00,x
0379: 65 9d                        adc     BAS_FAC
037b: 95 71                        sta     $71,x
037d: e8                           inx
037e: b5 00                        lda     $00,x
0380: 65 9e                        adc     BAS_FAC+1
0382: 95 71                        sta     $71,x
0384: 60                           rts

0385: ad 00 e0     InitCalls       lda     $e000             ;check for Applesoft in ROM
0388: a0 0b                        ldy     #$0b
038a: c9 4c                        cmp     #$4c              ;is it a JMP instruction?
038c: f0 02                        beq     :InRom            ;yes, copy $03b8-3c3 to $03ac-3b7
038e: a0 17                        ldy     #$17              ;no, copy $03c4-3cf to $03ac-3b7
0390: a2 0b        :InRom          ldx     #$0b
0392: b9 b8 03     :Loop           lda     BasicInRom,y
0395: 9d ac 03                     sta     SETPTRS_I,x
0398: 88                           dey
0399: ca                           dex
039a: 10 f6                        bpl     :Loop
039c: 60                           rts

039d: 6c ac 03     SETPTRS         jmp     (SETPTRS_I)

03a0: 6c b2 03     OUTDO           jmp     (OUTDO_I)

03a3: 6c b0 03     CRDO            jmp     (CRDO_I)

03a6: 6c b4 03     GARBAG          jmp     (GARBAG_I)

03a9: 6c b6 03     BLTU2           jmp     (BLTU2_I)

03ac: 00           SETPTRS_I       .dd1    $00               ;set TXTPTR, clear vars
03ad: 00                           .dd1    $00
03ae: 00           NEWSTT_I        .dd1    $00               ;perform NEXT statement
03af: 00                           .dd1    $00
03b0: 00           CRDO_I          .dd1    $00               ;print <return>
03b1: 00                           .dd1    $00
03b2: 00           OUTDO_I         .dd1    $00               ;print char from A-reg
03b3: 00                           .dd1    $00
03b4: 00           GARBAG_I        .dd1    $00               ;collect garbage
03b5: 00                           .dd1    $00
03b6: 00           BLTU2_I         .dd1    $00               ;move block of memory up (LOWTR:HIGHTR->STREND)
03b7: 00                           .dd1    $00
03b8: 65 d6        BasicInRom      .dd2    $d665
03ba: d2 d7                        .dd2    $d7d2
03bc: fb da                        .dd2    $dafb
03be: 5c db                        .dd2    $db5c
03c0: 84 e4                        .dd2    $e484
03c2: 9a d3                        .dd2    $d39a
03c4: 65 0e        BasicInRam      .dd2    $0e65
03c6: d4 0f                        .dd2    $0fd4
03c8: fc 12                        .dd2    $12fc
03ca: 5f 13                        .dd2    $135f
03cc: 7b 1c                        .dd2    $1c7b
03ce: 9a 0b                        .dd2    $0b9a

Symbol Table

No exported symbols found.