home *** CD-ROM | disk | FTP | other *** search
- ;goto.asm
- ;=================================
- ; Batch file command: goto label
- ;=================================
- ; Example:
-
- ; goto there
- ; dir/w
- ; :there
- ; dir
-
-
-
- ndx = $00d0
- int04 = $1704
- int05 = $1705
- int0e = $170e
- int21 = $1721
- stk1 = $1bd1
- rdila = $1bfa
- primm = $ff7d
-
- star = $0b00
- .wor star
- * = star
-
- jmp goto
- dw Date
-
- goto ldx #1
- jsr int04 ; label there?
- bcc gt0 ; yep
- exit ldx stk1 ; no. must be a BASIC GOTO
- txs
- lda #$40
- sta $ff00
- rts
-
- gt0 cmp #"1" ; if line number then let BASIC handle the goto
- bcc gt00
- cmp #":"
- bcc exit
- gt00 ldx #0 ; fetch label to go to
- gt1 sta $1b20,x
- inx
- jsr int05
- bcc gt1
- stx lablen ; save label length
- bit rdila ; in an exec file?
- bpl noexec ; no..quit
- gt2 jsr execin ; get char from exec file
- cmp #":" ; is next line a label?
- bne skpcr ; no. skip ahead to CR
- ldx #0
- gt3 jsr execin ; check one char
- cmp $1b20,x
- bne skpcr ; no match...skip this line
- inx
- cpx lablen ; keep going until all chars checked
- bne gt3
- jsr execin ; line must end with a CR
- cmp #13
- bne skpcr
- ; lda #0
- ; sta ndx
- noexec jmp int0e ; found label. return
-
- skpcr cmp #13 ; skip line
- beq gt2
- jsr execin
- jmp skpcr
-
- execin ldy #9 ; int21 function 9 fetches char from exec file
- lda #0
- jsr int21
- bcc eiok ; ok
- cmp #13
- beq eiok ; maybe ok
- ; jsr primm
- ; .asc 13,"Goto failed...end of EXEC file reached",13,0
- jmp int0e
-
- eiok rts
-
- lablen .byt 0
-
- .end
-