Saturday, December 19, 2015

Phase 2: Command Interpreter

After 5 hours straight debugging ... I have a rudimentary command interpreter in place. Most notably I had to change my tclib_strcmp routine in IE_tclib.S. Other files such as IE_egwu_monitor/IE_egwu_uartio and even IE_egwu_setup in the "core" subdirectory underwent changes.

What stuck out what a bug in the UART swinging buffer and the mutex shared between the user program and the DMA Engine's ISR that releases that resource. Anyway ... I have it all squared away. Once I debug the memory peek and poke command (mdx and mwx) I can transition to phase 3

time for some much needed sleep

/*
 *****************************************************************
 *description:  string comparison 
 *inputs:       char *ptrStrSrc=string 1
 *              char *ptrStrDst=string 2
 *              int  wdCount   =number of characters to compare 
 *output:       int = 0 on success failing index on error
 *int
 *tclib_strcmp(unsigned char *ptrStrSrc,\
 *             unsigned char *ptrStrDst,\
 *             int wdCount)
 *{
 *unsigned int wdIndex;
 *
 *for(wdIndex=0; wdIndex <wdCount; wdIndex++)
 *      {
 *      if (ptrStrSrc[wdIndex] == NULL || \
 *           ptrStrDst[wdIndex] == NULL || \
 *          (ptrStrSrc[wdIndex] - ptrStrDst[wdIndex]) !=0)
 *              return wdIndex;
 *      }
 *
 *return 0;          
 *}
 *****************************************************************
 */
    .align  2
    .global tclib_strcmp
/*
 *****************************************************************
 *r0 = ptrDst
 *r1 = ptrSrc
 *returns r0 strcmp value
 *r1 = src1
 *r2 = src2
 *r3 = scratch
 *r4 = scratch
 *r0 = cmp
 *****************************************************************
 */
    .thumb_func
    tclib_strcmp:
    push    {r1-r4, lr}

    mov     r2, r0                      /*save src1 in r2*/
    mov     r0, #0                      /*zero out r0*/


        tclib_strcmp_loop:
        ldrb    r3, [r1], #1            
        andS    r3, r3, #0x0ff          /*clear upper bits*/
        orrS    r3, r3, #0              /*end of string?*/
        beq     tclib_strcmp_exit

        ldrb    r4, [r2], #1
        andS    r4, r4, #0x0ff          /*clear upper bits*/
        orrS    r4, r4, #0              /*end of string?*/
        beq     tclib_strcmp_exit

        cmp     r4, r3
        it      EQ
        beq     tclib_strcmp_loop
                                        /*else*/
        ite     HI
        addhi   r0, r0, #1              /*track strcmp results*/
        subls   r0, r0, #1              /*ditto*/

        itt     NE
        popne   {r1-r4, lr}             /*exit*/
        movne   pc, lr                  /*exit*/
        
        
        tclib_strcmp_exit:
        itt     EQ
        popeq   {r1-r4, lr}             /*exit*/
        moveq   pc, lr                  /*exit*/

        b       tclib_strcmp_loop
 
 
 
 
Finally this is what the command interpreter output looks like under minicom 
 
..ie........ 
..ieieie.... 
..ie........ 
..ieieie.... 
..ie........ Igbo Embedded 
..ieieie.... EGWU v1.1 (c) 2015 
..ie........ Samuel Igwe


egwu-> help
go address           :  jump to address  
ldusb address        :  load file to address using USB  
ldxmodem address     :  load file to address using xmodem+serial port  
help                 :  display command table  
mdb|mdh|mdw addr len :  display byte|word|dword at address         
mwb|mwh|mww addr val :  write byte|word|dword to address         
reset                :  reset the lpc17
egwu-> mdb 0x10000000
invalid or non existent address

egwu-> reset 

No comments:

Post a Comment