CodeCodeCode

ECE362 LAB4 Debugger

Sep 14th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;*********************************************************************
  2. ; ECE 362 - Experiment 4 - Fall 2012
  3. ;
  4. ; Mini-Monitor with Memory Editor, Go, Memory Display, Register Display
  5. ;
  6. ; This debugging application allows one to jump to a section of code,
  7. ;     display unaltered register values, display memory, and edit memory.
  8. ; SRAM mapped to 3800-3FFF, Flash mapped to 8000-FFFF
  9. ;**********************************************************************
  10.  
  11. INITRM  equ $0010   ; INITRM - INTERNAL SRAM POSITION REGISTER
  12. INITRG  equ $0011   ; INITRG - INTERNAL REGISTER POSITION REGISTER
  13. RAMBASE equ $3800   ; 2KB SRAM located at 3800-3FFF
  14.  
  15. ;***********************************************************************
  16. ; ASCII character definitions
  17. ;
  18. CR  equ $; RETURN
  19. LF  equ $; LINE FEED
  20. NULL    equ $0  ; NULL
  21. DASH    equ '-' ; DASH (MINUS SIGN)
  22. PERIOD  equ '.' ; PERIOD
  23.  
  24. ;************************************************************************
  25.     org $8000   ; start of application program memory (32K Flash)
  26.  
  27. ;
  28. ;Boot-up entry point
  29. ;
  30.  
  31. startup_code
  32.  
  33.     movb    #$39,INITRM   ; map RAM ($3800 - $3FFF)
  34.         lds     #$3FCE            ; initialize stack pointer
  35.     jsr     ssinit            ; initialize system clock and serial I/O
  36.  
  37. ;***********************************************************************
  38. ; Start Mini-Monitor Application
  39. ;
  40.  
  41. main
  42. ;---register value back-up on stack---
  43.   pshy
  44.   pshx
  45.   pshd
  46.   pshc
  47. ;--------------------------------------
  48.  
  49.     jsr pmsg    ; display welcome message upon reset/power-up
  50.     fcb CR,LF,CR,LF
  51.     fcc "9S12C32 Mini-Monitor V1.0"
  52.     fcb CR,LF
  53.     fcc "Created by:  name ####-A"
  54.     fcb CR,LF
  55.     fcc "Last updated:  September 28, 2012"
  56.     fcb CR,LF,NULL
  57.  
  58. mprmpt  jsr pmsg    ; display monitor prompt
  59.     fcb CR,LF
  60.     fcc "=>"
  61.     fcb NULL
  62.     jsr inchar  ; input monitor command
  63.     jsr     outchar
  64.  
  65. ;---Input Checking and Function Start---      
  66.         ANDCC       #%11111011  ; initial clear Z
  67.        
  68.         CMPA        #$47        ; check for input G
  69.         BEQ         g_input    
  70.         ANDCC       #%11111011
  71.         CMPA        #$67        ; check for input g
  72.         BEQ         g_input
  73.         ANDCC       #%11111011
  74.            
  75.         CMPA        #$4D        ; check for input M
  76.         BEQ         m_input
  77.         ANDCC       #%11111011
  78.         CMPA        #$6D        ; check for input m
  79.         BEQ         m_input
  80.         ANDCC       #%11111011
  81.        
  82.         CMPA        #$44        ; check for input D
  83.         BEQ         d_input
  84.         ANDCC       #%11111011
  85.         CMPA        #$64        ; check for input d
  86.         BEQ         d_input
  87.         ANDCC       #%11111011
  88.        
  89.         CMPA        #$52        ; check for input R
  90.         BEQ         r_input
  91.         ANDCC       #%11111011
  92.         CMPA        #$72        ; check for input r
  93.         BEQ         r_input
  94.         ANDCC       #%11111011
  95.        
  96.         ;LDX        #error      ; error: load X with error address and print
  97.         JSR         pmsg
  98.         FCC         "Invalid address entered.  Try again."
  99.         FCB         CR,LF,NULL
  100.         LBRA        main
  101.        
  102. g_input
  103.         jsr         inchar
  104.         JMP         go_to_code  ; jump to code reader
  105.         LBRA        main
  106. m_input
  107.         jsr         inchar
  108.         JSR         mem_editor  ; jump to memory editor
  109.         LBRA        main
  110. d_input
  111.         jsr         inchar
  112.         JSR         disp_SRAM   ; jump to display SRAM
  113.         LBRA        main
  114. r_input
  115.         jsr         inchar
  116.         JSR         disp_reg    ; jump to display registers
  117.         LBRA        main
  118. ;---------------------------------------  
  119.  
  120. mexit   jmp main    ; End of main loop
  121.  
  122. ;***********************************************************************
  123. ; Go to code  
  124. ; -> -
  125. ; <- [program read]
  126. ;***********************************************************************
  127. go_to_code
  128.         jsr         pmsg    ; print start address (text)
  129.         fcb         CR,LF
  130.         fcc         "Enter Program Starting Address: "
  131.         fcb         NULL
  132.  
  133.         jsr         getword     ; get user input (start address)
  134.         pshd
  135.         jsr         inchar      ; wait for CR  
  136.        
  137.         pulx
  138.        
  139.         pshx
  140.         puly
  141.    ;---    
  142.         pshx
  143.         pshx       ;save the PC
  144.         puld
  145.         tsx      ;sp->x
  146.         pshx       ;save the SP
  147.        
  148.      ;----  
  149.         jmp         0,Y      
  150.  
  151. ;***********************************************************************
  152. ; Memory editor      
  153. ; -> -
  154. ; <- [memeory edit]
  155. ;***********************************************************************
  156. mem_editor
  157.         jsr         pmsg
  158.         fcb         CR,LF
  159.         fcc         "Memory edit mode..."
  160.         fcb         CR,LF
  161.         fcc         "Enter address: "
  162.         fcb         NULL
  163.  
  164. try_ag                          ; error checking
  165.         ldd         #$0000
  166.         jsr         getword
  167.         pshd
  168.         jsr         inchar      ;wait
  169.         puld
  170.         andcc       #%11110000
  171.         cpd         #$2E00
  172.         lbeq        finish
  173.         andcc       #%11110000
  174.         cpd         #$4000;#$3FFF
  175.         bpl         wrong
  176.         andcc       #%11110000
  177.         cpd         #$3800
  178.         bmi         wrong
  179.  
  180.         bra         good
  181.    
  182. wrong    
  183.         jsr         pmsg
  184.         fcb         CR,LF
  185.         fcc         "ERROR - Invalid Address - Try Again..."
  186.         fcb         CR,LF
  187.         fcc         "Enter address: "
  188.         fcb         NULL
  189.         bra         try_ag  
  190. move_up
  191.         jsr         pmsg
  192.         fcb         CR,LF
  193.         fcc         "Enter address: "
  194.         fcb         NULL
  195.         bra         try_ag
  196.  
  197. good        
  198.         pshd
  199.  ;-------loop starts here      
  200. mem_l
  201.         jsr         pmsg
  202.         fcb         CR,LF
  203.         fcc         "("
  204.         fcb         NULL
  205.        
  206.         puld
  207.         pshd
  208.         jsr         disword
  209.        
  210.         jsr         pmsg
  211.         fcc         ") = "
  212.         fcb         NULL
  213.        
  214.         pulx
  215.        
  216.         ldaa        0,X
  217.         jsr         disbyte
  218.  
  219. mo_ichi        
  220.         pshx
  221.         jsr         pmsg
  222.         fcb         CR,LF
  223.         fcc         "Enter new value: "
  224.         fcb         NULL
  225.         pulx
  226.  ;--INPUT VALUE ERROR CHECKING--      
  227.         ;jsr         getbyte
  228.         andcc       #%11110000
  229.         jsr         inchar
  230.         jsr         outchar;--
  231.         cmpa        #PERIOD
  232.         beq         move_up
  233.         cmpa        #CR
  234.         beq         skippa
  235.         cmpa        #DASH
  236.         beq         reverse
  237.        
  238.         andcc       #%11110000
  239.         jsr         atoh
  240.         bcs         inval
  241.         psha        
  242.         pulb
  243.        
  244.         jsr         inchar
  245.         jsr         outchar  ;--
  246.         jsr         atoh
  247.         bcs         inval
  248.         rolb
  249.         rolb
  250.         rolb
  251.         rolb
  252.         aba    ;B+A -> A
  253.         bra         yup
  254.  
  255. inval  ;invalid input nibble
  256.         pshd
  257.         pshx
  258.         jsr         pmsg
  259.         fcb         CR,LF
  260.         fcc         "ERROR - Invalid Data - Try Again..."
  261.         fcb         CR,LF,NULL
  262.         pulx
  263.         puld
  264.         bra         mo_ichi
  265.  ;------------------------------              
  266.         ;STUFF GETS EDITTED HERE!
  267.         ;--SAVE
  268. yup
  269.         psha
  270.         movb        sp,x
  271.         pula
  272.         ;---
  273.        
  274.         jsr         inchar  ;I DO NOTHING
  275. skippa        
  276.         leax        1,X
  277.         ;---------
  278.         andcc       #%11110000
  279.         cpx         #$4000
  280.         beq         backup
  281.         ;--------
  282.         pshx
  283.         lbra        mem_l
  284. backup ;-----more than 3FFF?
  285.         leax        -1,X
  286.         pshx
  287.         lbra        mem_l
  288. reverse    ;--backwards
  289.         leax        -1,X
  290.         ;--------
  291.         andcc       #%11110000
  292.         cpx         #$37FF
  293.         beq         frontup
  294.         ;---------
  295.         pshx
  296.         lbra        mem_l
  297. frontup ;-----less than 3800?
  298.         leax        1,X
  299.         pshx
  300.         lbra        mem_l        
  301.  
  302. finish
  303.         jsr         pmsg
  304.         fcb         CR,LF
  305.         fcc         "Exit memory edit mode"
  306.         fcb         CR,LF,NULL      
  307.  
  308.         RTS
  309.  
  310. ;***********************************************************************
  311. ; Display SRAM    
  312. ;***********************************************************************
  313. disp_SRAM
  314.         jsr         pmsg
  315.         fcb         CR,LF
  316.         fcc         "Enter SRAM starting address: "
  317.         fcb         NULL
  318.        
  319.         jsr         getword
  320.         pshd
  321.         pshd
  322.         jsr         inchar
  323.        
  324.         jsr         pmsg
  325.         fcb         CR,LF
  326.         fcc         "        0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F"
  327.         fcb         CR,LF,NULL
  328.        
  329.         bra         loop_A
  330.  
  331. otr_l      ;----  OUTER LOOP
  332.         bra         loop_B
  333. loop_A                        ;primary run loop
  334.         ldy         #$01
  335.         puld
  336.         jsr         disword
  337.         bra         loop_st
  338.        
  339. loop_B                        ; post primary run
  340.         orcc        #%11111011
  341.         cpy         #$0009
  342.         beq         nope
  343.         pulx
  344.         puld      
  345.      
  346.         jsr         disword
  347.        
  348.         pshx
  349. loop_st        
  350.         jsr         pmsg
  351.         fcc         ":  "
  352.         fcb         NULL
  353.         pulx                  ;starting mem val
  354.         ldab        #$00
  355.         leay        1,Y
  356.        
  357. inr_l        ;---- INNER LOOP
  358.        
  359.         orcc        #%11111011                  
  360.         ldaa        #$00
  361.        
  362.         ldaa        0,X
  363.         incb    
  364.  
  365.         leax        1,X
  366.         jsr         disbyte
  367.         cmpb        #$10
  368.         beq         nl_sr
  369.        
  370.         pshx
  371.         jsr         pmsg
  372.         fcc         " "
  373.         fcb         NULL
  374.         pulx
  375.         bra         inr_l
  376.        
  377. nl_sr  
  378.         pshx
  379.         pshx
  380.         jsr         pmsg
  381.         fcb         CR,LF,NULL
  382.         bra         otr_l
  383.  
  384. nope
  385.         ldy         #$8102
  386.         pshy
  387.         RTS
  388.  
  389. ;***********************************************************************
  390. ; Display Registers  
  391. ;***********************************************************************    
  392. disp_reg
  393.  
  394.         jsr         pmsg
  395.         fcb         CR,LF
  396.         fcc         "SXHINZVC     (A):(B)     (X)     (Y)     (SP)     (PC)"
  397.         fcb         CR,LF,NULL
  398.        
  399.         pulc
  400.         pulc   ;---
  401.         pulc   ;---
  402.         pshc
  403.         tpa     ;CCR copy to A
  404.         tab     ;A copy to B
  405.         ldy         #$0000
  406.        
  407. CCR_l  
  408.         andcc       #%11110000
  409.         leay        1,Y
  410.         cpy         #$0009
  411.         beq         CCR_d
  412.         andcc       #%11110000
  413.         rolb
  414.        
  415.         bcs         pr_y
  416.         bcc         pr_n
  417. pr_y
  418.         jsr         pmsg
  419.         fcc         "1"
  420.         fcb         NULL
  421.         bra         CCR_l
  422. pr_n
  423.         jsr         pmsg
  424.         fcc         "0"
  425.         fcb         NULL
  426.         bra         CCR_l
  427. CCR_d        
  428.         pulc
  429.        
  430.         jsr         pmsg
  431.         fcc         "      "
  432.         fcb         NULL
  433.        
  434.         puld        ; PULL D TO PRINT
  435.        
  436.         jsr         disword
  437.        
  438.         jsr         pmsg
  439.         fcc         "      "
  440.         fcb         NULL
  441.        
  442.         puld        ; PULL X TO PRINT
  443.        
  444.         jsr         disword
  445.        
  446.         jsr         pmsg
  447.         fcc         "     "
  448.         fcb         NULL
  449.        
  450.         puld        ; PULL Y TO PRINT
  451.        
  452.         jsr         disword
  453.        
  454.         jsr         pmsg
  455.         fcc         "     "
  456.         fcb         NULL                
  457.        
  458.         puld        ; PULL SP TO PRINT
  459.        
  460.         jsr         disword
  461.        
  462.         jsr         pmsg
  463.         fcc         "     "
  464.         fcb         NULL          
  465.                
  466.         puld        ; PULL PC TO PRINT
  467.        
  468.         jsr         disword
  469.        
  470.         jsr         pmsg
  471.         fcc         "   "
  472.         fcb         CR,LF,NULL  
  473.        
  474.         ldy         #$810C
  475.         pshy
  476.        
  477.         RTS
  478.              
  479. ;***********************************************************************
  480. ; Character I/O Library Routines for 9S12C32
  481. ;
  482. ; For flash-based applications created using AsmIDE
  483. ;***********************************************************************
  484. ;
  485. ; ==== CRG - Clock and Reset Generator Definitions
  486.  
  487. SYNR    EQU $0034           ;CRG synthesizer register
  488. REFDV   EQU $0035           ;CRG reference divider register
  489. CTFLG   EQU $0036       ;TEST ONLY
  490. CRGFLG  EQU $0037       ;CRG flags register
  491. CRGINT  EQU $0038
  492. CLKSEL  EQU $0039       ;CRG clock select register
  493. PLLCTL  EQU $003A       ;CRG PLL control register
  494. RTICTL  EQU $003B
  495. COPCTL  EQU $003C
  496. FORBYP  EQU $003D
  497. CTCTL   EQU $003E
  498. ARMCOP  EQU $003F
  499.  
  500. ; ==== SCI Register Definitions
  501.  
  502. SCIBDH  EQU $00C8       ;SCI0BDH - SCI BAUD RATE CONTROL REGISTER
  503. SCIBDL  EQU $00C9       ;SCI0BDL - SCI BAUD RATE CONTROL REGISTER
  504. SCICR1  EQU $00CA       ;SCI0CR1 - SCI CONTROL REGISTER
  505. SCICR2  EQU $00CB       ;SCI0CR2 - SCI CONTROL REGISTER
  506. SCISR1  EQU $00CC       ;SCI0SR1 - SCI STATUS REGISTER
  507. SCISR2  EQU $00CD       ;SCI0SR2 - SCI STATUS REGISTER
  508. SCIDRH  EQU $00CE       ;SCI0DRH - SCI DATA REGISTER
  509. SCIDRL  EQU $00CF       ;SCI0DRL - SCI DATA REGISTER
  510. PORTB   EQU $0001       ;PORTB - DATA REGISTER
  511. DDRB    EQU $0003       ;PORTB - DATA DIRECTION REGISTER
  512.  
  513. ;
  514. ; Initialize system clock serial port (SCI) for 9600 baud
  515. ;
  516. ; Assumes PLL is engaged -> CPU bus clock is 24 MHz
  517. ;
  518.  
  519. ssinit  bclr    CLKSEL,$80  ; disengage PLL to system
  520.     bset    PLLCTL,$40  ; turn on PLL
  521.     movb    #$2,SYNR    ; set PLL multiplier
  522.     movb    #$0,REFDV   ; set PLL divider
  523.     nop
  524.     nop
  525. plllp   brclr CRGFLG,$08,plllp  ; while (!(crg.crgflg.bit.lock==1))
  526.     bset  CLKSEL,$80    ; engage PLL to system
  527. ;
  528. ; Disable watchdog timer (COPCTL register)
  529. ;
  530.     movb    #$40,COPCTL ; COP off; RTI and COP stopped in BDM-mode
  531. ;
  532. ; Initialize SCI (COM port)
  533. ;
  534.     movb    #$00,SCIBDH ; set baud rate to 9600
  535.     movb    #$9C,SCIBDL ; 24,000,000 / 16 / 156 = 9600 (approx)
  536.     movb    #$00,SCICR1 ; $9C = 156
  537.     movb    #$0C,SCICR2 ; initialize SCI for program-driven operation
  538.     movb    #$10,DDRB   ; set PB4 for output mode
  539.     movb    #$10,PORTB  ; assert DTR pin of COM port
  540.     rts
  541.  
  542. ;
  543. ; SCI handshaking status bits
  544. ;
  545.  
  546. rxdrf    equ   $20    ; receive data register full (RDRF) mask pattern
  547. txdre    equ   $80    ; transmit data register empty (TDRE) mask pattern
  548.  
  549. ;***********************************************************************
  550. ; Name:         inchar
  551. ; Description:  inputs ASCII character from SCI serial port
  552. ;                  and returns it in the A register
  553. ; Returns:      ASCII character in A register
  554. ; Modifies:     A register
  555. ;***********************************************************************
  556.  
  557. inchar  brclr  SCISR1,rxdrf,inchar
  558.         ldaa   SCIDRL ; return ASCII character in A register
  559.         rts
  560.  
  561.  
  562. ;***********************************************************************
  563. ; Name:         outchar
  564. ; Description:  outputs ASCII character passed in the A register
  565. ;                  to the SCI serial port
  566. ;***********************************************************************
  567.  
  568. outchar brclr  SCISR1,txdre,outchar
  569.         staa   SCIDRL ; output ASCII character to SCI
  570.         rts
  571.  
  572.  
  573. ;***********************************************************************
  574. ; pmsg -- Print string following call to routine.  Note that subroutine
  575. ;         return address points to string, and is adjusted to point to
  576. ;         next valid instruction after call as string is printed.
  577. ;***********************************************************************
  578.  
  579.  
  580. pmsg    pulx            ; Get pointer to string (return addr).
  581.         psha
  582. ploop   ldaa    1,x+    ; Get next character of string.
  583.         beq     pexit   ; Exit if ASCII null encountered.
  584.         jsr     outchar ; Print character on terminal screen.
  585.         bra     ploop   ; Process next string character.
  586. pexit   pula
  587.         pshx            ; Place corrected return address on stack.
  588.         rts             ; Exit routine.
  589.  
  590.  
  591. ;***********************************************************************
  592. ; Subroutine:   htoa
  593. ; Description:  converts the hex nibble in the A register to ASCII
  594. ; Input:    hex nibble in the A accumualtor
  595. ; Output:   ASCII character equivalent of hex nibble
  596. ; Reg. Mod.:    A, CC
  597. ;***********************************************************************
  598.  
  599. htoa    adda     #$90
  600.     daa
  601.     adca     #$40
  602.     daa
  603.     rts
  604.  
  605. ;***********************************************************************
  606. ; Subroutine:   atoh
  607. ; Description:  converts ASCII character to a hexadecimal digit
  608. ; Input:    ASCII character in the A register
  609. ; Output:   converted hexadecimal digit returned in A register
  610. ;               CF = 0 if result OK; CF = 1 if error occurred (invalid input)
  611. ; Reg. Mod.:    A, CC
  612. ;***********************************************************************
  613.  
  614. atoh       pshb
  615.            pshx
  616.            pshy
  617.            suba    #$30   ; subtract "bias" to get ASCII equivalent
  618.            blt     outhex
  619.            cmpa    #$0a
  620.            bge     cont1
  621. quithx     clc             ; return with CF = 0 to indicate result OK
  622.            puly
  623.            pulx
  624.            pulb
  625.            rts
  626.  
  627. cont1      suba    #$07
  628.            cmpa    #$09
  629.            blt     outhex
  630.            cmpa    #$10
  631.            blt     quithx
  632.            suba    #$20
  633.            cmpa    #$09
  634.            blt     outhex
  635.            cmpa    #$10
  636.            blt     quithx
  637.  
  638. outhex     sec            ; set CF <- 1 to indicate error
  639.            puly
  640.            pulx
  641.            pulb
  642.            rts
  643.  
  644. ;***********************************************************************
  645. ; Subroutine:   getbyte
  646. ; Description:  inputs two ASCII characters and converts them to byte integer
  647. ; Input:    <none>
  648. ; Output:   converted hexadecimal value returned in A register
  649. ;               if error in character input, echo "?"
  650. ; Reg. Mod.:    A
  651. ;***********************************************************************
  652.  
  653. getbyte    pshc
  654. getblp     jsr    inchar   ; get first ASCII character        
  655.        cmpa   #CR
  656.        beq    gbexit
  657.  
  658.            jsr    outchar  ; echo character
  659.        cmpa   #PERIOD  ; check for exit mode character
  660.        beq    gbexit
  661.        cmpa   #DASH    ; check for backup character
  662.        beq    gbexit
  663.  
  664.            jsr    atoh     ; convert ASCII character to hex
  665.            bcs    errhex1  ; if not hex, go to error routine
  666.            asla            ; shift converted hex digit
  667.            asla            ;   to upper nibble
  668.            asla
  669.            asla
  670.            psha            ; save on stack temporarily
  671.  
  672. get2       jsr    inchar   ; get second ASCII character
  673.            jsr    outchar  ; echo to screen
  674.            jsr    atoh     ; convert ASCII character to hex
  675.            bcs    errhex2  ; if not hex, go to error routine
  676.            oraa   1,sp+    ; OR converted hex digits together
  677.  
  678. gbexit     pulc
  679.            rts
  680.  
  681. errhex1    ldaa   #'?'     ; get ? to prompt for new character
  682.            jsr    outchar
  683.            bra    getblp
  684.  
  685. errhex2    ldaa   #'?'
  686.            jsr    outchar
  687.            bra    get2
  688.  
  689. ;***********************************************************************
  690. ; Subroutine:   getword
  691. ; Description:  inputs four ASCII characters and converts them to word integer
  692. ; Input:    <none>
  693. ; Output:   converted hexadecimal value returned in D register
  694. ; Reg. Mod.:    A, CC
  695. ;***********************************************************************
  696.  
  697. getword jsr getbyte     ; get first byte of the data entered
  698.         cmpa    #PERIOD     ; check for exit mode character
  699.     bne getnxw
  700.     rts
  701.  
  702. getnxw  tfr a,b     ; save MSB in B
  703.     jsr getbyte     ; get second byte of data entered
  704.     exg a,b     ; put MSB in A and LSB in B
  705.     rts
  706.  
  707. ;***********************************************************************
  708. ; Subroutine:   disbyte
  709. ; Description:  displays 8-bit (binary) value as two ASCII characters
  710. ; Input:    8-bit value passed in A register
  711. ; Output:   <none>
  712. ; Reg. Mod.:    A, CC
  713. ;***********************************************************************
  714.  
  715. disbyte psha        ; save value passed on stack
  716.     anda    #$F0    ; get most significant digit of result
  717.     lsra
  718.     lsra
  719.     lsra
  720.     lsra
  721.     jsr htoa
  722.     jsr outchar ; display most significant digit
  723.     pula        ; restore original value
  724.     anda    #$0F    ; get least significant digit of resust
  725.     jsr htoa    ; convert result to ASCII character
  726.     jsr outchar ; display least significant digit
  727.     rts
  728.  
  729. ;***********************************************************************
  730. ; Subroutine:   disword
  731. ; Description:  displays 16-bit (binary) value as four ASCII characters
  732. ; Input:    16-bit value passed in D register
  733. ; Output:   <none>
  734. ; Reg. Mod.:    A, CC
  735. ;***********************************************************************
  736.  
  737. disword pshd        ; save value passed on stack
  738.     jsr disbyte ; display high byte
  739.     puld
  740.     exg a,b
  741.     jsr disbyte ; display low byte
  742.     rts
  743.  
  744. ;***********************************************************************
  745. ; "Go" / "Register Display" test code.
  746. ; Description:  Loads registers with test values and returns to 'main'.
  747. ;               The registers should display the values specified here
  748. ;               when followed by the "R" command.
  749. ; Reg. Mod.:    D, X, Y, CC
  750. ;***********************************************************************
  751.  
  752.   org     $800  ; This is mapped to $3800 at the beginning of 'main'
  753.      
  754.   ;;; Load registers with test values ;;;
  755.   ldd     #$1234  
  756.   ldx     #$ABCD
  757.   ldy     #$CDEF
  758.   andcc   #0
  759.   orcc    #%10101010
  760.  
  761.   jmp     $800b   ; return to 'main'
  762.                   ; ** this assumes that nothing was changed
  763.                   ; ** between "org $8000" and "main"
  764.                   ; ** (which should be a safe assumption)
  765.  
  766. ;***********************************************************************
  767. ;
  768. ; If get bad interrupt, just return
  769. ;
  770. BadInt  rti
  771. ;
  772. ;***********************************************************************
  773. ;
  774. ; Define 'where you want to go today' (reset and interrupt vectors)
  775. ;
  776. ; Note this is the "re-mapped" table in Flash (located outside debug monitor)
  777. ;
  778. ; ------------------ VECTOR TABLE --------------------
  779.  
  780.     org $FF8A
  781.     fdb BadInt  ;$FF8A: VREG LVI
  782.     fdb BadInt  ;$FF8C: PWM emergency shutdown
  783.     fdb BadInt  ;$FF8E: PortP
  784.     fdb BadInt  ;$FF90: Reserved
  785.     fdb BadInt  ;$FF92: Reserved
  786.     fdb BadInt  ;$FF94: Reserved
  787.     fdb BadInt  ;$FF96: Reserved
  788.     fdb BadInt  ;$FF98: Reserved
  789.     fdb BadInt  ;$FF9A: Reserved
  790.     fdb BadInt  ;$FF9C: Reserved
  791.     fdb BadInt  ;$FF9E: Reserved
  792.     fdb BadInt  ;$FFA0: Reserved
  793.     fdb BadInt  ;$FFA2: Reserved
  794.     fdb BadInt  ;$FFA4: Reserved
  795.     fdb BadInt  ;$FFA6: Reserved
  796.     fdb BadInt  ;$FFA8: Reserved
  797.     fdb BadInt  ;$FFAA: Reserved
  798.     fdb BadInt  ;$FFAC: Reserved
  799.     fdb BadInt  ;$FFAE: Reserved
  800.     fdb BadInt  ;$FFB0: CAN transmit
  801.     fdb BadInt  ;$FFB2: CAN receive
  802.     fdb BadInt  ;$FFB4: CAN errors
  803.     fdb BadInt  ;$FFB6: CAN wake-up
  804.     fdb BadInt  ;$FFB8: FLASH
  805.     fdb BadInt  ;$FFBA: Reserved
  806.     fdb BadInt  ;$FFBC: Reserved
  807.     fdb BadInt  ;$FFBE: Reserved
  808.     fdb BadInt  ;$FFC0: Reserved
  809.     fdb BadInt  ;$FFC2: Reserved
  810.     fdb BadInt  ;$FFC4: CRG self-clock-mode
  811.     fdb BadInt  ;$FFC6: CRG PLL Lock
  812.     fdb BadInt  ;$FFC8: Reserved
  813.     fdb BadInt  ;$FFCA: Reserved
  814.     fdb BadInt  ;$FFCC: Reserved
  815.     fdb BadInt  ;$FFCE: PORTJ
  816.     fdb BadInt  ;$FFD0: Reserved
  817.     fdb BadInt  ;$FFD2: ATD
  818.     fdb BadInt  ;$FFD4: Reserved
  819.     fdb BadInt  ;$FFD6: SCI Serial System
  820.     fdb BadInt  ;$FFD8: SPI Serial Transfer Complete
  821.     fdb BadInt  ;$FFDA: Pulse Accumulator Input Edge
  822.     fdb BadInt  ;$FFDC: Pulse Accumulator Overflow
  823.     fdb BadInt  ;$FFDE: Timer Overflow
  824.     fdb BadInt  ;$FFE0: Standard Timer Channel 7
  825.     fdb BadInt      ;$FFE2: Standard Timer Channel 6
  826.     fdb BadInt  ;$FFE4: Standard Timer Channel 5
  827.     fdb BadInt  ;$FFE6: Standard Timer Channel 4
  828.     fdb BadInt  ;$FFE8: Standard Timer Channel 3
  829.     fdb BadInt  ;$FFEA: Standard Timer Channel 2
  830.     fdb BadInt  ;$FFEC: Standard Timer Channel 1
  831.     fdb BadInt  ;$FFEE: Standard Timer Channel 0
  832.     fdb BadInt  ;$FFF0: Real Time Interrupt (RTI)
  833.     fdb BadInt  ;$FFF2: IRQ (External Pin or Parallel I/O) (IRQ)
  834.     fdb BadInt  ;$FFF4: XIRQ (Pseudo Non-Maskable Interrupt) (XIRQ)
  835.     fdb BadInt  ;$FFF6: Software Interrupt (SWI)
  836.     fdb BadInt  ;$FFF8: Illegal Opcode Trap ()
  837.     fdb startup_code    ;$FFFA: COP Failure (Reset) ()
  838.     fdb BadInt      ;$FFFC: Clock Monitor Fail (Reset) ()
  839.     fdb startup_code    ;$FFFE: /RESET
  840.     end
  841.  
  842. ;*****************************************************************
  843. ; ECE 362 - Experiment 4 - Fall 2012
  844. ;*****************************************************************
Advertisement
Add Comment
Please, Sign In to add comment