home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / develop / hc11dev / scixirq / talkerx8.asc < prev    next >
Text File  |  1995-02-27  |  8KB  |  208 lines

  1. *************************** TALKERX8.ASC 9/2/89 **************************
  2. *   Written by R.Soja, Motorola, East Kilbride                           *
  3. *   Motorola Copyright 1988                                              *
  4. *   MCU resident, Interrupt driven Communication routines for 68HC11     *
  5. *   monitor. Provides low level memory and stack read/write operations.  *
  6. *   Works with Host user interface program PCBUG11.EXE.                  *
  7. *                                                                        *
  8. *   This talker uses XIRQ (connected to SCI RX)                          *
  9. *   --------------------------------------------                         *
  10. *                                                                        *
  11. *   Same as TALKERA8.ASC, except designed to communicate with PCBUG11 at *
  12. *   38.4K baud, using 4.9152MHz crystal!                                 *
  13. *
  14. * CONSTANTS
  15. TALKBASE  equ $0000
  16. BOOTVECT  equ $00C4       Start of bootstrap vector jump table.
  17. STACK     equ $00EB
  18. REGBASE   equ $1000
  19. *
  20. JSCI      equ $00C4
  21. JXIRQ     equ $00F1
  22. JSWI      equ $00F4
  23. JILLOP    equ $00F7
  24. JCOP      equ $00FA
  25. uS500     equ 5000/35     500uS delay with DEY/BNE loop
  26. JMPEXT    equ $7E         Mnemonic for jump extended instruction
  27. BRKCODE   equ $4A         Break point signal code to host.
  28. BRKACK    equ $B5         Break point acknowledge code from host.
  29. *
  30. * REGISTERS
  31. BAUD      equ $2B
  32. SCCR1     equ $2C
  33. SCCR2     equ $2D
  34. SCSR      equ $2E
  35. SCDR      equ $2F
  36. *
  37. RDRF      equ $20
  38. TDRE      equ $80
  39. *
  40. * PROGRAM
  41.           org TALKBASE
  42. TLKRSTART EQU *
  43.           LDS #STACK
  44.           LDX #REGBASE
  45.           CLR SCCR1,X
  46.           LDD #$010C    gives 38.4K baud (with 4.9152MHz crystal)
  47.           STAA BAUD,X   Initialise SCI to 38.4K baud, no parity
  48.           STAB SCCR2,X  and enable SCI tx & rx.
  49.           LDAA #$10     Enable STOP, and XIRQ interrupts, disable I bit intr.
  50.           TAP
  51. *
  52. IDLE      JMP IDLE      Now hang around for SCI interrupt from host.
  53. * A RESET from host changes above jump destination to start of user code.
  54. *
  55. SCISRV    EQU *             On detecting interrupt,
  56.           LDAA SCSR+REGBASE assume receiver caused it.
  57.           ANDA #RDRF
  58.           BEQ SCISRV        otherwise program will hang up
  59. *
  60. RXSRV     EQU *             Talker code processes received data.
  61.           LDAA SCDR+REGBASE Read command byte, & echo it as acknowledge
  62.           BSR OUTSCI        to host.
  63.           BMI INH1      If command bit 7 set, then process inherent command
  64.           BSR INSCI     else read byte count from host into ACCB.(0=256)
  65.           XGDX          Save command and byte count.
  66.           BSR INSCI     Read high address byte
  67.           TBA           into ACCA
  68.           BSR INSCI     then low address byte into ACCB
  69.           XGDX          Restore command in ACCA,count in ACCB,address in X
  70.           CMPA #$01
  71.           BNE RXSRV1    If command is memory read, then
  72. *
  73. TREADMEM  EQU *         REPEAT
  74.           LDAA ,X       read required address
  75.           BSR OUTSCI    send it to host
  76.           TBA           (save byte count)
  77.           BSR INSCI     and wait for acknowledge
  78.           TAB           (restore byte count)
  79.           INX           Increment address
  80.           DECB          Decrement byte count
  81.           BNE TREADMEM  UNTIL all done
  82.           RTI           and return to idle loop or user code.
  83. *
  84. RXSRV1    EQU *
  85.           CMPA #$41
  86.           BNE RXSRVEX    If command is memory write then
  87. *
  88.           TBA           move byte count to ACCA
  89. TWRITMEM  EQU *         REPEAT
  90.           BSR INSCI     Read next byte from host into ACCB,
  91.           STAB ,X       and store at required address.
  92.           LDY #$0001    Set up wait loop to allow for 28C64 prog time, where
  93. WAITPOLL  DEY           Y operand must be manually set to $0359 (3mS)
  94.           BNE WAITPOLL
  95.           LDAB ,X       Read stored byte and
  96.           STAB SCDR+REGBASE   echo it back to host,
  97.           INX
  98.           DECA          Decrement byte count
  99.           BNE TWRITMEM  UNTIL all done
  100. RXSRVEX   EQU *         and return
  101. NULLSRV   RTI
  102. *
  103. INSCI     EQU *
  104.           LDAB SCSR+REGBASE   Wait for RDRF=1
  105.           BITB #$0A           If break detected then
  106.           BNE TLKRSTART       restart talker
  107.           ANDB #RDRF
  108.           BEQ INSCI
  109.           LDAB SCDR+REGBASE   then read data received from host
  110.           RTS                 and return with data in ACCB
  111. *
  112. OUTSCI    EQU *               Only register Y modified.
  113.           XGDY                Enter with data to send in ACCA.
  114. OUTSCI1   LDAA SCSR+REGBASE
  115.           BPL OUTSCI1         MS bit is TDRE flag
  116.           XGDY
  117.           STAA SCDR+REGBASE   Important - Updates CCR!
  118.           RTS
  119. *
  120. INH1      EQU *
  121.           CMPA #$81     If command is read MCU registers then
  122.           BNE INH2
  123. *
  124. INH1A     TSX           Move stack pointer to X
  125.           XGDX          then to ACCD
  126.           BSR OUTSCI    send stack pointer to host (high byte first)
  127.           TBA
  128.           BSR OUTSCI    then low byte
  129.           TSX           Restore X (=stack pointer)
  130.           LDAB #9       then return 9 bytes on stack
  131.           BRA TREADMEM  i.e. CCR,ACCB,ACCA,IXH,IXL,IYH,IYL,PCH,PCL
  132. *
  133. INH2      EQU *
  134.           CMPA #$C1     If command is write MCU registers then
  135.           BNE SWISRV1
  136. *
  137.           BSR INSCI     get stack pointer from host (High byte first)
  138.           TBA
  139.           BSR INSCI
  140.           XGDX          Move to X reg
  141.           TXS           and copy to stack pointer
  142.           LDAA #9       Then put next 9 bytes from host on to stack
  143.           BRA TWRITMEM
  144. *
  145. SWISRV    EQU *         Breakpoints generated by host-placed SWI instruction.
  146.           LDAA #BRKCODE Force host to process breakpoints
  147.           BSR OUTSCI    by sending it the break signal
  148. SWIIDLE   BRA SWIIDLE   Wait for response from host. (Ibit=1,Xbit=0)
  149. *
  150. SWISRV1   EQU *
  151.           CMPA #BRKACK  If host has acknowledged breakpoint state then
  152.           BNE RXSRVEX
  153.           TSX           move stack pointer to SWI stack frame and
  154.           LDAB #9
  155.           ABX
  156.           TXS
  157.           LDD 7,X       Send user code breakpoint return address to host
  158.           BSR OUTSCI    (high byte first)
  159.           TBA
  160.           BSR OUTSCI    (low byte next)
  161.           LDD #IDLE     force idle loop on return from breakpoint processing
  162.           STD 7,X
  163.           BRA INH1A     but first return all MCU registers to host
  164. *
  165.           ORG BOOTVECT  Boot vector jump table set up only during bootstrap.
  166.           FCB JMPEXT    SCI
  167.           FDB SCISRV
  168.           FCB JMPEXT    SPI  (Unused vectors point to RTI)
  169.           FDB NULLSRV
  170.           FCB JMPEXT    Pulse acc. Input Edge
  171.           FDB NULLSRV
  172.           FCB JMPEXT    Pulse acc. Overflow
  173.           FDB NULLSRV
  174.           FCB JMPEXT    Timer Overflow
  175.           FDB NULLSRV
  176.           FCB JMPEXT    OC5
  177.           FDB NULLSRV
  178.           FCB JMPEXT    OC4
  179.           FDB NULLSRV
  180.           FCB JMPEXT    OC3
  181.           FDB NULLSRV
  182.           FCB JMPEXT    OC2
  183.           FDB NULLSRV
  184.           FCB JMPEXT    OC1
  185.           FDB NULLSRV
  186.           FCB JMPEXT    IC3
  187.           FDB NULLSRV
  188.           FCB JMPEXT    IC2
  189.           FDB NULLSRV
  190.           FCB JMPEXT    IC1
  191.           FDB NULLSRV
  192.           FCB JMPEXT    Real Time Intr
  193.           FDB NULLSRV
  194.           FCB JMPEXT    IRQ
  195.           FDB NULLSRV
  196.           FCB JMPEXT    XIRQ   SCI RX line must be connected to XIRQ input.
  197.           FDB SCISRV
  198.           FCB JMPEXT    SWI    N.B. Changed by monitor Break point and Trace !
  199.           FDB NULLSRV
  200.           FCB JMPEXT    ILLOP
  201.           FDB TLKRSTART
  202.           FCB JMPEXT    COP Fail
  203.           FDB NULLSRV
  204.           FCB JMPEXT    Clock Monitor N.B. Changed by monitor Reset operation !
  205.           FDB NULLSRV
  206. *
  207.           END
  208.