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

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