?? xmdstub.s
字號:
/*--------------------------------------------------*/SingleStep: brlid r15, Get_All_Registers nop rtsd r16, 0 lwi r15,r0,register_dump+15*4 /*--------------------------------------------------*/ /* When Processor resets */ /* - save all registers to the register_dump */ /* - send 0x3 ('Processor reset') to host */ /* - Jump to the main command entry code */ /*--------------------------------------------------*/ StartUp_Entry: swi r15,r0,register_dump+60 brid Dump_All_Registers ori r15,r0,ProcReset_signal /* Control goes to SendStatus from DumpAllRegisters */ /*--------------------------------------------------*/ /* Program End entry */ /* When control returns from the program or */ /* on exit() */ /* - save all register to the register_dump */ /* - send 0x0 ('Reached_End_Of_Program') to host */ /* - Jump to the main command entry code */ /*--------------------------------------------------*/ Program_Exit: swi r15,r0,register_dump+60 brid Dump_All_Registers ori r15,r0,Reached_End_Of_Program /* Control goes to SendStatus from DumpAllRegisters */ /*--------------------------------------------------*/ /* Debug Entry code */ /* The code that breakpoint instruction will call */ /* - Will save all registers */ /* - Send 0x01 to the host */ /* - Jump to the main command entry code */ /*--------------------------------------------------*/Debug_Entry: swi r15,r0,register_dump+60 /* Dump_All_regs doesnt do this */ brid Dump_All_Registers ori r15,r0, Reached_Breakpoint /* Control goes to SendStatus from DumpAllRegisters */ /*--------------------------------------------------*/ /* Brk signal handler */ /* - Will save all registers */ /* - Send 0x02 to the host */ /* - Jump to the main command entry code */ /*--------------------------------------------------*/Brk_Signal_Entry: swi r15,r0,register_dump+60 /* Dump_All_regs doesnt do this */ lwi r15, r0, uart_stat andi r15,r15, Intr_Enabled ori r15, r15, Clear_ExtBreak swi r15, r0, uart_ctrl brid Dump_All_Registers ori r15,r0, Received_brk_signal /* Control goes to SendStatus from DumpAllRegisters */ /* Send the status to the host */Send_Status: brlid r29,Wait_for_TX_space nop swi r15,r0,uart_tx_data bri Wait_for_command /*--------------------------------------------------*/ /* NOTE : ADDED FOR THE SAKE OF COMPATIBILITY WITH MDK 2.2 */ /* Return Debug Address Entry command */ /* The code will return the address for the */ /* Debug_Entry code section as four bytes */ /*--------------------------------------------------*/Return_Dbg_Addr: brlid r15,Send_32Bit addi r5,r0,Debug_Entry bri Wait_for_command/*--------------------------------------------------*//* Low Level Helper routines */ /*--------------------------------------------------*/ /*--------------------------------------------------*/ /* Get a byte function */ /* - loop until a character has been received */ /* - read the character */ /* Uses: R3 */ /* Parameters: None */ /* Returns using R27 */ /* Result in: R3 */ /*--------------------------------------------------*/Get_Byte: /* Get 1 byte and return it in r3 */ lwi r3,r0,uart_stat andi r3,r3,uart_rx_data_valid /* rx data present */ beqi r3, Get_Byte lwi r3,r0,uart_rx_data rtsd r27,8 nop /*--------------------------------------------------*/ /* Get a char function */ /* - Get a byte from the UART */ /* - Check if it's an escape character */ /* - if it is */ /* Uses: R3, R26, R27 */ /* Parameters: None */ /* Returns using R29 */ /* Result in: R3 */ /*--------------------------------------------------*/Get_Char: brlid r27,Get_Byte nop xori r26,r3,Escape_Char bnei r26,No_Escape brlid r27,Get_Byte nopGet_Char_Return: rtsd r29,8 nopNo_Escape: xori r26,r3,ReSync_Char beqi r26,ReSync bri Get_Char_Return /*--------------------------------------------------*/ /* Get a half word function */ /* - Get 2 bytes using Get_Char function */ /* - Store each byte in a memory location,temp_mem */ /* using store byte SBI instruction */ /* stores the received byte in the order */ /* addr+1,addr+0 */ /* Uses: R3,R29,R30,R31 */ /* Parameters: None */ /* Returns using R15 */ /* Result in: R3 */ /*--------------------------------------------------*/ Get_16Bit: and r30,r0,r0 addi r31,r0,1Get_16Bit_1: /* Get the next byte */ brlid r29,Get_Char nop sbi r3,r31,temp_mem addi r31,r31,-1 bgei r31,Get_16Bit_1 rtsd r15,8 lhui r3,r0,temp_mem /*--------------------------------------------------*/ /* Get a word function */ /* - Get 4 bytes using Get_Char function */ /* - Store each byte in a memory location,temp_mem */ /* using store byte SBI instruction */ /* stores the received byte in the order */ /* addr+3,addr+2,addr+1,addr+0 */ /* Uses: R3,R29,R30,R31 */ /* Parameters: None */ /* Returns using R15 */ /* Result in: R3 */ /*--------------------------------------------------*/Get_32Bit: and r30,r0,r0 addi r31,r0,3Get_32Bit_1: /* Get the next byte */ brlid r29,Get_Char nop sbi r3,r31,temp_mem addi r31,r31,-1 bgei r31,Get_32Bit_1 rtsd r15,8 lwi r3,r0,temp_mem /*--------------------------------------------------*/ /* Wait for UART TX is become empty function */ /* - loop until UART TXC buffer is empty */ /* Uses: R25 */ /* Parameters: None */ /* Returns using R29 */ /* Result in: no result */ /*--------------------------------------------------*/Wait_for_TX_space: lwi r25,r0,uart_stat andi r25,r25,uart_tx_buffer_empty /* tx buffer empty */ beqi r25, Wait_for_TX_space rtsd r29,8 nop /*--------------------------------------------------*/ /* Send a half word function */ /* - Store the half word to send in temp_mem */ /* - loop */ /* - Wait for TX to become empty */ /* - Read a byte out of temp_mem */ /* reads the bytes in the order */ /* addr+1,addr+0 */ /* - Send that byte (Write to the UART_TX fifo) */ /* - Repeat for all 2 bytes */ /* Uses: R3,R25,R29,R30,R31 */ /* Parameters: R5 Half Word to send */ /* Returns using R15 */ /* Result in: No result */ /*--------------------------------------------------*/Send_16Bit: addi r31,r0,1 brid Send_32Bit_1 shi r5,r0,temp_mem /*--------------------------------------------------*/ /* Send a word function */ /* - Store the word to send in temp_mem */ /* - loop */ /* - Wait for TX to become empty */ /* - Read a byte out of temp_mem */ /* reads the bytes in the order */ /* addr+3,addr+2,addr+1,addr+0 */ /* - Send that byte (Write to the UART_TX fifo) */ /* - Repeat for all 4 bytes */ /* Uses: R3,R25,R29,R30,R31 */ /* Parameters: R5 Word to send */ /* Returns using R15 */ /* Result in: No result */ /*--------------------------------------------------*/Send_32Bit: addi r31,r0,3 swi r5,r0,temp_mem Send_32Bit_1: /* Wait for free space in the transmit buffer */ brlid r29, Wait_for_TX_space /* Get the right byte from the word to transmit */ lbui r30,r31,temp_mem swi r30,r0,uart_tx_data addi r31,r31,-1 bgei r31, Send_32Bit_1 rtsd r15,8 nop /*--------------------------------------------------*/ /* Save register to register_dump function */ /* - Store all registers to the register dump */ /* except R0 : makes no sense always zero */ /* R15 : needed for the return address */ /* - R15 has to saved before calling this function */ /* to the address register_dump+15*4 */ /* Uses: */ /* Parameters: */ /* Returns using R15 */ /* Result in: No result */ /*--------------------------------------------------*/Dump_All_Registers:/* swi r0,r0,register_dump + 0 */ swi r1,r0,register_dump + 4 swi r2,r0,register_dump + 8 swi r3,r0,register_dump+12 swi r4,r0,register_dump+16 swi r5,r0,register_dump+20 swi r6,r0,register_dump+24 swi r7,r0,register_dump+28 swi r8,r0,register_dump+32 swi r9,r0,register_dump+36 swi r10,r0,register_dump+40 swi r11,r0,register_dump+44 swi r12,r0,register_dump+48 swi r13,r0,register_dump+52 swi r14,r0,register_dump+56/* swi r15,r0,register_dump+60 */ swi r16,r0,register_dump+64 swi r17,r0,register_dump+68 swi r18,r0,register_dump+72 swi r19,r0,register_dump+76 swi r20,r0,register_dump+80 swi r21,r0,register_dump+84 swi r22,r0,register_dump+88 swi r23,r0,register_dump+92 swi r24,r0,register_dump+96 swi r25,r0,register_dump+100 swi r26,r0,register_dump+104 swi r27,r0,register_dump+108 swi r28,r0,register_dump+112 swi r29,r0,register_dump+116 swi r30,r0,register_dump+120 swi r31,r0,register_dump+124 mfs r31, rmsr brid Send_Status swi r31,r0,register_dump+132 /*--------------------------------------------------*/ /* Read registers from register_dump function */ /* - Read all registers to the register dump */ /* except R0 : makes no sense always zero */ /* R15 : needed for the return address */ /* R16 : contains the debug return address*/ /* and can't be overwritten */ /* R29 : is used by the eXecute command */ /* for storing the execution address*/ /* Uses: */ /* Parameters: */ /* Returns using R15 */ /* Result in: No result */ /*--------------------------------------------------*/Get_All_Registers: /* lwi r0,r0,register_dump + 0 */ lwi r1,r0,register_dump + 4 lwi r2,r0,register_dump + 8 lwi r3,r0,register_dump+12 lwi r4,r0,register_dump+16 lwi r5,r0,register_dump+20 lwi r6,r0,register_dump+24 lwi r7,r0,register_dump+28 lwi r8,r0,register_dump+32 lwi r9,r0,register_dump+36 lwi r10,r0,register_dump+40 lwi r11,r0,register_dump+44 lwi r12,r0,register_dump+48 lwi r13,r0,register_dump+52 lwi r14,r0,register_dump+56 /* lwi r15,r0,register_dump+60 */ lwi r16,r0,register_dump+64 lwi r17,r0,register_dump+68 lwi r18,r0,register_dump+72 lwi r19,r0,register_dump+76 lwi r20,r0,register_dump+80 lwi r21,r0,register_dump+84 lwi r22,r0,register_dump+88 lwi r23,r0,register_dump+92 lwi r24,r0,register_dump+96 lwi r25,r0,register_dump+100 lwi r26,r0,register_dump+104 lwi r27,r0,register_dump+108 lwi r28,r0,register_dump+112 lwi r29,r0,register_dump+116 lwi r30,r0,register_dump+120 lwi r31,r0,register_dump+132 mts rmsr, r31 rtsd r15,8 lwi r31,r0,register_dump+124 /* Temporary memory needed for the byte-to-word */ /* and word-to-byte translation */ .data .align 2temp_mem: .int 0 /* 34 words containing the register_dump (32 regs + pc + msr) */ .align 2register_dump: .fill 34, 4, 0 .end xmd_stub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -