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

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