[Coco] Re: Re: CoCo related question? (Better edit for coco3.rom)

Albert Stinger albertstinger24 at canada.com
Thu Mar 24 01:38:30 EST 2005


After a quick check for size I think the enhanced edit patch into BASIC
edit command should work. Now all I need is for a nice screen editor
coded in 6809 assembly language It must fit in a free area in the rom.

See the dis-assembly below of the instructions that was involved in
the patch for edit command.

Albert Stinger

(C) BY MICROSOFT

*I
00100 START   JSR     $AF67
00110         BCC     CHK
00120         JMP     $89AE
00130 CHK     LEAS    4,S
00140         JMP     $C000
00150         END
00160
*A/WE/NO
0000 BD   AF67     00100 START   JSR     $AF67
0003 24   03       00110         BCC     CHK
0005 7E   89AE     00120         JMP     $89AE
0008 32   64       00130 CHK     LEAS    4,S
000A 7E   C000     00140         JMP     $C000
          0000     00150         END

00000 TOTAL ERRORS

CHK     0008
START   0000

 * The checking for enhanced edit command command
 * This code will be patched into the memory stating
 * at $A064 - $A072 which is 12 bytes.
 *
 CHKEDEX JSR LAF67  * CONVERT LINE NUMBER TO BINARY, RETURN VALUE IN BINVAL
  BCC CHKED  * IF NOT LINE NUMBER, BETTER BE ENHANCED EDIT
  JMP L89AE  * GO GET LINE NUMBER AND RETURN TO EDIT
 CHKED LEAS $04,S  * PURGE RETURN ADDRESSES OFF OF THE STACK
  JMP EDITEX  * MUST BE ENHANCED EDIT JUMPING THERE
 *
 * EDIT - if you enter EDIT [LINE NUMBER] in the CONSOLE you come here.
 *
 EDIT JSR CHKEDEX  * GET LINE NUMBER FROM BASIC
  LEAS $02,S  * PURGE RETURN ADDRESS OFF OF THE STACK
 L8538 LDA #$01  * 'LIST' FLAG
  STA VD8   * SET FLAG TO LIST LINE
  JSR LAD01  * GO FIND THE LINE NUMBER IN PROGRAM
  LBCS LAED2  * ERROR #7 'UNDEFINED LINE #'
  JSR LB7C2  * GO UNCRUNCH LINE INTO BUFFER AT LINBUF+1
  TFR Y,D   * PUT ABSOLUTE ADDRESS OF END OF LINE TO ACCD
  SUBD #LINBUF+2  * SUBTRACT OUT THE START OF LINE
  STB VD7   * SAVE LENGTH OF LINE
 L854D LDD BINVAL  * GET THE HEX VALUE OF LINE NUMBER
  JSR LBDCC  * LIST THE LINE NUMBER ON THE SCREEN
  JSR LB9AC  * PRINT A SPACE
  LDX #LINBUF+1  * POINT X TO BUFFER
  LDB VD8   * CHECK TO SEE IF LINE IS TO BE
  BNE L8581  * LISTED TO SCREEN - BRANCH IF IT IS
 L855C CLRB   * RESET DIGIT ACCUMULATOR - DEFAULT VALUE
 L855D JSR L8687  * GET KEY STROKE
  JSR L90AA  * SET CARRY IF NOT NUMERIC
  BLO L8570  * BRANCH IF NOT NUMERIC
  SUBA #'0'  * MASK OFF ASCII
  PSHS A   * SAVE IT ON STACK
  LDA #10   * NUMBER BEING CONVERTED IS BASE 10
  MUL   * MULTIPLY ACCUMULATED VALUE BY BASE (10)
  ADDB ,S+  * ADD DIGIT TO ACCUMULATED VALUE
  BRA L855D  * CHECK FOR ANOTHER DIGIT
 L8570 SUBB #$01  * REPEAT PARAMETER IN ACCB; IF IT
  ADCB #$01  * IS 0, THEN MAKE IT '1'
  CMPA #'A'  * ABORT?
  BNE L857D  * NO
  JSR LB958  * PRINT CARRIAGE RETURN TO SCREEN
  BRA L8538  * RESTART EDIT PROCESS - CANCEL ALL CHANGES
 L857D CMPA #'L'  * LIST?
  BNE L858C  * NO
 L8581 BSR L85B4  * LIST THE LINE
  CLR VD8   * RESET THE LIST FLAG TO 'NO LIST'
  JSR LB958  * PRINT CARRIAGE RETURN
  BRA L854D  * GO INTERPRET ANOTHER EDIT COMMAND
 L858A LEAS $02,S  * PURGE RETURN ADDRESS OFF OF THE STACK
 L858C CMPA #CR  * ENTER KEY?
  BNE L859D  * NO
  BSR L85B4  * ECHO THE LINE TO THE SCREEN
 L8592 JSR LB958  * PRINT CARRIAGE RETURN
  LDX #LINBUF+1  * RESET BASIC'S INPUT POINTER
  STX CHARAD  * TO THE LINE INPUT BUFFER
  JMP LACA8  * GO PUT LINE BACK IN PROGRAM
 L859D CMPA #'E'  * EXIT?
  BEQ L8592  * YES - SAME AS ENTER EXCEPT NO ECHO
  CMPA #'Q'  * QUIT?
  BNE L85AB  * NO
  JSR LB958  * PRINT CARRIAGE RETURN TO SCREEN
  JMP LAC73  * GO TO COMMAND LEVEL - MAKE NO CHANGES
 L85AB BSR L85AF  * INTERPRET THE REMAINING COMMANDS AS SUBROUTINES
  BRA L855C  * GO INTERPRET ANOTHER EDIT COMMAND
 L85AF CMPA #SPACE  * SPACE BAR?
  BNE L85C3  * NO
 L85B3 FCB SKP2  * SKIP TWO BYTES
 *
 * THE NEXT ACCB BYTES OF THE LINE IN THE BUFFER TO THE SCREEN
 *
 L85B4 LDB #LBUFMX-1  * 250 BYTES MAX IN BUFFER
 L85B6 LDA ,X   * GET A CHARACTER FROM BUFFER
  BEQ L85C2  * EXIT IF IT'S A 0
  JSR LA282  * SEND CHAR TO CONSOLE OUT
  LEAX $01,X  * MOVE POINTER UP ONE
  DECB   * DECREMENT CHARACTER COUNTER
  BNE L85B6  * LOOP IF NOT DONE
 L85C2 RTS              * 
 L85C3 CMPA #'D'  * DELETE?
  BNE L860F  * NO
 L85C7 TST ,X   * CHECK FOR END OF LINE
  BEQ L85C2  * AND BRANCH IF SO
  BSR L85D1  * REMOVE A CHARACTER
  DECB   * DECREMENT REPEAT PARAMETER
  BNE L85C7  * BRANCH IF NOT DONE
  RTS   * ONE CHARACTER FROM BUFFER
 *
 * REMOVE ONE CHARACTER FROM BUFFER
 *
 L85D1 DEC VD7   * DECREMENT LENGTH OF BUFFER
  LEAY $-01,X  * POINT Y TO ONE BEFORE CURRENT BUFFER POINTER
 L85D5 LEAY $01,Y  * INCREMENT TEMPORARY BUFFER POINTER
  LDA $01,Y  * GET NEXT CHARACTER
  STA ,Y   * PUT IT IN CURRENT POSITION
  BNE L85D5  * BRANCH IF NOT END OF LINE
  RTS   *
 L85DE CMPA #'I'  * INSERT?
  BEQ L85F5  * YES
  CMPA #'X'  * EXTEND?
  BEQ L85F3  * YES
  CMPA #'H'  * HACK?
  BNE L8646  * NO
  CLR ,X   * TURN CURRENT BUFFER POINTER INTO END OF LINE FLAG
  TFR X,D   * PUT CURRENT BUFFER POINTER IN ACCD
  SUBD #LINBUF+2  * SUBTRACT INITIAL POINTER POSITION
  STB VD7   * SAVE NEW BUFFER LENGTH
 L85F3 BSR L85B4  * DISPLAY THE LINE ON THE SCREEN
 L85F5 JSR L8687  * GET A KEYSTROKE
  CMPA #CR  * ENTER KEY?
  BEQ L858A  * YES - INTERPRET ANOTHER COMMAND - PRINT LINE
  CMPA #ESC  * ESCAPE?
  BEQ L8625  * YES - RETURN TO COMMAND LEVEL - DON'T PRINT LINE
  CMPA #BS  * BACK SPACE?
  BNE L8626  * NO
  CMPX #LINBUF+1  * COMPARE POINTER TO START OF BUFFER
  BEQ L85F5  * DO NOT ALLOW BS IF AT START
  BSR L8650  * MOVE POINTER BACK ONE, BS TO SCREEN
  BSR L85D1  * REMOVE ONE CHARACTER FROM BUFFER
  BRA L85F5  * GET INSERT SUB COMMAND
 L860F CMPA #'C'  * CHANGE?
  BNE L85DE  * NO
 L8613 TST ,X   * CHECK CURRENT BUFFER CHARACTER
  BEQ L8625  * BRANCH IF END OF LINE
  JSR L8687  * GET A KEYSTROKE
  BLO L861E  * BRANCH IF LEGITIMATE KEY
  BRA L8613  * TRY AGAIN IF ILLEGAL KEY
 L861E STA ,X+   * INSERT NEW CHARACTER INTO BUFFER
  BSR L8659  * SEND NEW CHARACTER TO SCREEN
  DECB   * DECREMENT REPEAT PARAMETER
  BNE L8613  * BRANCH IF NOT DONE
 L8625 RTS   * 
 L8626 LDB VD7   * GET LENGTH OF LINE
  CMPB #LBUFMX-1  * COMPARE TO MAXIMUM LENGTH
  BNE L862E  * BRANCH IF NOT AT MAXIMUM
  BRA L85F5  * IGNORE INPUT IF LINE AT MAXIMUM LENGTH
 L862E PSHS X   * SAVE CURRENT BUFFER POINTER
 L8630 TST ,X+   * SCAN THE LINE UNTIL END OF
  BNE L8630  * LINE (0) IS FOUND
 L8634 LDB ,-X   * DECR TEMP LINE POINTER AND GET A CHARACTER
  STB $01,X  * PUT CHARACTER BACK DOWN ONE SPOT
  CMPX ,S   * HAVE WE REACHED STARTING POINT?
  BNE L8634  * NO - KEEP GOING
  LEAS $02,S  * PURGE BUFFER POINTER FROM STACK
  STA ,X+   * INSERT NEW CHARACTER INTO THE LINE
  BSR L8659  * SEND A CHARACTER TO CONSOLE OUT
  INC VD7   * ADD ONE TO BUFFER LENGTH
  BRA L85F5  * GET INSERT SUB COMMAND
 L8646 CMPA #BS  * BACKSPACE?
  BNE L865C  * NO
 L864A BSR L8650  * MOVE POINTER BACK 1, SEND BS TO SCREEN
  DECB   * DECREMENT REPEAT PARAMETER
  BNE L864A  * LOOP UNTIL DONE
  RTS   * 
 L8650 CMPX #LINBUF+1  * COMPARE POINTER TO START OF BUFFER
  BEQ L8625  * DO NOT ALLOW BS IF AT START
  LEAX $-01,X  * MOVE POINTER BACK ONE
  LDA #BS   * BACK SPACE
 L8659 JMP LA282  * SEND TO CONSOLE OUT
 L865C CMPA #'K'  * KILL?
  BEQ L8665  * YES
  SUBA #'S'  * SEARCH?
  BEQ L8665  * YES
  RTS   * 
 L8665 PSHS A   * SAVE KILL/SEARCH FLAG ON STACK
  BSR L8687  * GET A KEYSTROKE (TARGET CHARACTER)
  PSHS A   * AND SAVE IT ON STACK
 L866B LDA ,X   * = GET CURRENT BUFFER CHARACTER
  BEQ L8685  * = AND RETURN IF END OF LINE
  TST $01,S  * CHECK KILL/SEARCH FLAG
  BNE L8679  * BRANCH IF KILL
  BSR L8659  * SEND A CHARACTER TO CONSOLE OUT
  LEAX $01,X  * INCREMENT BUFFER POINTER
  BRA L867C  * CHECK NEXT INPUT CHARACTER
 L8679 JSR L85D1  * REMOVE ONE CHARACTER FROM BUFFER
 L867C LDA ,X   * GET CURRENT INPUT CHARACTER
  CMPA ,S   * COMPARE TO TARGET CHARACTER
  BNE L866B  * BRANCH IF NO MATCH
  DECB   * DECREMENT REPEAT PARAMETER
  BNE L866B  * BRANCH IF NOT DONE
 L8685 PULS Y,PC  * THE Y PULL WILL CLEAN UP THE STACK FOR THE 2 PSHS A
 *
 * GET A KEYSTRKE
 *
 L8687 JSR LA171  * CALL CONSOLE IN : DEV NBR=SCREEN
  CMPA #$7F  * GRAPHIC CHARACTER?
  BCC L8687  * YES - GET ANOTHER CHAR
  CMPA #$5F  * SHIFT UP ARROW (QUIT INSERT)
  BNE L8694  * NO
  LDA #ESC  * REPLACE W/ESCAPE CODE
 L8694 CMPA #CR  * ENTER KEY
  BEQ L86A6  * YES
  CMPA #ESC  * ESCAPE?
  BEQ L86A6  * YES
  CMPA #BS  * BACKSPACE?
  BEQ L86A6  * YES
  CMPA #SPACE  * SPACE
  BLO L8687  * GET ANOTHER CHAR IF CONTROL CHAR
  ORCC #$01  * SET CARRY
 L86A6 RTS   * 
 *
 * Called as first instruction for edit command
 *
 L89AE JSR LAF67  * GO GET LINE NUMBER CONVERTED TO BINARY
  JMP LA5C7  * MAKE SURE THERE'S NO MORE ON THIS LINE
 L89B4 LDA ,U+   * GET A BYTE FROM (U)
  STA ,X+   * MOVE THE BYTE TO (X)
 L89B8 CMPU VARTAB  * COMPARE TO END OF BASIC
  BNE L89B4  * BRANCH IF NOT AT END
  STX VARTAB  * SAVE (X) AS NEW END OF BASIC
 L89BF RTS   *
 *
 * Called from above as first instruction
 *
 LAF67 LDX ZERO  * DEFAULT LINE NUMBER OF ZERO
  STX BINVAL  * SAVE IT IN BINVAL
 *
 * CONVERT LINE NUMBER TO BINARY - RETURN VALUE IN BINVAL
 *
 LAF6B BCC LAFCE  * RETURN IF NOT NUMERIC CHARACTER
  SUBA #'0  * MASK OFF ASCII
  STA CHARAC  * SAVE DIGIT IN VO1
  LDD BINVAL  * GET ACCUMULATED LINE NUMBER VALUE
  CMPA #24  * LARGEST LINE NUMBER IS $F9FF
     * (63999) = (24*256+255)*10+9
  BHI LAF52  *'SYNTAX' ERROR IF TOO BIG
     * MULT ACCD X 10
  ASLB   *
  ROLA   * TIMES 2
  ASLB   * =
  ROLA   * = TIMES 4
  ADDD BINVAL  * ADD 1 = TIMES 5
  ASLB   *
  ROLA   * TIMES 10
  ADDB CHARAC  * ADD NEXT DIGIT
  ADCA #0   * PROPAGATE CARRY
  STD BINVAL  * SAVE NEW ACCUMULATED LINE NUMBER
  JSR GETNCH  * GET NEXT CHARACTER FROM BASIC
  BRA LAF6B  * LOOP- PROCESS NEXT DIGIT
 *
 * THIS IS THE RETURN LOCATION FOR SCAN FILE NAME BELOW
 *
 LA5C4 RTS
 *
 * THIS ROUTINE WILL SCAN OFF THE FILE NAME FROM A BASIC LINE
 * AND RETURN A SYNTAX ERROR IF THERE ARE ANY CHARACTERS
 * FOLLOWING THE END OF THE NAME
 *
 LA5C5 BSR LA578  * SCAN OFF NAME
  JSR GETCCH  * GET CURRENT INPUT CHAR FROM BASIC LINE
 LA5C9 BEQ LA5C4  * RETURN IF END OF LINE
  JMP LB277  * SYNTAX ERROR IF ANY MORE CHARACTERS
 *
 * Branch here if by: LAF6B BCC LAFCE * RETURN IF NOT NUMERIC CHARACTER
 *
 LAFCE RTS




More information about the Coco mailing list