├── .gitignore ├── Makefile └── a1basic.asm /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.p 3 | *.bin 4 | *.lst 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: a1basic-check 2 | 3 | %.lst %.p: %.asm 4 | asl $< -o $*.p -LC 5 | 6 | a1basic.bin: a1basic.p 7 | p2bin -r '$$e000-$$efff' a1basic.p a1basic.bin 8 | 9 | a1basic-check: a1basic.bin 10 | echo "56d5cd968557c81a99cde298d76030f65bb7ce9a85bc2ff0fed5726d50b91499 a1basic.bin" | sha256sum -c - 11 | 12 | -------------------------------------------------------------------------------- /a1basic.asm: -------------------------------------------------------------------------------- 1 | ; Disassembly of Apple 1 BASIC 2 | 3 | ; Apple 1 BASIC was written by Steve Wozniak 4 | 5 | ; This disassembly is copyright 2003, 2019 Eric Smith 6 | ; Includes some updates by Jeff Tranter 7 | 8 | ; Cross-assembles on modern systems using the Macro Assembler AS 9 | ; by Alfred Arnold: 10 | ; http://john.ccac.rwth-aachen.de:8000/as/ 11 | 12 | cpu 6502 13 | 14 | fcs macro arg 15 | irpc char,arg 16 | fcb 'char'+$80 17 | endm 18 | endm 19 | 20 | 21 | errstr macro arg 22 | if strlen(arg) > 1 23 | fcs substr(arg,0,strlen(arg)-1) 24 | endif 25 | fcb charfromstr(arg,strlen(arg)-1) 26 | endm 27 | 28 | 29 | synstr macro arg 30 | i set strlen(arg) 31 | while i > 0 32 | i set i-1 33 | fcb charfromstr(arg, i)+$60 34 | endm 35 | endm 36 | 37 | synstr1 macro arg 38 | i set strlen(arg) 39 | i set i-1 40 | fcb charfromstr(arg, i)+$a0 41 | while i > 0 42 | i set i-1 43 | fcb charfromstr(arg, i)+$60 44 | endm 45 | endm 46 | 47 | 48 | verb macro num,precv,target 49 | org verb_prec_tbl+num 50 | fcb precv 51 | org verb_addr_l+num 52 | fcb target & $ff 53 | org verb_addr_h+num 54 | fcb target >> 8 55 | endm 56 | 57 | 58 | ch_cr equ $0d 59 | 60 | 61 | reset equ $00 62 | Z1d equ $1d 63 | ch equ $24 ; cursor horizontal location 64 | cv equ $25 ; cusror vertical location 65 | lomem equ $4a ; lower limit of memory used by BASIC (2 bytes) 66 | himem equ $4c ; upper limit of memory used by BASIC (2 bytes) 67 | rnd equ $4e ; random number (2 bytes) 68 | 69 | ; The noun stack and syntax stack appear to overlap, which is OK since 70 | ; they apparently are not used simultaneously. 71 | 72 | ; The noun stack size appears to be 32 entries, based on LDX #$20 73 | ; instruction at e67f. However, there seems to be enough room for 74 | ; another 8 entries. The noun stack builds down from noun_stk_+$1f 75 | ; to noun_stk_+$00, indexed by the X register. 76 | 77 | ; Noun stack usage appears to be: 78 | ; integer: 79 | ; (noun_stk_h_int,noun_stk_l) = value 80 | ; noun_stk_h_str = 0 81 | ; string: 82 | ; (noun_stk_h_str,noun_stk_l) = pointer to string 83 | ; noun_stk_h_int = any 84 | ; Since noun_stk_h_str determines whether stack entry is integer or string, 85 | ; strings can't start in zero page. 86 | 87 | noun_stk_l equ $50 88 | syn_stk_h equ $58 ; through $77 89 | noun_stk_h_str equ $78 90 | syn_stk_l equ $80 ; through $9f 91 | noun_stk_h_int equ $a0 92 | txtndxstk equ $a8 ; through $c7 93 | text_index equ $c8 ; index into text being tokenized (in buffer at $0200) 94 | leadbl equ $c9 ; leading blanks 95 | pp equ $ca ; pointer to end fo program (2 bytes) 96 | pv equ $cc ; pointer to end of variable storage (2 bytes) 97 | acc equ $ce ; (2 bytes) 98 | srch equ $d0 99 | tokndxstk equ $d1 100 | srch2 equ $d2 101 | if_flag equ $d4 102 | cr_flag equ $d5 103 | current_verb equ $d6 104 | precedence equ $d7 105 | x_save equ $d8 106 | run_flag equ $d9 107 | aux equ $da 108 | pline equ $dc ; pointer to current program line (2 bytes) 109 | pverb equ $e0 ; pointer to current verb (2 bytes) 110 | p1 equ $e2 111 | p2 equ $e4 112 | p3 equ $e6 113 | token_index equ $f1 ; pointer used to write tokens into buffer (2 bytes) 114 | pcon equ $f2 ; temp used in decimal output (2 bytes) 115 | auto_inc equ $f4 116 | auto_ln equ $f6 117 | auto_flag equ $f8 118 | char equ $f9 119 | leadzr equ $fa 120 | for_nest_count equ $fb ; count of active (nested) FOR loops 121 | gosub_nest_count equ $fc ; count of active (nested) subroutine calls (GOSUB) 122 | synstkdx equ $fd 123 | synpag equ $fe 124 | 125 | 126 | ; GOSUB stack, max eight entries 127 | ; note that the Apple II version has sixteen entries 128 | gstk_pverbl equ $0100 129 | gstk_pverbh equ $0108 130 | gstk_plinel equ $0110 131 | gstk_plineh equ $0118 132 | 133 | ; FOR stack, max eight entries 134 | ; note that the Apple II version has sixteen entries 135 | fstk_varl equ $0120 136 | fstk_varh equ $0128 137 | fstk_stepl equ $0130 138 | fstk_steph equ $0138 139 | fstk_plinel equ $0140 140 | fstk_plineh equ $0148 141 | fstk_pverbl equ $0150 142 | fstk_pverbh equ $0158 143 | fstk_tol equ $0160 144 | fstk_toh equ $0168 145 | 146 | buffer equ $0200 147 | 148 | ; hardware locations: 149 | kbd equ $d010 150 | kbdcr equ $d011 151 | dsp equ $d0f2 ; the canonical address is $d012, but due to incomplete decode, this works 152 | 153 | org $e000 154 | 155 | Pe000: jmp cold ; BASIC cold start entry point 156 | 157 | ; Get character from keybaord, return in A. 158 | rdkey: lda kbdcr ; read control register 159 | bpl rdkey ; loop if no key pressed 160 | lda kbd ; read data 161 | rts 162 | 163 | Se00c: txa 164 | and #$20 165 | beq Le034 166 | 167 | Se011: lda #' '+$80 168 | sta p2 169 | jmp cout 170 | 171 | Se018: lda #' ' 172 | 173 | Se01a: cmp ch 174 | bcs nextbyte 175 | lda #ch_cr+$80 176 | ldy #$07 177 | Le022: jsr cout 178 | lda #' '+$80 179 | dey 180 | bne Le022 181 | 182 | nextbyte: ldy #$00 183 | lda (p1),y 184 | inc p1 185 | bne Le034 186 | inc p1+1 187 | Le034: rts 188 | 189 | list_comman: jsr get16bit 190 | jsr find_line2 191 | Le03b: lda p1 192 | cmp p3 193 | lda p1+1 194 | sbc p3+1 195 | bcs Le034 196 | jsr list_line 197 | jmp Le03b 198 | 199 | list_all: lda pp 200 | sta p1 201 | lda pp+1 202 | sta p1+1 203 | lda himem 204 | sta p3 205 | lda himem+1 206 | sta p3+1 207 | bne Le03b 208 | 209 | list_cmd: jsr get16bit 210 | jsr find_line 211 | lda p2 212 | sta p1 213 | lda p2+1 214 | sta p1+1 215 | bcs Le034 216 | 217 | list_line: stx x_save 218 | lda #$a0 219 | sta leadzr 220 | jsr nextbyte 221 | tya 222 | list_int: sta p2 223 | jsr nextbyte 224 | tax 225 | jsr nextbyte 226 | jsr prdec 227 | Le083: jsr Se018 228 | sty leadzr 229 | tax 230 | bpl list_token 231 | asl a 232 | bpl list_int 233 | lda p2 234 | bne Le095 235 | jsr Se011 236 | Le095: txa 237 | Le096: jsr cout 238 | Le099: lda #$25 239 | jsr Se01a 240 | tax 241 | bmi Le096 242 | sta p2 243 | list_token: cmp #$01 244 | bne Le0ac 245 | ldx x_save 246 | jmp crout 247 | Le0ac: pha 248 | sty acc 249 | ldx #$ed 250 | stx acc+1 251 | cmp #$51 252 | bcc Le0bb 253 | dec acc+1 254 | sbc #$50 255 | Le0bb: pha 256 | lda (acc),y 257 | Le0be: tax 258 | dey 259 | lda (acc),y 260 | bpl Le0be 261 | cpx #$c0 262 | bcs Le0cc 263 | cpx #$00 264 | bmi Le0be 265 | Le0cc: tax 266 | pla 267 | sbc #$01 268 | bne Le0bb 269 | bit p2 270 | bmi Le0d9 271 | jsr Seff8 272 | Le0d9: lda (acc),y 273 | bpl Le0ed 274 | tax 275 | and #$3f 276 | sta p2 277 | clc 278 | adc #' '+$80 279 | jsr cout 280 | dey 281 | cpx #$c0 282 | bcc Le0d9 283 | Le0ed: jsr Se00c 284 | pla 285 | cmp #$5d 286 | beq Le099 287 | cmp #$28 288 | bne Le083 289 | beq Le099 290 | 291 | paren_substr: jsr Se118 292 | sta noun_stk_l,x 293 | cmp noun_stk_h_str,x 294 | Le102: bcc Le115 295 | string_err: ldy #$2b 296 | go_errmess_1: jmp do_error 297 | 298 | comma_substr: jsr getbyte 299 | cmp noun_stk_l,x 300 | bcc string_err 301 | jsr Sefe4 302 | sta noun_stk_h_str,x 303 | Le115: jmp left_paren 304 | 305 | Se118: jsr getbyte 306 | beq string_err 307 | sec 308 | sbc #$01 309 | rts 310 | 311 | str_arr_dest: jsr Se118 312 | sta noun_stk_l,x 313 | clc 314 | sbc noun_stk_h_str,x 315 | jmp Le102 316 | Le12c: ldy #$14 317 | bne go_errmess_1 318 | 319 | dim_str: jsr Se118 320 | inx 321 | Le134: lda noun_stk_l,x 322 | sta aux 323 | adc acc 324 | pha 325 | tay 326 | lda noun_stk_h_str,x 327 | sta aux+1 328 | adc acc+1 329 | pha 330 | cpy pp 331 | sbc pp+1 332 | bcs Le12c 333 | lda aux 334 | adc #$fe 335 | sta aux 336 | lda #$ff 337 | tay 338 | adc aux+1 339 | sta aux+1 340 | Le156: iny 341 | lda (aux),y 342 | cmp pv,y 343 | bne Le16d 344 | tya 345 | beq Le156 346 | Le161: pla 347 | sta (aux),y 348 | sta pv,y 349 | dey 350 | bpl Le161 351 | inx 352 | rts 353 | 354 | nop ; unused 355 | 356 | Le16d: ldy #$80 357 | Le16f: bne go_errmess_1 358 | 359 | input_str: lda #$00 360 | jsr push_a_noun_stk 361 | ldy #$02 362 | sty noun_stk_h_str,x 363 | jsr push_a_noun_stk 364 | lda #$bf 365 | jsr cout 366 | ldy #$00 367 | jsr read_line 368 | sty noun_stk_h_str,x 369 | 370 | nop 371 | nop 372 | nop 373 | 374 | string_lit: lda noun_stk_l+1,x 375 | sta acc 376 | lda noun_stk_h_str+1,x 377 | sta acc+1 378 | inx 379 | inx 380 | jsr Se1bc 381 | Le199: lda rnd,x 382 | cmp syn_stk_h+30,x 383 | bcs Le1b4 384 | inc rnd,x 385 | tay 386 | lda (acc),y 387 | ldy noun_stk_l,x 388 | cpy p2 389 | bcc Le1ae 390 | ldy #$83 391 | bne Le16f 392 | Le1ae: sta (aux),y 393 | inc noun_stk_l,x 394 | bcc Le199 395 | Le1b4: ldy noun_stk_l,x 396 | txa 397 | sta (aux),y 398 | inx 399 | inx 400 | rts 401 | 402 | Se1bc: lda noun_stk_l+1,x 403 | sta aux 404 | sec 405 | sbc #$02 406 | sta p2 407 | lda noun_stk_h_str+1,x 408 | sta aux+1 409 | sbc #$00 410 | sta p2+1 411 | ldy #$00 412 | lda (p2),y 413 | clc 414 | sbc aux 415 | sta p2 416 | rts 417 | 418 | string_eq: lda noun_stk_l+3,x 419 | sta acc 420 | lda noun_stk_h_str+3,x 421 | sta acc+1 422 | lda noun_stk_l+1,x 423 | sta aux 424 | lda noun_stk_h_str+1,x 425 | sta aux+1 426 | inx 427 | inx 428 | inx 429 | ldy #$00 430 | sty noun_stk_h_str,x 431 | sty noun_stk_h_int,x 432 | iny 433 | sty noun_stk_l,x 434 | Le1f3: lda himem+1,x 435 | cmp syn_stk_h+29,x 436 | php 437 | pha 438 | lda rnd+1,x 439 | cmp syn_stk_h+31,x 440 | bcc Le206 441 | pla 442 | plp 443 | bcs Le205 444 | Le203: lsr noun_stk_l,x 445 | Le205: rts 446 | 447 | Le206: tay 448 | lda (acc),y 449 | sta p2 450 | pla 451 | tay 452 | plp 453 | bcs Le203 454 | lda (aux),y 455 | cmp p2 456 | bne Le203 457 | inc rnd+1,x 458 | inc himem+1,x 459 | bcs Le1f3 460 | 461 | string_neq: jsr string_eq 462 | jmp not_op 463 | 464 | multiply_op: jsr Se254 465 | Le225: asl acc 466 | rol acc+1 467 | bcc Le238 468 | clc 469 | lda p3 470 | adc aux 471 | sta p3 472 | lda p3+1 473 | adc aux+1 474 | sta p3+1 475 | Le238: dey 476 | beq Le244 477 | asl p3 478 | rol p3+1 479 | bpl Le225 480 | jmp Le77e 481 | Le244: lda p3 482 | jsr push_ya_noun_stk 483 | lda p3+1 484 | sta noun_stk_h_int,x 485 | asl p2+1 486 | bcc Le279 487 | jmp negate 488 | 489 | Se254: lda #$55 490 | sta p2+1 491 | jsr Se25b 492 | 493 | Se25b: lda acc 494 | sta aux 495 | lda acc+1 496 | sta aux+1 497 | jsr get16bit 498 | sty p3 499 | sty p3+1 500 | lda acc+1 501 | bpl Le277 502 | dex 503 | asl p2+1 504 | jsr negate 505 | jsr get16bit 506 | Le277: ldy #$10 507 | Le279: rts 508 | 509 | mod_op: jsr See6c 510 | beq Le244 ; hoepfully always taken 511 | fcb $ff ; hopefully unused 512 | 513 | Le280: cmp #$84 514 | bne Le286 515 | lsr auto_flag 516 | Le286: cmp #$df 517 | beq Le29b 518 | cmp #$9b 519 | beq Le294 520 | sta buffer,y 521 | iny 522 | bpl read_line 523 | Le294: ldy #$8b 524 | jsr Se3c4 525 | 526 | Se299: ldy #$01 527 | Le29b: dey 528 | bmi Le294 529 | 530 | read_line: jsr rdkey 531 | 532 | nop 533 | nop 534 | 535 | jsr cout 536 | cmp #ch_cr+$80 537 | bne Le280 538 | lda #'_'+$80 ; mark end of line with underscore 539 | sta buffer,y 540 | rts 541 | 542 | cold: jsr mem_init_4k 543 | warm: jsr crout 544 | Le2b6: lsr run_flag 545 | lda #$be 546 | jsr cout 547 | ldy #$00 548 | sty leadzr 549 | bit auto_flag 550 | bpl Le2d1 551 | ldx auto_ln 552 | lda auto_ln+1 553 | jsr prdec 554 | lda #' '+$80 555 | jsr cout 556 | Le2d1: ldx #$ff 557 | txs 558 | jsr read_line 559 | sty token_index 560 | txa 561 | sta text_index 562 | ldx #$20 563 | jsr Se491 564 | lda text_index 565 | adc #$00 566 | sta pverb 567 | lda #$00 568 | tax 569 | adc #$02 570 | sta pverb+1 571 | lda (pverb,x) 572 | and #$f0 573 | cmp #$b0 574 | beq Le2f9 575 | jmp Le883 576 | Le2f9: ldy #$02 577 | Le2fb: lda (pverb),y 578 | sta pv+1,y 579 | dey 580 | bne Le2fb 581 | jsr Se38a 582 | lda token_index 583 | sbc text_index 584 | cmp #$04 585 | beq Le2b6 586 | sta (pverb),y 587 | lda pp 588 | sbc (pverb),y 589 | sta p2 590 | lda pp+1 591 | sbc #$00 592 | sta p2+1 593 | lda p2 594 | cmp pv 595 | lda p2+1 596 | sbc pv+1 597 | bcc Le36b 598 | Le326: lda pp 599 | sbc (pverb),y 600 | sta p3 601 | lda pp+1 602 | sbc #$00 603 | sta p3+1 604 | lda (pp),y 605 | sta (p3),y 606 | inc pp 607 | bne Le33c 608 | inc pp+1 609 | Le33c: lda p1 610 | cmp pp 611 | lda p1+1 612 | sbc pp+1 613 | bcs Le326 614 | Le346: lda p2,x 615 | sta pp,x 616 | dex 617 | bpl Le346 618 | lda (pverb),y 619 | tay 620 | Le350: dey 621 | lda (pverb),y 622 | sta (p3),y 623 | tya 624 | bne Le350 625 | bit auto_flag 626 | bpl Le365 627 | Le35c: lda auto_ln+1,x 628 | adc auto_inc+1,x 629 | sta auto_ln+1,x 630 | inx 631 | beq Le35c 632 | Le365: bpl Le3e5 633 | 634 | fcb $00,$00,$00,$00 ; BRK instructions, hopefully never executed 635 | 636 | Le36b: ldy #erri_mem_full 637 | bne do_error 638 | 639 | del_comma: jsr get16bit 640 | lda p1 641 | sta p3 642 | lda p1+1 643 | sta p3+1 644 | jsr find_line1 645 | lda p1 646 | sta p2 647 | lda p1+1 648 | sta p2+1 649 | bne Le395 650 | 651 | del_cmd: jsr get16bit 652 | 653 | Se38a: jsr find_line 654 | lda p3 655 | sta p1 656 | lda p3+1 657 | sta p1+1 658 | Le395: ldy #$00 659 | Le397: lda pp 660 | cmp p2 661 | lda pp+1 662 | sbc p2+1 663 | bcs Le3b7 664 | lda p2 665 | bne Le3a7 666 | dec p2+1 667 | Le3a7: dec p2 668 | lda p3 669 | bne Le3af 670 | dec p3+1 671 | Le3af: dec p3 672 | lda (p2),y 673 | sta (p3),y 674 | bcc Le397 675 | Le3b7: lda p3 676 | sta pp 677 | lda p3+1 678 | sta pp+1 679 | rts 680 | Le3c0: jsr cout 681 | iny 682 | 683 | Se3c4: lda error_msg_tbl,y 684 | bmi Le3c0 685 | 686 | cout: cmp #ch_cr+$80 687 | bne Le3d3 688 | 689 | crout: lda #$00 690 | sta ch 691 | lda #ch_cr+$80 692 | Le3d3: inc ch 693 | 694 | ; Send character in A to display. 695 | Le3d5: bit dsp 696 | bmi Le3d5 697 | sta dsp 698 | rts 699 | 700 | too_long_err: ldy #erri_too_long 701 | 702 | do_error: jsr print_err_msg 703 | bit run_flag 704 | Le3e5: bmi Le3ea 705 | jmp Le2b6 706 | Le3ea: jmp Leb9a 707 | 708 | Le3ed: rol 709 | adc #$a0 710 | cmp buffer,x 711 | bne Le448 712 | lda (synpag),y 713 | asl 714 | bmi Le400 715 | dey 716 | lda (synpag),y 717 | bmi Le428 718 | iny 719 | Le400: stx text_index 720 | tya 721 | pha 722 | ldx #$00 723 | lda (synpag,x) 724 | tax 725 | Le409: lsr 726 | eor #$48 727 | ora (synpag),y 728 | cmp #$c0 729 | bcc Le413 730 | inx 731 | Le413: iny 732 | bne Le409 733 | pla 734 | tay 735 | txa 736 | jmp Le4c0 737 | 738 | put_token: inc token_index 739 | ldx token_index 740 | beq too_long_err 741 | sta buffer,x 742 | Le425: rts 743 | 744 | Le426: ldx text_index 745 | Le428: lda #$a0 746 | Le42a: inx 747 | cmp buffer,x 748 | bcs Le42a 749 | lda (synpag),y 750 | and #$3f 751 | lsr 752 | bne Le3ed 753 | lda buffer,x 754 | bcs Le442 755 | adc #$3f 756 | cmp #$1a 757 | bcc Le4b1 758 | Le442: adc #$4f 759 | cmp #$0a 760 | bcc Le4b1 761 | Le448: ldx synstkdx 762 | Le44a: iny 763 | lda (synpag),y 764 | and #$e0 765 | cmp #$20 766 | beq Le4cd 767 | lda txtndxstk,x 768 | sta text_index 769 | lda tokndxstk,x 770 | sta token_index 771 | Le45b: dey 772 | lda (synpag),y 773 | asl a 774 | bpl Le45b 775 | dey 776 | bcs Le49c 777 | asl a 778 | bmi Le49c 779 | ldy syn_stk_h,x 780 | sty synpag+1 781 | ldy syn_stk_l,x 782 | inx 783 | bpl Le44a 784 | Le470: beq Le425 785 | cmp #$7e 786 | bcs Le498 787 | dex 788 | bpl Le47d 789 | ldy #$06 790 | bpl go_errmess_2 ; always taken 791 | 792 | 793 | Le47d: sty syn_stk_l,x 794 | ldy synpag+1 795 | sty syn_stk_h,x 796 | ldy text_index 797 | sty txtndxstk,x 798 | ldy token_index 799 | sty tokndxstk,x 800 | and #$1f ; mask to get syntax category number 801 | tay 802 | lda category_table,y 803 | 804 | Se491: asl a 805 | tay 806 | lda #$ec/2 807 | rol 808 | sta synpag+1 809 | Le498: bne Le49b 810 | iny 811 | Le49b: iny 812 | Le49c: stx synstkdx 813 | lda (synpag),y 814 | bmi Le426 815 | bne Le4a9 816 | ldy #erri_syntax 817 | go_errmess_2: jmp do_error 818 | 819 | Le4a9: cmp #$03 820 | bcs Le470 821 | lsr a 822 | ldx text_index 823 | inx 824 | Le4b1: lda buffer,x 825 | bcc Le4ba 826 | cmp #'"'+$80 827 | beq Le4c4 828 | Le4ba: cmp #'_'+$80 829 | beq Le4c4 830 | stx text_index 831 | Le4c0: jsr put_token 832 | iny 833 | Le4c4: dey 834 | ldx synstkdx 835 | Le4c7: lda (synpag),y 836 | dey 837 | asl 838 | bpl Le49c 839 | Le4cd: ldy syn_stk_h,x 840 | sty synpag+1 841 | ldy syn_stk_l,x 842 | inx 843 | lda (synpag),y 844 | and #$9f 845 | bne Le4c7 846 | sta pcon 847 | sta pcon+1 848 | tya 849 | pha 850 | stx synstkdx 851 | ldy srch,x 852 | sty leadbl 853 | clc 854 | Le4e7: lda #$0a 855 | sta char 856 | ldx #$00 857 | iny 858 | lda buffer,y 859 | and #$0f 860 | Le4f3: adc pcon 861 | pha 862 | txa 863 | adc pcon+1 864 | bmi Le517 865 | tax 866 | pla 867 | dec char 868 | bne Le4f3 869 | sta pcon 870 | stx pcon+1 871 | cpy token_index 872 | bne Le4e7 873 | ldy leadbl 874 | iny 875 | sty token_index 876 | jsr put_token 877 | pla 878 | tay 879 | lda pcon+1 880 | bcs Le4c0 881 | Le517: ldy #$00 882 | bpl go_errmess_2 883 | 884 | prdec: sta pcon+1 885 | stx pcon 886 | ldx #$04 887 | stx leadbl 888 | Le523: lda #'0'+$80 889 | sta char 890 | Le527: lda pcon 891 | cmp dectabl,x 892 | lda pcon+1 893 | sbc dectabh,x 894 | bcc Le540 895 | sta pcon+1 896 | lda pcon 897 | sbc dectabl,x 898 | sta pcon 899 | inc char 900 | bne Le527 901 | Le540: lda char 902 | inx 903 | dex 904 | beq Le554 905 | cmp #'0'+$80 906 | beq Le54c 907 | sta leadbl 908 | Le54c: bit leadbl 909 | bmi Le554 910 | lda leadzr 911 | beq Le55f 912 | Le554: jsr cout 913 | bit auto_flag 914 | bpl Le55f 915 | sta buffer,y 916 | iny 917 | Le55f: dex 918 | bpl Le523 919 | rts 920 | 921 | dectabl: fcb $01,$0a,$64,$e8,$10 922 | dectabh: fcb $00,$00,$00,$03,$27 923 | 924 | find_line: lda pp 925 | sta p3 926 | lda pp+1 927 | sta p3+1 928 | 929 | find_line1: inx 930 | 931 | find_line2: lda p3+1 932 | sta p2+1 933 | lda p3 934 | sta p2 935 | cmp himem 936 | lda p2+1 937 | sbc himem+1 938 | bcs Le5ac 939 | ldy #$01 940 | lda (p2),y 941 | sbc acc 942 | iny 943 | lda (p2),y 944 | sbc acc+1 945 | bcs Le5ac 946 | ldy #$00 947 | lda p3 948 | adc (p2),y 949 | sta p3 950 | bcc Le5a0 951 | inc p3+1 952 | clc 953 | Le5a0: iny 954 | lda acc 955 | sbc (p2),y 956 | iny 957 | lda acc+1 958 | sbc (p2),y 959 | bcs find_line2 960 | Le5ac: rts 961 | 962 | new_cmd: lsr auto_flag 963 | lda himem 964 | sta pp 965 | lda himem+1 966 | sta pp+1 967 | 968 | clr_cmd: lda lomem 969 | sta pv 970 | lda lomem+1 971 | sta pv+1 972 | lda #$00 973 | sta for_nest_count 974 | sta gosub_nest_count 975 | sta synpag 976 | lda #$00 977 | sta Z1d 978 | rts 979 | 980 | Le5cc: lda srch 981 | adc #$05 982 | sta srch2 983 | lda tokndxstk 984 | adc #$00 985 | sta srch2+1 986 | lda srch2 987 | cmp pp 988 | lda srch2+1 989 | sbc pp+1 990 | bcc Le5e5 991 | jmp Le36b 992 | Le5e5: lda acc 993 | sta (srch),y 994 | lda acc+1 995 | iny 996 | sta (srch),y 997 | lda srch2 998 | iny 999 | sta (srch),y 1000 | lda srch2+1 1001 | iny 1002 | sta (srch),y 1003 | lda #$00 1004 | iny 1005 | sta (srch),y 1006 | iny 1007 | sta (srch),y 1008 | lda srch2 1009 | sta pv 1010 | lda srch2+1 1011 | sta pv+1 1012 | lda srch 1013 | bcc Le64f 1014 | execute_var: sta acc 1015 | sty acc+1 1016 | jsr get_next_prog_byte 1017 | bmi Le623 1018 | cmp #$40 1019 | beq Le623 1020 | jmp Le628 1021 | 1022 | fcb $06,$c9,$49,$d0,$07,$a9,$49 1023 | 1024 | Le623: sta acc+1 1025 | jsr get_next_prog_byte 1026 | Le628: lda lomem+1 1027 | sta tokndxstk 1028 | lda lomem 1029 | Le62e: sta srch 1030 | cmp pv 1031 | lda tokndxstk 1032 | sbc pv+1 1033 | bcs Le5cc 1034 | lda (srch),y 1035 | iny 1036 | cmp acc 1037 | bne Le645 1038 | lda (srch),y 1039 | cmp acc+1 1040 | beq Le653 1041 | Le645: iny 1042 | lda (srch),y 1043 | pha 1044 | iny 1045 | lda (srch),y 1046 | sta tokndxstk 1047 | pla 1048 | Le64f: ldy #$00 1049 | beq Le62e 1050 | Le653: lda srch 1051 | adc #$03 1052 | jsr push_a_noun_stk 1053 | lda tokndxstk 1054 | adc #$00 1055 | sta noun_stk_h_str,x 1056 | lda acc+1 1057 | cmp #$40 1058 | bne fetch_prog_byte 1059 | dey 1060 | tya 1061 | jsr push_a_noun_stk 1062 | dey 1063 | sty noun_stk_h_str,x 1064 | ldy #$03 1065 | Le670: inc noun_stk_h_str,x 1066 | iny 1067 | lda (srch),y 1068 | bmi Le670 1069 | bpl fetch_prog_byte 1070 | 1071 | execute_stmt: lda #$00 1072 | sta if_flag 1073 | sta cr_flag 1074 | ldx #$20 1075 | push_old_verb: pha 1076 | fetch_prog_byte: ldy #$00 1077 | lda (pverb),y 1078 | Le686: bpl execute_token 1079 | asl a 1080 | bmi execute_var 1081 | jsr get_next_prog_byte 1082 | jsr push_ya_noun_stk 1083 | jsr get_next_prog_byte 1084 | sta noun_stk_h_int,x 1085 | Le696: bit if_flag 1086 | bpl Le69b 1087 | dex 1088 | Le69b: jsr get_next_prog_byte 1089 | bcs Le686 1090 | execute_token: cmp #$28 1091 | bne execute_verb 1092 | lda pverb 1093 | jsr push_a_noun_stk 1094 | lda pverb+1 1095 | sta noun_stk_h_str,x 1096 | bit if_flag 1097 | bmi Le6bc 1098 | lda #$01 1099 | jsr push_a_noun_stk 1100 | lda #$00 1101 | sta noun_stk_h_str,x 1102 | Le6ba: inc noun_stk_h_str,x 1103 | Le6bc: jsr get_next_prog_byte 1104 | bmi Le6ba 1105 | bcs Le696 1106 | execute_verb: bit if_flag 1107 | bpl Le6cd 1108 | cmp #$04 1109 | bcs Le69b 1110 | lsr if_flag 1111 | Le6cd: tay 1112 | sta current_verb 1113 | lda verb_prec_tbl,y 1114 | and #$55 1115 | asl 1116 | sta precedence 1117 | Le6d8: pla 1118 | tay 1119 | lda verb_prec_tbl,y 1120 | and #$aa 1121 | cmp precedence 1122 | bcs do_verb 1123 | tya 1124 | pha 1125 | jsr get_next_prog_byte 1126 | lda current_verb 1127 | bcc push_old_verb 1128 | do_verb: lda verb_addr_l,y 1129 | sta acc 1130 | lda verb_addr_h,y 1131 | sta acc+1 1132 | jsr Se6fc 1133 | jmp Le6d8 1134 | 1135 | Se6fc: jmp (acc) 1136 | 1137 | get_next_prog_byte: 1138 | inc pverb 1139 | bne Le705 1140 | inc pverb+1 1141 | Le705: lda (pverb),y 1142 | rts 1143 | 1144 | push_ya_noun_stk: 1145 | sty syn_stk_h+31,x 1146 | 1147 | push_a_noun_stk: 1148 | dex 1149 | bmi Le710 1150 | sta noun_stk_l,x 1151 | rts 1152 | 1153 | Le710: ldy #erri_stopped_at+3 ; The "+3" is a bug! 1154 | go_errmess_3: jmp do_error 1155 | 1156 | get16bit: ldy #$00 1157 | lda noun_stk_l,x 1158 | sta acc 1159 | lda noun_stk_h_int,x 1160 | sta acc+1 1161 | lda noun_stk_h_str,x 1162 | beq Le731 1163 | sta acc+1 1164 | lda (acc),y 1165 | pha 1166 | iny 1167 | lda (acc),y 1168 | sta acc+1 1169 | pla 1170 | sta acc 1171 | dey 1172 | Le731: inx 1173 | rts 1174 | 1175 | eq_op: jsr neq_op 1176 | 1177 | not_op: jsr get16bit 1178 | tya 1179 | jsr push_ya_noun_stk 1180 | sta noun_stk_h_int,x 1181 | cmp acc 1182 | bne Le749 1183 | cmp acc+1 1184 | bne Le749 1185 | inc noun_stk_l,x 1186 | Le749: rts 1187 | 1188 | neq_op: jsr subtract_op 1189 | jsr sgn_fn 1190 | 1191 | abs_fn: jsr get16bit 1192 | bit acc+1 1193 | bmi Se772 1194 | Le757: dex 1195 | Le758: rts 1196 | 1197 | sgn_fn: jsr get16bit 1198 | lda acc+1 1199 | bne Le764 1200 | lda acc 1201 | beq Le757 1202 | Le764: lda #$ff 1203 | jsr push_ya_noun_stk 1204 | sta noun_stk_h_int,x 1205 | bit acc+1 1206 | bmi Le758 1207 | 1208 | negate: jsr get16bit 1209 | 1210 | Se772: tya 1211 | sec 1212 | sbc acc 1213 | jsr push_ya_noun_stk 1214 | tya 1215 | sbc acc+1 1216 | bvc Le7a1 1217 | Le77e: ldy #$00 1218 | bpl go_errmess_3 1219 | 1220 | subtract_op: jsr negate 1221 | 1222 | add_op: jsr get16bit 1223 | lda acc 1224 | sta aux 1225 | lda acc+1 1226 | sta aux+1 1227 | jsr get16bit 1228 | 1229 | Se793: clc 1230 | lda acc 1231 | adc aux 1232 | jsr push_ya_noun_stk 1233 | lda acc+1 1234 | adc aux+1 1235 | bvs Le77e 1236 | Le7a1: sta noun_stk_h_int,x 1237 | 1238 | unary_pos: rts 1239 | 1240 | tab_fn: jsr get16bit 1241 | ldy acc 1242 | beq Le7b0 1243 | dey 1244 | lda acc+1 1245 | beq Le7bc 1246 | Le7b0: rts 1247 | 1248 | tabout: lda ch 1249 | ora #7 1250 | tay 1251 | iny 1252 | Le7b7: lda #' '+$80 1253 | jsr cout 1254 | Le7bc: cpy ch 1255 | bcs Le7b7 1256 | rts 1257 | 1258 | print_com_num: jsr tabout 1259 | 1260 | print_num: jsr get16bit 1261 | lda acc+1 1262 | bpl Le7d5 1263 | lda #'-'+$80 1264 | jsr cout 1265 | jsr Se772 1266 | bvc print_num 1267 | Le7d5: dey 1268 | sty cr_flag 1269 | stx acc+1 1270 | ldx acc 1271 | jsr prdec 1272 | ldx acc+1 1273 | rts 1274 | 1275 | auto_cmd: jsr get16bit 1276 | lda acc 1277 | sta auto_ln 1278 | lda acc+1 1279 | sta auto_ln+1 1280 | dey 1281 | sty auto_flag 1282 | iny 1283 | lda #$0a 1284 | Le7f3: sta auto_inc 1285 | sty auto_inc+1 1286 | rts 1287 | 1288 | auto_comma: jsr get16bit 1289 | lda acc 1290 | ldy acc+1 1291 | bpl Le7f3 1292 | 1293 | var_assign: jsr get16bit 1294 | lda noun_stk_l,x 1295 | sta aux 1296 | lda noun_stk_h_str,x 1297 | sta aux+1 1298 | lda acc 1299 | sta (aux),y 1300 | iny 1301 | lda acc+1 1302 | sta (aux),y 1303 | inx 1304 | 1305 | null_stmt: rts ; used to execute LET keyword or colon 1306 | ; (statement separator), which need no 1307 | ; processing 1308 | 1309 | begin_line: pla 1310 | pla 1311 | 1312 | colon: bit cr_flag 1313 | bpl Le822 1314 | 1315 | print_cr: jsr crout 1316 | 1317 | print_semi: lsr cr_flag 1318 | Le822: rts 1319 | 1320 | left_paren: ldy #$ff 1321 | sty precedence 1322 | 1323 | right_paren: rts 1324 | 1325 | if_stmt: jsr Sefcd 1326 | beq Le834 1327 | lda #$25 1328 | sta current_verb 1329 | dey 1330 | sty if_flag 1331 | Le834: inx 1332 | rts 1333 | 1334 | run_warm: lda pp 1335 | ldy pp+1 1336 | bne Le896 1337 | 1338 | gosub_stmt: ldy #$41 1339 | lda gosub_nest_count 1340 | cmp #8 1341 | bcs go_errmess_4 1342 | tay 1343 | inc gosub_nest_count 1344 | lda pverb 1345 | sta gstk_pverbl,y 1346 | lda pverb+1 1347 | sta gstk_pverbh,y 1348 | lda pline 1349 | sta gstk_plinel,y 1350 | lda pline+1 1351 | sta gstk_plineh,y 1352 | 1353 | goto_stmt: jsr get16bit 1354 | jsr find_line 1355 | bcc Le867 1356 | ldy #$37 1357 | bne go_errmess_4 1358 | Le867: lda p2 1359 | ldy p2+1 1360 | run_loop: sta pline 1361 | sty pline+1 1362 | bit kbdcr 1363 | bmi Le8c3 1364 | clc 1365 | adc #$03 1366 | bcc Le87a 1367 | iny 1368 | Le87a: ldx #$ff 1369 | stx run_flag 1370 | txs 1371 | sta pverb 1372 | sty pverb+1 1373 | Le883: jsr execute_stmt 1374 | bit run_flag 1375 | bpl end_stmt 1376 | clc 1377 | ldy #$00 1378 | lda pline 1379 | adc (pline),y 1380 | ldy pline+1 1381 | bcc Le896 1382 | iny 1383 | Le896: cmp himem 1384 | bne run_loop 1385 | cpy himem+1 1386 | bne run_loop 1387 | ldy #erri_end 1388 | lsr run_flag 1389 | go_errmess_4: jmp do_error 1390 | 1391 | return_stmt: ldy #$4a 1392 | lda gosub_nest_count 1393 | beq go_errmess_4 1394 | dec gosub_nest_count 1395 | tay 1396 | lda gstk_plinel-1,y 1397 | sta pline 1398 | lda gstk_plineh-1,y 1399 | sta pline+1 1400 | 1401 | fcb $be ; ldx synpag+1,y, but force absolute addressing mode 1402 | fdb synpag+1 1403 | 1404 | lda gstk_pverbh-1,y 1405 | Le8be: tay 1406 | txa 1407 | jmp Le87a 1408 | 1409 | Le8c3: ldy #$63 1410 | jsr Se3c4 1411 | ldy #$01 1412 | lda (pline),y 1413 | tax 1414 | iny 1415 | lda (pline),y 1416 | jsr prdec 1417 | 1418 | end_stmt: jmp warm 1419 | Le8d6: dec for_nest_count 1420 | 1421 | next_stmt: ldy #erri_bad_next 1422 | lda for_nest_count 1423 | Le8dc: beq go_errmess_4 1424 | tay 1425 | lda noun_stk_l,x 1426 | cmp fstk_varl-1,y 1427 | bne Le8d6 1428 | lda noun_stk_h_str,x 1429 | cmp fstk_varh-1,y 1430 | bne Le8d6 1431 | lda fstk_stepl-1,y 1432 | sta aux 1433 | lda fstk_steph-1,y 1434 | sta aux+1 1435 | jsr get16bit 1436 | dex 1437 | jsr Se793 1438 | jsr var_assign 1439 | dex 1440 | ldy for_nest_count 1441 | lda fstk_toh-1,y 1442 | sta syn_stk_l+31,x 1443 | lda fstk_tol-1,y 1444 | ldy #$00 1445 | jsr push_ya_noun_stk 1446 | jsr subtract_op 1447 | jsr sgn_fn 1448 | jsr get16bit 1449 | ldy for_nest_count 1450 | lda acc 1451 | beq Le925 1452 | eor fstk_steph-1,y 1453 | bpl Le937 1454 | Le925: lda fstk_plinel-1,y 1455 | sta pline 1456 | lda fstk_plineh-1,y 1457 | sta pline+1 1458 | ldx fstk_pverbl-1,y 1459 | lda fstk_pverbh-1,y 1460 | bne Le8be 1461 | Le937: dec for_nest_count 1462 | rts 1463 | 1464 | for_stmt: ldy #erri_too_many_fors 1465 | lda for_nest_count 1466 | cmp #$08 1467 | beq Le8dc 1468 | inc for_nest_count 1469 | tay 1470 | lda noun_stk_l,x 1471 | sta fstk_varl,y 1472 | lda noun_stk_h_str,x 1473 | sta fstk_varh,y 1474 | rts 1475 | 1476 | to_clause: jsr get16bit 1477 | ldy for_nest_count 1478 | lda acc 1479 | sta fstk_tol-1,y 1480 | lda acc+1 1481 | sta fstk_toh-1,y 1482 | lda #$01 1483 | sta fstk_stepl-1,y 1484 | lda #$00 1485 | Le966: sta fstk_steph-1,y 1486 | lda pline 1487 | sta fstk_plinel-1,y 1488 | lda pline+1 1489 | sta fstk_plineh-1,y 1490 | lda pverb 1491 | sta fstk_pverbl-1,y 1492 | lda pverb+1 1493 | sta fstk_pverbh-1,y 1494 | rts 1495 | 1496 | step_clause: jsr get16bit 1497 | ldy for_nest_count 1498 | lda acc 1499 | sta fstk_stepl-1,y 1500 | lda acc+1 1501 | jmp Le966 1502 | 1503 | fcb $00,$00,$00,$00,$00,$00,$00,$00 1504 | fcb $00,$00,$00 1505 | 1506 | 1507 | verb_prec_tbl: rmb $78 1508 | verb_addr_l: rmb $78 1509 | verb_addr_h: rmb $78 1510 | 1511 | verb $00,$00,begin_line 1512 | verb $01,$00,$ffff 1513 | verb $02,$00,$ffff 1514 | verb $03,$ab,colon 1515 | verb $04,$03,list_cmd 1516 | verb $05,$03,list_comman 1517 | verb $06,$03,list_all 1518 | verb $07,$03,run_cmd_w_lno ; RUN w/ line # 1519 | verb $08,$03,run_cmd ; RUN w/o line # 1520 | verb $09,$03,del_cmd ; DEL 1521 | verb $0a,$03,del_comma ; comma used with DEL 1522 | verb $0b,$03,new_cmd ; SCR (New) 1523 | verb $0c,$03,clr_cmd ; CLR 1524 | verb $0d,$03,auto_cmd ; AUTO 1525 | verb $0e,$03,auto_comma ; comma used with AUTO 1526 | verb $0f,$03,man_cmd ; MAN 1527 | verb $10,$03,himem_cmd ; HIMEM: 1528 | verb $11,$03,lomem_cmd ; LOMEM: 1529 | verb $12,$3f,add_op ; + 1530 | verb $13,$3f,subtract_op ; - 1531 | verb $14,$c0,multiply_op ; * 1532 | verb $15,$c0,divide_op ; / 1533 | verb $16,$3c,eq_op ; = 1534 | verb $17,$3c,neq_op ; # 1535 | verb $18,$3c,gt_eq_op ; >= 1536 | verb $19,$3c,gt_op ; > 1537 | verb $1a,$3c,lt_eq_op ; <= 1538 | verb $1b,$3c,neq_op ; <> 1539 | verb $1c,$3c,lt_op ; < 1540 | verb $1d,$30,and_op ; AND 1541 | verb $1e,$0f,or_op ; OR 1542 | verb $1f,$c0,mod_op ; MOD 1543 | verb $20,$cc,$0000 1544 | verb $21,$ff,$ffff 1545 | verb $22,$55,left_paren ; ( used in string DIM 1546 | verb $23,$00,comma_substr ; , 1547 | verb $24,$ab,goto_stmt ; THEN followed by a line number 1548 | verb $25,$ab,null_stmt ; THEN followed by a statement 1549 | verb $26,$03,string_input ; , used in string INPUT 1550 | verb $27,$03,input_num_comma ; , used in numeric input 1551 | verb $28,$ff,$ffff 1552 | verb $29,$ff,$ffff 1553 | verb $2a,$55,paren_substr ; ( substring 1554 | verb $2b,$ff,$ffff 1555 | verb $2c,$ff,$ffff 1556 | verb $2d,$55,num_array_subs ; ( variable array subscript 1557 | verb $2e,$cf,peek_fn ; PEEK 1558 | verb $2f,$cf,rnd_fn ; RND 1559 | verb $30,$cf,sgn_fn ; SGN 1560 | verb $31,$cf,abs_fn ; ABS 1561 | verb $32,$cf,$0000 ; USR 1562 | verb $33,$ff,$ffff 1563 | verb $34,$55,left_paren ; ( used in variable DIM 1564 | verb $35,$c3,unary_pos ; unary + 1565 | verb $36,$c3,negate ; unary - 1566 | verb $37,$c3,not_op ; NOT 1567 | verb $38,$55,left_paren ; ( numeric 1568 | verb $39,$f0,string_eq ; = string 1569 | verb $3a,$f0,string_neq ; # string 1570 | verb $3b,$cf,len_fn ; LEN( 1571 | verb $3c,$56,asc_fn ; ASC( XXX doesnt' work 1572 | verb $3d,$56,scrn_fn ; SCRN( ??? 1573 | verb $3e,$56,scrn_comma ; , used in SCRN 1574 | verb $3f,$55,left_paren ; ( 1575 | verb $40,$ff,$ffff 1576 | verb $41,$ff,$ffff 1577 | verb $42,$55,str_arr_dest ; ( for string index on left side of assignment 1578 | verb $43,$03,dim_str ; , for DIM string var 1579 | verb $44,$03,dim_num ; , for DIM numeric var 1580 | verb $45,$03,print_str ; ; string PRINT 1581 | verb $46,$03,print_num ; ; numeric PRINT 1582 | verb $47,$03,print_semi ; ; end of PRINT 1583 | verb $48,$03,print_str_comma ; , string PRINT 1584 | verb $49,$03,print_com_num ; , numeric PRINT 1585 | verb $4a,$ff,$ffff 1586 | verb $4b,$ff,$ffff 1587 | verb $4c,$ff,$ffff 1588 | verb $4d,$03,call_stmt ; CALL 1589 | verb $4e,$03,dim_str ; DIM string var 1590 | verb $4f,$03,dim_num ; DIM numeric var 1591 | verb $50,$03,tab_fn ; TAB 1592 | verb $51,$03,end_stmt ; END 1593 | verb $52,$03,string_input ; INPUT string with no prompt 1594 | verb $53,$03,input_prompt ; INPUT prompt 1595 | verb $54,$03,input_num_stmt ; INPUT numeric 1596 | verb $55,$03,for_stmt ; FOR 1597 | verb $56,$03,var_assign ; = in FOR 1598 | verb $57,$03,to_clause ; TO 1599 | verb $58,$03,step_clause ; STEP 1600 | verb $59,$03,next_stmt ; NEXT 1601 | verb $5a,$03,next_stmt ; , 1602 | verb $5b,$03,return_stmt ; RETURN 1603 | verb $5c,$03,gosub_stmt ; GOSUB 1604 | verb $5d,$00,$ffff ; REM 1605 | verb $5e,$ab,null_stmt ; LET 1606 | verb $5f,$03,goto_stmt ; GOTO 1607 | verb $60,$57,if_stmt ; IF 1608 | verb $61,$03,print_str ; PRINT string 1609 | verb $62,$03,print_num ; PRINT numeric 1610 | verb $63,$03,print_cr ; PRINT w/o arg 1611 | verb $64,$03,poke_stmt ; POKE 1612 | verb $65,$07,poke_comma ; , in POKE 1613 | verb $66,$03,color_stmt ; COLOR= ??? 1614 | verb $67,$03,$ef00 ; PLOT ??? 1615 | verb $68,$03,$ee3e ; , in PLOT ??? 1616 | verb $69,$03,$ef00 ; HLIN ??? 1617 | verb $6a,$03,$eea6 ; , in HLIN ??? 1618 | verb $6b,$03,$eeb0 ; AT in HLIN ??? 1619 | verb $6c,$03,$ef00 ; VLIN ??? 1620 | verb $6d,$03,$eebc ; , in VLIN ??? 1621 | verb $6e,$03,$eec6 ; AT in VLIN ??? 1622 | verb $6f,$03,$ee57 ; VTAB ??? 1623 | verb $70,$03,string_lit ; = string assginment 1624 | verb $71,$03,var_assign ; = numeric assignment 1625 | verb $72,$aa,right_paren ; ) 1626 | verb $73,$ff,$ffff 1627 | verb $74,$ff,$ffff 1628 | verb $75,$ff,$ffff 1629 | verb $76,$ff,$ffff 1630 | verb $77,$ff,$ffff 1631 | 1632 | 1633 | error_msg_tbl equ * 1634 | 1635 | erri_gr_32767 equ *-error_msg_tbl 1636 | errstr ">32767" 1637 | 1638 | erri_too_long equ *-error_msg_tbl 1639 | errstr "TOO LONG" 1640 | 1641 | erri_syntax equ *-error_msg_tbl 1642 | errstr "SYNTAX" 1643 | 1644 | erri_mem_full equ *-error_msg_tbl 1645 | errstr "MEM FULL" 1646 | 1647 | erri_too_many_parens equ *-error_msg_tbl 1648 | errstr "TOO MANY PARENS" 1649 | 1650 | erri_string equ *-error_msg_tbl 1651 | errstr "STRING" 1652 | 1653 | erri_no_end equ *-error_msg_tbl 1654 | fcs "NO " 1655 | 1656 | erri_end equ *-error_msg_tbl 1657 | errstr "END" 1658 | 1659 | erri_bad_branch equ *-error_msg_tbl 1660 | errstr "BAD BRANCH" 1661 | 1662 | erri_too_many_gosubs equ *-error_msg_tbl 1663 | errstr ">8 GOSUBS" 1664 | 1665 | erri_bad_return equ *-error_msg_tbl 1666 | errstr "BAD RETURN" 1667 | 1668 | erri_too_many_fors equ *-error_msg_tbl 1669 | errstr ">8 FORS" 1670 | 1671 | erri_bad_next equ *-error_msg_tbl 1672 | errstr "BAD NEXT" 1673 | 1674 | erri_stopped_at equ *-error_msg_tbl 1675 | errstr "STOPPED AT " 1676 | 1677 | erri_err equ *-error_msg_tbl 1678 | errstr "*** " 1679 | fcs " ERR" 1680 | fcb ch_cr 1681 | 1682 | erri_gr_255 equ *-error_msg_tbl 1683 | errstr ">255" 1684 | 1685 | erri_range equ *-error_msg_tbl 1686 | errstr "RANGE" 1687 | 1688 | erri_dim equ *-error_msg_tbl 1689 | errstr "DIM" 1690 | 1691 | erri_str_ovfl equ *-error_msg_tbl 1692 | errstr "STR OVFL" 1693 | 1694 | fcb $dc ; backslash 1695 | fcb ch_cr 1696 | 1697 | erri_retype_line equ *-error_msg_tbl 1698 | fcs "RETYPE LINE" 1699 | fcb ch_cr+$80,'?' 1700 | 1701 | 1702 | Leb9a: lsr run_flag 1703 | bcc Leba1 1704 | jmp Le8c3 1705 | Leba1: ldx acc+1 1706 | txs 1707 | ldx acc 1708 | ldy #$8d 1709 | bne Lebac 1710 | 1711 | input_num_stmt: ldy #$99 1712 | Lebac: jsr Se3c4 1713 | stx acc 1714 | tsx 1715 | stx acc+1 1716 | ldy #$fe 1717 | sty run_flag 1718 | iny 1719 | sty text_index 1720 | jsr Se299 1721 | sty token_index 1722 | ldx #$20 1723 | lda #$30 1724 | jsr Se491 1725 | inc run_flag 1726 | ldx acc 1727 | 1728 | input_num_comma: ldy text_index 1729 | asl a 1730 | Lebce: sta acc 1731 | iny 1732 | lda buffer,y 1733 | cmp #$74 1734 | beq input_num_stmt 1735 | eor #$b0 1736 | cmp #$0a 1737 | bcs Lebce 1738 | iny 1739 | iny 1740 | sty text_index 1741 | lda buffer,y 1742 | pha 1743 | lda buffer-1,y 1744 | ldy #$00 1745 | jsr push_ya_noun_stk 1746 | pla 1747 | sta noun_stk_h_int,x 1748 | lda acc 1749 | cmp #$c7 1750 | bne Lebfa 1751 | jsr negate 1752 | Lebfa: jmp var_assign 1753 | 1754 | fcb $ff,$ff,$ff,$50 1755 | 1756 | lt_op: jsr gt_eq_op 1757 | bne Lec1b 1758 | 1759 | gt_op: jsr lt_eq_op 1760 | bne Lec1b 1761 | 1762 | lt_eq_op: jsr subtract_op 1763 | jsr negate 1764 | bvc Lec16 1765 | 1766 | gt_eq_op: jsr subtract_op 1767 | Lec16: jsr sgn_fn 1768 | lsr noun_stk_l,x 1769 | Lec1b: jmp not_op 1770 | 1771 | fcb $ff,$ff 1772 | 1773 | category_table: 1774 | fcb ((syn_cat_00-1)/2)&$ff 1775 | fcb $ff 1776 | fcb ((syn_cat_02-1)/2)&$ff 1777 | fcb $d1 ; $03 1778 | fcb ((syn_cat_04-1)/2)&$ff 1779 | fcb ((syn_cat_05-1)/2)&$ff 1780 | fcb ((syn_cat_06-1)/2)&$ff 1781 | fcb ((syn_cat_07-1)/2)&$ff ; numeric expressoin 1782 | fcb ((syn_cat_08-1)/2)&$ff 1783 | fcb ((syn_cat_09-1)/2)&$ff 1784 | fcb ((syn_cat_0a-1)/2)&$ff 1785 | fcb ((syn_cat_0b-1)/2)&$ff ; statement 1786 | fcb ((syn_cat_0c-1)/2)&$ff 1787 | fcb ((syn_cat_0d-1)/2)&$ff 1788 | fcb ((syn_cat_0e-1)/2)&$ff 1789 | fcb ((syn_cat_0f-1)/2)&$ff 1790 | fcb ((syn_cat_10-1)/2)&$ff 1791 | fcb ((syn_cat_11-1)/2)&$ff 1792 | fcb ((syn_cat_12-1)/2)&$ff 1793 | fcb $2b ; $13 1794 | fcb ((syn_cat_14-1)/2)&$ff ; function 1795 | fcb ((syn_cat_15-1)/2)&$ff 1796 | fcb ((syn_cat_16-1)/2)&$ff 1797 | fcb ((syn_cat_17-1)/2)&$ff 1798 | fcb $35 ; $18 1799 | fcb $8e ; $19: numeric variable name 1800 | fcb ((syn_cat_1a-1)/2)&$ff 1801 | fcb $ff 1802 | fcb $ff 1803 | fcb $ff 1804 | fcb ((syn_cat_1e-1)/2)&$ff ; binary operator 1805 | fcb ((syn_cat_1f-1)/2)&$ff 1806 | 1807 | and_op: jsr Sefc9 1808 | ora rnd+1,x 1809 | bpl Lec4c 1810 | 1811 | or_op: jsr Sefc9 1812 | and rnd+1,x 1813 | Lec4c: sta noun_stk_l,x 1814 | bpl Lec1b 1815 | jmp Sefc9 1816 | 1817 | ; syntax tables 1818 | fcb $40 ; cat 00, end of category 1819 | 1820 | fcb $60 ; unsigned integer, end of rule 1821 | synstr "-" 1822 | syn_cat_13: 1823 | 1824 | fcb $60 ; cat 00, end of rule 1825 | synstr "+" 1826 | 1827 | fcb $00 1828 | 1829 | fcb $7e ; branch "backward" two bytes 1830 | synstr "," 1831 | fcb $33 1832 | syn_cat_12: 1833 | 1834 | fcb $00 1835 | fcb $00 1836 | 1837 | fcb $60 ; cat 00, end of rule 1838 | fcb $03 ; string literal 1839 | synstr "_" 1840 | fcb $12 1841 | 1842 | fcb $00 ; return with syntax error 1843 | fcb $40 1844 | synstr ")" 1845 | syn_cat_11: 1846 | 1847 | synstr1 ")" 1848 | 1849 | fcb $47 1850 | synstr "=" 1851 | fcb $17 1852 | syn_cat_18: 1853 | 1854 | fcb $68 1855 | synstr "=" 1856 | fcb $0a 1857 | 1858 | fcb $00 ; return with syntax error 1859 | fcb $40 1860 | 1861 | fcb $60 1862 | synstr "-" 1863 | 1864 | fcb $60 1865 | synstr "+" 1866 | 1867 | fcb $00 ; return with syntax error 1868 | fcb $7e ; branch "backward" two bytes 1869 | synstr "," 1870 | fcb $3c 1871 | 1872 | fcb $00 1873 | 1874 | fcb $00 ; return with syntax error 1875 | 1876 | fcb $60 1877 | fcb $03 ; string literal 1878 | synstr "_" 1879 | fcb $1b 1880 | fcb $4b 1881 | 1882 | fcb $67 ; numeric expression, end of rule 1883 | synstr "AT" 1884 | fcb $07 ; numeric expression 1885 | synstr "," 1886 | fcb $07 ; numeric expression 1887 | synstr "HLIN" 1888 | 1889 | fcb $67 ; numeric expression, end of rule 1890 | synstr "," 1891 | fcb $07 ; numeric expression 1892 | synstr "PLOT" 1893 | 1894 | fcb $67 ; numeric expression, end of rule 1895 | synstr "COLOR=" 1896 | 1897 | fcb $67 ; numeric expression, end of rule 1898 | synstr "," 1899 | fcb $07 ; numeric expression 1900 | synstr "POKE" 1901 | 1902 | synstr1 "PRINT" 1903 | 1904 | fcb $7f ; branch "backward" one byte 1905 | fcb $0e 1906 | fcb $27 1907 | synstr "PRINT" 1908 | 1909 | fcb $7f ; branch "backward" one byte 1910 | fcb $0e 1911 | fcb $28 1912 | synstr "PRINT" 1913 | 1914 | fcb $64 1915 | fcb $07 ; numeric expressoin 1916 | synstr "IF" 1917 | 1918 | fcb $67 1919 | synstr "GOTO" 1920 | 1921 | fcb $78 1922 | synstr "LET" 1923 | 1924 | fcb $78 ; end of rule 1925 | fcb $7f ; branch "backward" one byte 1926 | fcb $02 ; comment characte 1927 | synstr "REM" 1928 | syn_cat_1a: 1929 | 1930 | fcb $67 ; numeric expression, end of rule 1931 | synstr "GOSUB" 1932 | 1933 | synstr1 "RETURN" 1934 | 1935 | fcb $7e ; branch "backward" two bytes 1936 | synstr "," 1937 | fcb $39 1938 | synstr "NEXT" 1939 | 1940 | fcb $67 ; numeric expression, end of rule 1941 | synstr "STEP" 1942 | fcb $27 ; numeric expression, rest optional 1943 | synstr "TO" 1944 | fcb $07 ; numeric expression 1945 | synstr "=" 1946 | fcb $19 1947 | synstr "FOR" 1948 | 1949 | fcb $7f ; branch "backward" one byte 1950 | fcb $05 1951 | fcb $37 1952 | synstr "INPUT" 1953 | 1954 | fcb $7f ; branch "backward" one byte 1955 | fcb $05 1956 | fcb $28 1957 | synstr "INPUT" 1958 | 1959 | fcb $7f ; branch "backward" one byte 1960 | fcb $05 1961 | fcb $2a 1962 | synstr "INPUT" 1963 | 1964 | synstr1 "END" 1965 | syn_cat_02: 1966 | 1967 | fcb $00 1968 | fcb $ff 1969 | fcb $ff 1970 | 1971 | fcb $47 ; numeric expression, end of category 1972 | synstr "TAB" 1973 | 1974 | fcb $7f ; branch "backward" one byte 1975 | fcb $0d 1976 | fcb $30 1977 | synstr "DIM" 1978 | 1979 | fcb $7f ; branch "backward" one byte 1980 | fcb $0d ; category 0d, required 1981 | fcb $23 ; category 03, optional 1982 | synstr "DIM" 1983 | 1984 | fcb $67 ; numeric expression, end of rule 1985 | synstr "CALL" 1986 | syn_cat_0b: 1987 | 1988 | fcb $00 1989 | 1990 | fcb $40 ; unsigned integer, end of category 1991 | fcb $80 ; letter A-Z 1992 | syn_cat_19: 1993 | 1994 | fcb $c0 1995 | fcb $c1 1996 | fcb $80 1997 | fcb $00 1998 | 1999 | fcb $47 ; numeric expression, end of category 2000 | synstr "," 2001 | fcb $68 2002 | synstr "," 2003 | fcb $db 2004 | 2005 | fcb $67 ; numeric expression, end of rule 2006 | synstr ";" 2007 | fcb $68 2008 | synstr ";" 2009 | syn_cat_0e: 2010 | 2011 | fcb $50 2012 | synstr "," 2013 | fcb $63 2014 | synstr "," 2015 | syn_cat_0d: 2016 | 2017 | fcb $7f ; branch "backward" one byte 2018 | fcb $01 ; return with no error 2019 | syn_cat_0c: 2020 | 2021 | fcb $51 2022 | fcb $07 ; numeric expression 2023 | fcb $88 2024 | syn_cat_0a: 2025 | 2026 | fcb $29 2027 | fcb $84 2028 | fcb $80 2029 | fcb $c4 2030 | syn_cat_09: 2031 | 2032 | fcb $80 2033 | fcb $57 2034 | fcb $71 2035 | fcb $07 ; numeric expression 2036 | synstr "(" 2037 | fcb $14 2038 | 2039 | synstr1 "LOMEM" 2040 | 2041 | synstr1 "HIMEM" 2042 | 2043 | synstr1 "COLOR" 2044 | 2045 | fcb $71 2046 | fcb $08 2047 | synstr "LEN(" 2048 | 2049 | fcb $68 2050 | fcb $83 2051 | fcb $08 2052 | 2053 | fcb $68 2054 | synstr "=" 2055 | fcb $08 2056 | 2057 | fcb $71 ; cat 11, end of rule 2058 | fcb $07 ; numeric expression 2059 | synstr "(" 2060 | syn_cat_16: 2061 | 2062 | fcb $60 ; cat 00, end of rule 2063 | 2064 | fcb $76 ; cat 16, end of rule 2065 | synstr "NOT" 2066 | 2067 | fcb $76 ; cat 16, end of rule 2068 | synstr "-" 2069 | 2070 | fcb $76 ; cat 16, end of rule 2071 | synstr "+" 2072 | syn_cat_15: 2073 | 2074 | fcb $51 2075 | fcb $07 2076 | synstr "(" 2077 | fcb $19 2078 | syn_cat_10: 2079 | 2080 | synstr "RNDX" ; can never be matched since it 2081 | ; comes "after" RND 2082 | 2083 | synstr1 "USR" 2084 | 2085 | synstr1 "ABS" 2086 | 2087 | synstr1 "SGN" 2088 | 2089 | synstr1 "RND" 2090 | 2091 | synstr1 "PEEK" 2092 | syn_cat_14: 2093 | 2094 | fcb $51 2095 | fcb $07 ; numeric expression 2096 | synstr "(" 2097 | syn_cat_17: 2098 | 2099 | fcb $39 2100 | synstr "!" 2101 | syn_cat_0f: 2102 | 2103 | fcb $c1 ; parse 0-9, end of rule 2104 | 2105 | fcb $4f ; cat 15, end of category 2106 | fcb $7f ; branch "backward" one byte 2107 | fcb $0f ; cat 15 2108 | syn_cat_00: 2109 | 2110 | fcb $2f ; cat 15 2111 | fcb $00 2112 | fcb $51 2113 | fcb $06 2114 | synstr "(" 2115 | fcb $29 2116 | fcb $c2 2117 | fcb $0c 2118 | syn_cat_08: 2119 | 2120 | synstr "\"" 2121 | fcb $57 2122 | synstr "," 2123 | fcb $6a 2124 | syn_cat_05: 2125 | 2126 | synstr "," 2127 | fcb $42 2128 | synstr "THEN" 2129 | 2130 | fcb $60 2131 | synstr "THEN" 2132 | syn_cat_04: 2133 | 2134 | fcb $4f 2135 | fcb $7e ; branch "backward" two bytes 2136 | fcb $1e 2137 | syn_cat_07: 2138 | fcb $35 2139 | synstr "," 2140 | syn_cat_06: 2141 | 2142 | fcb $27 ; optional reset, numeric expr 2143 | 2144 | fcb $51 2145 | fcb $07 ; numeric expr 2146 | synstr "(" 2147 | 2148 | fcb $09 2149 | synstr "+" 2150 | syn_cat_03: 2151 | 2152 | synstr1 "^" 2153 | synstr1 "MOD" 2154 | synstr1 "OR" 2155 | synstr1 "AND" 2156 | synstr1 "<" 2157 | synstr1 "<>" 2158 | synstr1 "<=" 2159 | synstr1 ">" 2160 | synstr1 ">=" 2161 | synstr1 "#" 2162 | synstr1 "=" 2163 | synstr1 "/" 2164 | synstr1 "*" 2165 | synstr1 "-" 2166 | synstr1 "+" 2167 | syn_cat_1e: 2168 | 2169 | fcb $00 2170 | 2171 | fcb $47 2172 | synstr "LOMEM=" 2173 | 2174 | fcb $76 2175 | synstr "HIMEM=" 2176 | 2177 | synstr1 "OFF" 2178 | 2179 | fcb $60 ; unsigned integer, end of rule 2180 | synstr "," 2181 | fcb $20 ; (optional) unsigned integer 2182 | synstr "AUTO" 2183 | 2184 | synstr1 "CLR" 2185 | 2186 | synstr1 "SCR" 2187 | 2188 | fcb $60 ; unsgined integer, end of rule 2189 | synstr "," 2190 | fcb $20 ; (optional) unsigned integer 2191 | synstr "DEL" 2192 | 2193 | synstr1 "RUN" ; RUN with no line number 2194 | 2195 | fcb $60 ; unsigned integer, end of rule 2196 | synstr "RUN" 2197 | 2198 | synstr1 "LIST" 2199 | 2200 | fcb $60 ; unsigned integer, end of rule 2201 | synstr "," 2202 | fcb $20 ; (optional) unsigned integer 2203 | synstr "LIST" 2204 | 2205 | fcb $7a 2206 | fcb $7e ; branch "backward" two bytes 2207 | fcb $9a 2208 | fcb $22 2209 | fcb $20 ; (optional) unsigned integer 2210 | syn_cat_1f: 2211 | 2212 | fcb $00 2213 | fcb $60 2214 | fcb $03 ; string literal 2215 | fcb $bf 2216 | fcb $60 2217 | fcb $03 2218 | fcb $bf 2219 | fcb $1f 2220 | 2221 | print_str_comma: jsr tabout 2222 | 2223 | print_str: inx 2224 | inx 2225 | lda rnd+1,x 2226 | sta aux 2227 | lda syn_stk_h+31,x 2228 | sta aux+1 2229 | ldy rnd,x 2230 | Lee0f: tya 2231 | cmp syn_stk_h+30,x 2232 | bcs Lee1d 2233 | lda (aux),y 2234 | jsr cout 2235 | iny 2236 | jmp Lee0f 2237 | Lee1d: lda #$ff 2238 | sta cr_flag 2239 | rts 2240 | 2241 | len_fn: inx 2242 | lda #$00 2243 | sta noun_stk_h_str,x 2244 | sta noun_stk_h_int,x 2245 | lda syn_stk_h+31,x 2246 | sec 2247 | sbc rnd+1,x 2248 | sta noun_stk_l,x 2249 | jmp left_paren 2250 | 2251 | fcb $ff 2252 | 2253 | getbyte: jsr get16bit 2254 | lda acc+1 2255 | bne gr_255_err 2256 | lda acc 2257 | rts 2258 | 2259 | plot_comma: jsr getbyte 2260 | ldy text_index 2261 | cmp #$30 2262 | bcs range_err 2263 | cpy #$28 2264 | bcs range_err 2265 | rts 2266 | 2267 | nop 2268 | nop 2269 | 2270 | ; COLOR= statement not usable on Apple 1 2271 | color_stmt: jsr getbyte 2272 | rts 2273 | 2274 | nop 2275 | nop 2276 | 2277 | man_cmd: lsr auto_flag 2278 | rts 2279 | 2280 | vtab_stmt: jsr getbyte 2281 | cmp #$18 2282 | bcs range_err 2283 | sta cv 2284 | rts 2285 | 2286 | nop 2287 | nop 2288 | 2289 | gr_255_err: ldy #erri_gr_255 2290 | go_errmess_5: jmp do_error 2291 | 2292 | range_err: ldy #erri_range 2293 | bne go_errmess_5 2294 | 2295 | See6c: jsr Se254 2296 | lda aux 2297 | bne Lee7a 2298 | lda aux+1 2299 | bne Lee7a 2300 | jmp Le77e 2301 | Lee7a: asl acc 2302 | rol acc+1 2303 | rol p3 2304 | rol p3+1 2305 | lda p3 2306 | cmp aux 2307 | lda p3+1 2308 | sbc aux+1 2309 | bcc Lee96 2310 | sta p3+1 2311 | lda p3 2312 | sbc aux 2313 | sta p3 2314 | inc acc 2315 | Lee96: dey 2316 | bne Lee7a 2317 | rts 2318 | 2319 | fcb $ff,$ff,$ff,$ff,$ff,$ff 2320 | 2321 | call_stmt: jsr get16bit 2322 | jmp (acc) 2323 | 2324 | fcb $20,$34,$ee,$c5,$c8,$90,$bb,$85 2325 | 2326 | ; SCRN function not usable on Apple 1 2327 | scrn_fn: lda himem+1 2328 | 2329 | Teeb0: pha 2330 | lda himem 2331 | jsr push_ya_noun_stk 2332 | pla 2333 | sta noun_stk_h_int,x 2334 | rts 2335 | 2336 | scrn_comma: lda lomem+1 2337 | 2338 | Teebc: pha 2339 | lda lomem 2340 | jmp Lefb3 2341 | 2342 | ; bogus code, ASC function doesn't work 2343 | asc_fn: fcb $a5,$85,$2d,$60 2344 | 2345 | Teec6: jsr getbyte 2346 | cmp #$28 2347 | Leecb: bcs range_err 2348 | tay 2349 | lda text_index 2350 | rts 2351 | 2352 | nop 2353 | nop 2354 | 2355 | print_err_msg: tya 2356 | tax 2357 | ldy #$6e 2358 | jsr Se3c4 2359 | txa 2360 | tay 2361 | jsr Se3c4 2362 | ldy #$72 2363 | jmp Se3c4 2364 | 2365 | Seee4: jsr get16bit 2366 | Leee7: asl acc 2367 | rol acc+1 2368 | bmi Leee7 2369 | bcs Leecb 2370 | bne Leef5 2371 | cmp acc 2372 | bcs Leecb 2373 | Leef5: rts 2374 | 2375 | peek_fn: jsr get16bit 2376 | lda (acc),y 2377 | sty syn_stk_l+31,x 2378 | jmp push_ya_noun_stk 2379 | 2380 | poke_stmt: jsr getbyte 2381 | lda acc 2382 | pha 2383 | jsr get16bit 2384 | pla 2385 | sta (acc),y 2386 | 2387 | poke_comma: rts 2388 | 2389 | fcb $ff,$ff,$ff 2390 | 2391 | divide_op: jsr See6c 2392 | lda acc 2393 | sta p3 2394 | lda acc+1 2395 | sta p3+1 2396 | jmp Le244 2397 | 2398 | dim_num: jsr Seee4 2399 | jmp Le134 2400 | 2401 | num_array_subs: jsr Seee4 2402 | ldy noun_stk_h_str,x 2403 | lda noun_stk_l,x 2404 | adc #$fe 2405 | bcs Lef30 2406 | dey 2407 | Lef30: sta aux 2408 | sty aux+1 2409 | clc 2410 | adc acc 2411 | sta noun_stk_l,x 2412 | tya 2413 | adc acc+1 2414 | sta noun_stk_h_str,x 2415 | ldy #$00 2416 | lda noun_stk_l,x 2417 | cmp (aux),y 2418 | iny 2419 | lda noun_stk_h_str,x 2420 | sbc (aux),y 2421 | bcs Leecb 2422 | jmp left_paren 2423 | 2424 | rnd_fn: jsr get16bit 2425 | lda rnd 2426 | jsr push_ya_noun_stk 2427 | lda rnd+1 2428 | bne Lef5e 2429 | cmp rnd 2430 | adc #$00 2431 | Lef5e: and #$7f 2432 | sta rnd+1 2433 | sta noun_stk_h_int,x 2434 | ldy #$11 2435 | Lef66: lda rnd+1 2436 | asl 2437 | clc 2438 | adc #$40 2439 | asl 2440 | rol rnd 2441 | rol rnd+1 2442 | dey 2443 | bne Lef66 2444 | lda acc 2445 | jsr push_ya_noun_stk 2446 | lda acc+1 2447 | sta noun_stk_h_int,x 2448 | jmp mod_op 2449 | 2450 | himem_cmd: jsr get16bit 2451 | ldy acc 2452 | cpy lomem 2453 | lda acc+1 2454 | sbc lomem+1 2455 | bcc Lefab 2456 | sty himem 2457 | lda acc+1 2458 | sta himem+1 2459 | Lef93: jmp new_cmd 2460 | 2461 | lomem_cmd: jsr get16bit 2462 | ldy acc 2463 | cpy himem 2464 | lda acc+1 2465 | sbc himem+1 2466 | bcs Lefab 2467 | sty lomem 2468 | lda acc+1 2469 | sta lomem+1 2470 | bcc Lef93 2471 | Lefab: jmp Leecb 2472 | 2473 | fcb $a5,$4d,$48,$a5,$4c 2474 | 2475 | Lefb3: jsr Sefc9 2476 | 2477 | string_input: jsr input_str 2478 | jmp Lefbf 2479 | 2480 | input_prompt: jsr print_str 2481 | Lefbf: lda #$ff 2482 | sta text_index 2483 | lda #$74 2484 | sta buffer 2485 | rts 2486 | 2487 | Sefc9: jsr not_op 2488 | inx 2489 | 2490 | Sefcd: jsr not_op 2491 | lda noun_stk_l,x 2492 | rts 2493 | 2494 | mem_init_4k: lda #$00 2495 | sta lomem 2496 | sta himem 2497 | lda #$08 2498 | sta lomem+1 2499 | lda #$10 2500 | sta himem+1 2501 | jmp new_cmd 2502 | 2503 | Sefe4: cmp noun_stk_h_str,x 2504 | bne Lefe9 2505 | clc 2506 | Lefe9: jmp Le102 2507 | 2508 | run_cmd: jsr clr_cmd 2509 | jmp run_warm 2510 | 2511 | run_cmd_w_lno: jsr clr_cmd 2512 | jmp goto_stmt 2513 | 2514 | Seff8: cpx #$80 2515 | bne Leffd 2516 | dey 2517 | Leffd: jmp Se00c 2518 | --------------------------------------------------------------------------------