firmware/disasm.c
/**
 * Disassemble instructions from external memory to console
 */
Disassemble instructions from external memory to console
Disassemble instructions from external memory to console
void disasm_mem(uint32_t start, uint32_t end)
{
    char mnemonic[64];
    uint8_t buf[256];
    uint8_t i;
    disasm_addr = start;
    disasm_index = 0;
    disasm_buf = buf;
    while (start <= disasm_addr && disasm_addr <= end) {
        instr_length = 0;
        printf_P(PSTR("%05lx "), disasm_addr);
        disasm(disasm_next_byte, mnemonic);
        for (i = 0; i < instr_length; i++) {
            printf_P(PSTR("%02x "), instr_bytes[i]);
        }
        i = 4 - instr_length;
        while (i--)
            printf_P(PSTR("   "));
        for (i = 0; i < instr_length; i++) {
            if (0x20 <= instr_bytes[i] && instr_bytes[i] <= 0x7e)
                printf_P(PSTR("%c"), instr_bytes[i]);
            else
                printf_P(PSTR("."));
        }
        i = 4 - instr_length;
        while (i--)
            printf_P(PSTR(" "));
        printf_P(PSTR(" %s\n"), mnemonic);
    }
}
void disasm_mem ( uint32_t start , uint32_t end ) { char mnemonic [ 64 ] ; uint8_t buf [ 256 ] ; uint8_t i ; disasm_addr = start ; disasm_index = 0 ; disasm_buf = buf ; while ( start <= disasm_addr && disasm_addr <= end ) { instr_length = 0 ; printf_P ( PSTR ( " " ) , disasm_addr ) ; disasm ( disasm_next_byte , mnemonic ) ; for ( i = 0 ; i < instr_length ; i ++ ) { printf_P ( PSTR ( " " ) , instr_bytes [ i ] ) ; } i = 4 - instr_length ; while ( i -- ) printf_P ( PSTR ( " " ) ) ; for ( i = 0 ; i < instr_length ; i ++ ) { if ( 0x20 <= instr_bytes [ i ] && instr_bytes [ i ] <= 0x7e ) printf_P ( PSTR ( " " ) , instr_bytes [ i ] ) ; else printf_P ( PSTR ( " " ) ) ; } i = 4 - instr_length ; while ( i -- ) printf_P ( PSTR ( " " ) ) ; printf_P ( PSTR ( " \n " ) , mnemonic ) ; } }
Disassemble instructions from external memory to console
Disassemble instructions from external memory to console