home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / develop / hc11dev / talkers / talker88.asc < prev    next >
Text File  |  1995-02-27  |  8KB  |  212 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 DOES NOT use XIRQ
  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 #$302C
  50.           STAA BAUD,X   Initialise SCI to 9600 baud, no parity
  51.           STAB SCCR2,X  and enable SCI tx & rx.
  52.           LDAA #$40     Enable STOP, and I bit interrupts,
  53.           TAP           disable XIRQ
  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   CLI
  152.           BRA SWIIDLE   then wait for response from host. (Ibit=0,Xbit=1)
  153. *
  154. SWISRV1   EQU *
  155.           CMPA #BRKACK  If host has acknowledged breakpoint state then
  156.           BNE RXSRVEX
  157.           TSX           move stack pointer to SWI stack frame and
  158.           LDAB #9
  159.           ABX
  160.           TXS
  161.           LDD 7,X       Send user code breakpoint return address to host
  162.           BSR OUTSCI    (high byte first)
  163.           TBA
  164.           BSR OUTSCI    (low byte next)
  165.           LDD #IDLE     force idle loop on return from breakpoint processing
  166.           STD 7,X
  167.           BRA INH1A     but first return all MCU registers to host
  168. *
  169.           ORG BOOTVECT  Boot vector jump table set up only during bootstrap.
  170.           FCB JMPEXT    SCI
  171.           FDB SCISRV
  172.           FCB JMPEXT    SPI  (Unused vectors point to RTI)
  173.           FDB NULLSRV
  174.           FCB JMPEXT    Pulse acc. Input Edge
  175.           FDB NULLSRV
  176.           FCB JMPEXT    Pulse acc. Overflow
  177.           FDB NULLSRV
  178.           FCB JMPEXT    Timer Overflow
  179.           FDB NULLSRV
  180.           FCB JMPEXT    OC5
  181.           FDB NULLSRV
  182.           FCB JMPEXT    OC4
  183.           FDB NULLSRV
  184.           FCB JMPEXT    OC3
  185.           FDB NULLSRV
  186.           FCB JMPEXT    OC2
  187.           FDB NULLSRV
  188.           FCB JMPEXT    OC1
  189.           FDB NULLSRV
  190.           FCB JMPEXT    IC3
  191.           FDB NULLSRV
  192.           FCB JMPEXT    IC2
  193.           FDB NULLSRV
  194.           FCB JMPEXT    IC1
  195.           FDB NULLSRV
  196.           FCB JMPEXT    Real Time Intr
  197.           FDB NULLSRV
  198.           FCB JMPEXT    IRQ
  199.           FDB NULLSRV
  200.           FCB JMPEXT    XIRQ
  201.           FDB NULLSRV
  202.           FCB JMPEXT    SWI    N.B. Changed by monitor Break point and Trace !
  203.           FDB NULLSRV
  204.           FCB JMPEXT    ILLOP
  205.           FDB TLKRSTART
  206.           FCB JMPEXT    COP Fail
  207.           FDB NULLSRV
  208.           FCB JMPEXT    Clock Monitor N.B. Changed by monitor Reset operation !
  209.           FDB NULLSRV
  210. *
  211.           END
  212.