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

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