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

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