Hello I am new to this forum and new to Arm 7 programming.
My question is - I have a programming (I think it is a Flash) file in hex ,which I downloaded to Arm 7 MCU through Rlink usb tool to run the programme.
If I need to modify this programme how do I do this?
Thanks
If the dis-assembly code can be generated, is it match your intention? If it is enough, I will provide the following code.
#include <stdio.h> FILE *fp; main(int argc, char *argv[]) { int ch; int pos=0; fp = fopen(argv[1], "rb"); printf(".text\n"); printf("main:\n"); while((ch=fgetc(fp))!=EOF){ if(pos==0){ printf(".byte\t"); } printf("0x%02x",ch&0xff); if(pos==7){ pos=0; printf("\n"); } else{ printf(","); pos++; } } fclose(fp); }
This is to convert a binary code to an assembler source.
By using the objcopy command, you can get binary file corresponding to the hex file.
You can assemble the source file and get dis-assembly code by using the objdump command.
The following is an example.
$ cat tmp.hexS00A0000746D702E68657831S11380006400A0E3FFFFFFEA010050E3940000DAFCS11380100030A0E3F04F2DE93CD04DE200308DE577S1138020020050E38100000A023040E218308DE57ES113803003B0A0E10030A0E304308DE5033040E25AS11380400130C3E3040040E2003063E024308DE5F6S113805001005BE30B30A0E1830000DA0020A0E321S113806030B08DE508208DE5020053E36B00000A73S1138070022043E21C208DE502B0A0E10020A0E331S11380800C208DE5032043E20120C2E3043043E2E7S1138090033062E028308DE501005BE30B30A0E1A2S11380A05C0000DA0020A0E334B08DE510208DE5FBS11380B0020053E35300000A022043E220208DE52ES11380C002A0A0E10020A0E314208DE5032043E2F8S11380D00120C2E3043043E2033062E02C308DE53AS11380E001005AE30A30A0E1440000DA0090A0E362S11380F0020053E33E00000A02B043E20B60A0E139S11381000070A0E3038043E20180C8E3043043E24BS1138110038068E0010056E30640A0E1320000DA83S11381200050A0E3010044E2B6FFFFEB024044E24AS1138130010054E3005085E0F9FFFFCA015085E2D5S1138140026046E2080056E1057087E0F0FFFF1A7ES1138150017087E201005BE30B30A0E1079089E046S1138160E2FFFFCA019089E22C309DE502A04AE2B9S113817003005AE114309DE5093083E014308DE5A5S1138180D6FFFF1A019083E220309DE510209DE583S1138190010053E3092082E010208DE5C3FFFFCAECS11381A034B09DE5013082E228209DE502B04BE227S11381B002005BE10C209DE5033082E00C308DE58CS11381C0B4FFFF1A012083E21C309DE508109DE5F1S11381D0010053E3022081E008208DE5A1FFFFCADES11381E030B09DE5013082E2200000EA0150A0E3B6S11381F0D2FFFFEA0170A0E300B0A0E3D4FFFFEADES11382000190A0E3D7FFFFEA0030A0E30190A0E3D0S113821020308DE5DCFFFFEA0130A0E3E1FFFFEA57S11382200030A0E30120A0E31C308DE5E6FFFFEA67S11382300020A0E30130A0E318208DE5010052E303S11382400200A0E100209DE5033082E000308DE5CES113825072FFFFCA010083E23CD08DE2F04FBDE81BS11382601EFF2FE10100A0E31EFF2FE10130A0E378S113827024209DE502B04BE202005BE104209DE571S1138280033082E004308DE570FFFF1A013083E291S10B829018209DE5E8FFFFEA58S90380007C $ ../gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/arm-none-eabi-objcopy -I srec -O binary tmp.hex tmp.bin $ ./bin2src tmp.bin > tmp.s # This is the command shown above $ cat tmp.s.textmain:.byte 0x64,0x00,0xa0,0xe3,0xff,0xff,0xff,0xea.byte 0x01,0x00,0x50,0xe3,0x94,0x00,0x00,0xda.byte 0x00,0x30,0xa0,0xe3,0xf0,0x4f,0x2d,0xe9.byte 0x3c,0xd0,0x4d,0xe2,0x00,0x30,0x8d,0xe5.byte 0x02,0x00,0x50,0xe3,0x81,0x00,0x00,0x0a.byte 0x02,0x30,0x40,0xe2,0x18,0x30,0x8d,0xe5.byte 0x03,0xb0,0xa0,0xe1,0x00,0x30,0xa0,0xe3.byte 0x04,0x30,0x8d,0xe5,0x03,0x30,0x40,0xe2.byte 0x01,0x30,0xc3,0xe3,0x04,0x00,0x40,0xe2.byte 0x00,0x30,0x63,0xe0,0x24,0x30,0x8d,0xe5.byte 0x01,0x00,0x5b,0xe3,0x0b,0x30,0xa0,0xe1.byte 0x83,0x00,0x00,0xda,0x00,0x20,0xa0,0xe3.byte 0x30,0xb0,0x8d,0xe5,0x08,0x20,0x8d,0xe5.byte 0x02,0x00,0x53,0xe3,0x6b,0x00,0x00,0x0a.byte 0x02,0x20,0x43,0xe2,0x1c,0x20,0x8d,0xe5.byte 0x02,0xb0,0xa0,0xe1,0x00,0x20,0xa0,0xe3.byte 0x0c,0x20,0x8d,0xe5,0x03,0x20,0x43,0xe2.byte 0x01,0x20,0xc2,0xe3,0x04,0x30,0x43,0xe2.byte 0x03,0x30,0x62,0xe0,0x28,0x30,0x8d,0xe5.byte 0x01,0x00,0x5b,0xe3,0x0b,0x30,0xa0,0xe1.byte 0x5c,0x00,0x00,0xda,0x00,0x20,0xa0,0xe3.byte 0x34,0xb0,0x8d,0xe5,0x10,0x20,0x8d,0xe5.byte 0x02,0x00,0x53,0xe3,0x53,0x00,0x00,0x0a.byte 0x02,0x20,0x43,0xe2,0x20,0x20,0x8d,0xe5.byte 0x02,0xa0,0xa0,0xe1,0x00,0x20,0xa0,0xe3.byte 0x14,0x20,0x8d,0xe5,0x03,0x20,0x43,0xe2.byte 0x01,0x20,0xc2,0xe3,0x04,0x30,0x43,0xe2.byte 0x03,0x30,0x62,0xe0,0x2c,0x30,0x8d,0xe5.byte 0x01,0x00,0x5a,0xe3,0x0a,0x30,0xa0,0xe1.byte 0x44,0x00,0x00,0xda,0x00,0x90,0xa0,0xe3.byte 0x02,0x00,0x53,0xe3,0x3e,0x00,0x00,0x0a.byte 0x02,0xb0,0x43,0xe2,0x0b,0x60,0xa0,0xe1.byte 0x00,0x70,0xa0,0xe3,0x03,0x80,0x43,0xe2.byte 0x01,0x80,0xc8,0xe3,0x04,0x30,0x43,0xe2.byte 0x03,0x80,0x68,0xe0,0x01,0x00,0x56,0xe3.byte 0x06,0x40,0xa0,0xe1,0x32,0x00,0x00,0xda.byte 0x00,0x50,0xa0,0xe3,0x01,0x00,0x44,0xe2.byte 0xb6,0xff,0xff,0xeb,0x02,0x40,0x44,0xe2.byte 0x01,0x00,0x54,0xe3,0x00,0x50,0x85,0xe0.byte 0xf9,0xff,0xff,0xca,0x01,0x50,0x85,0xe2.byte 0x02,0x60,0x46,0xe2,0x08,0x00,0x56,0xe1.byte 0x05,0x70,0x87,0xe0,0xf0,0xff,0xff,0x1a.byte 0x01,0x70,0x87,0xe2,0x01,0x00,0x5b,0xe3.byte 0x0b,0x30,0xa0,0xe1,0x07,0x90,0x89,0xe0.byte 0xe2,0xff,0xff,0xca,0x01,0x90,0x89,0xe2.byte 0x2c,0x30,0x9d,0xe5,0x02,0xa0,0x4a,0xe2.byte 0x03,0x00,0x5a,0xe1,0x14,0x30,0x9d,0xe5.byte 0x09,0x30,0x83,0xe0,0x14,0x30,0x8d,0xe5.byte 0xd6,0xff,0xff,0x1a,0x01,0x90,0x83,0xe2.byte 0x20,0x30,0x9d,0xe5,0x10,0x20,0x9d,0xe5.byte 0x01,0x00,0x53,0xe3,0x09,0x20,0x82,0xe0.byte 0x10,0x20,0x8d,0xe5,0xc3,0xff,0xff,0xca.byte 0x34,0xb0,0x9d,0xe5,0x01,0x30,0x82,0xe2.byte 0x28,0x20,0x9d,0xe5,0x02,0xb0,0x4b,0xe2.byte 0x02,0x00,0x5b,0xe1,0x0c,0x20,0x9d,0xe5.byte 0x03,0x30,0x82,0xe0,0x0c,0x30,0x8d,0xe5.byte 0xb4,0xff,0xff,0x1a,0x01,0x20,0x83,0xe2.byte 0x1c,0x30,0x9d,0xe5,0x08,0x10,0x9d,0xe5.byte 0x01,0x00,0x53,0xe3,0x02,0x20,0x81,0xe0.byte 0x08,0x20,0x8d,0xe5,0xa1,0xff,0xff,0xca.byte 0x30,0xb0,0x9d,0xe5,0x01,0x30,0x82,0xe2.byte 0x20,0x00,0x00,0xea,0x01,0x50,0xa0,0xe3.byte 0xd2,0xff,0xff,0xea,0x01,0x70,0xa0,0xe3.byte 0x00,0xb0,0xa0,0xe3,0xd4,0xff,0xff,0xea.byte 0x01,0x90,0xa0,0xe3,0xd7,0xff,0xff,0xea.byte 0x00,0x30,0xa0,0xe3,0x01,0x90,0xa0,0xe3.byte 0x20,0x30,0x8d,0xe5,0xdc,0xff,0xff,0xea.byte 0x01,0x30,0xa0,0xe3,0xe1,0xff,0xff,0xea.byte 0x00,0x30,0xa0,0xe3,0x01,0x20,0xa0,0xe3.byte 0x1c,0x30,0x8d,0xe5,0xe6,0xff,0xff,0xea.byte 0x00,0x20,0xa0,0xe3,0x01,0x30,0xa0,0xe3.byte 0x18,0x20,0x8d,0xe5,0x01,0x00,0x52,0xe3.byte 0x02,0x00,0xa0,0xe1,0x00,0x20,0x9d,0xe5.byte 0x03,0x30,0x82,0xe0,0x00,0x30,0x8d,0xe5.byte 0x72,0xff,0xff,0xca,0x01,0x00,0x83,0xe2.byte 0x3c,0xd0,0x8d,0xe2,0xf0,0x4f,0xbd,0xe8.byte 0x1e,0xff,0x2f,0xe1,0x01,0x00,0xa0,0xe3.byte 0x1e,0xff,0x2f,0xe1,0x01,0x30,0xa0,0xe3.byte 0x24,0x20,0x9d,0xe5,0x02,0xb0,0x4b,0xe2.byte 0x02,0x00,0x5b,0xe1,0x04,0x20,0x9d,0xe5.byte 0x03,0x30,0x82,0xe0,0x04,0x30,0x8d,0xe5.byte 0x70,0xff,0xff,0x1a,0x01,0x30,0x83,0xe2.byte 0x18,0x20,0x9d,0xe5,0xe8,0xff,0xff,0xea $ ../gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/arm-none-eabi-gcc -o tmp2.out tmp.s -nostdlibd:/gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00008000 $ ../gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/arm-none-eabi-objdump -D tmp2.out tmp2.out: file format elf32-littlearm Disassembly of section .text: 00008000 <main>: 8000: e3a00064 mov r0, #100 ; 0x64 8004: eaffffff b 8008 <main+0x8> 8008: e3500001 cmp r0, #1 800c: da000094 ble 8264 <main+0x264> 8010: e3a03000 mov r3, #0 8014: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr} 8018: e24dd03c sub sp, sp, #60 ; 0x3c 801c: e58d3000 str r3, [sp] 8020: e3500002 cmp r0, #2 8024: 0a000081 beq 8230 <main+0x230> 8028: e2403002 sub r3, r0, #2 802c: e58d3018 str r3, [sp, #24] 8030: e1a0b003 mov fp, r3 8034: e3a03000 mov r3, #0 8038: e58d3004 str r3, [sp, #4] 803c: e2403003 sub r3, r0, #3 8040: e3c33001 bic r3, r3, #1 8044: e2400004 sub r0, r0, #4 8048: e0633000 rsb r3, r3, r0 804c: e58d3024 str r3, [sp, #36] ; 0x24 8050: e35b0001 cmp fp, #1 8054: e1a0300b mov r3, fp 8058: da000083 ble 826c <main+0x26c> 805c: e3a02000 mov r2, #0 8060: e58db030 str fp, [sp, #48] ; 0x30 8064: e58d2008 str r2, [sp, #8] 8068: e3530002 cmp r3, #2 806c: 0a00006b beq 8220 <main+0x220> 8070: e2432002 sub r2, r3, #2 8074: e58d201c str r2, [sp, #28] 8078: e1a0b002 mov fp, r2 807c: e3a02000 mov r2, #0 8080: e58d200c str r2, [sp, #12] 8084: e2432003 sub r2, r3, #3 8088: e3c22001 bic r2, r2, #1 808c: e2433004 sub r3, r3, #4 8090: e0623003 rsb r3, r2, r3 8094: e58d3028 str r3, [sp, #40] ; 0x28 8098: e35b0001 cmp fp, #1 809c: e1a0300b mov r3, fp 80a0: da00005c ble 8218 <main+0x218> 80a4: e3a02000 mov r2, #0 80a8: e58db034 str fp, [sp, #52] ; 0x34 80ac: e58d2010 str r2, [sp, #16] 80b0: e3530002 cmp r3, #2 80b4: 0a000053 beq 8208 <main+0x208> 80b8: e2432002 sub r2, r3, #2 80bc: e58d2020 str r2, [sp, #32] 80c0: e1a0a002 mov sl, r2 80c4: e3a02000 mov r2, #0 80c8: e58d2014 str r2, [sp, #20] 80cc: e2432003 sub r2, r3, #3 80d0: e3c22001 bic r2, r2, #1 80d4: e2433004 sub r3, r3, #4 80d8: e0623003 rsb r3, r2, r3 80dc: e58d302c str r3, [sp, #44] ; 0x2c 80e0: e35a0001 cmp sl, #1 80e4: e1a0300a mov r3, sl 80e8: da000044 ble 8200 <main+0x200> 80ec: e3a09000 mov r9, #0 80f0: e3530002 cmp r3, #2 80f4: 0a00003e beq 81f4 <main+0x1f4> 80f8: e243b002 sub fp, r3, #2 80fc: e1a0600b mov r6, fp 8100: e3a07000 mov r7, #0 8104: e2438003 sub r8, r3, #3 8108: e3c88001 bic r8, r8, #1 810c: e2433004 sub r3, r3, #4 8110: e0688003 rsb r8, r8, r3 8114: e3560001 cmp r6, #1 8118: e1a04006 mov r4, r6 811c: da000032 ble 81ec <main+0x1ec> 8120: e3a05000 mov r5, #0 8124: e2440001 sub r0, r4, #1 8128: ebffffb6 bl 8008 <main+0x8> 812c: e2444002 sub r4, r4, #2 8130: e3540001 cmp r4, #1 8134: e0855000 add r5, r5, r0 8138: cafffff9 bgt 8124 <main+0x124> 813c: e2855001 add r5, r5, #1 8140: e2466002 sub r6, r6, #2 8144: e1560008 cmp r6, r8 8148: e0877005 add r7, r7, r5 814c: 1afffff0 bne 8114 <main+0x114> 8150: e2877001 add r7, r7, #1 8154: e35b0001 cmp fp, #1 8158: e1a0300b mov r3, fp 815c: e0899007 add r9, r9, r7 8160: caffffe2 bgt 80f0 <main+0xf0> 8164: e2899001 add r9, r9, #1 8168: e59d302c ldr r3, [sp, #44] ; 0x2c 816c: e24aa002 sub sl, sl, #2 8170: e15a0003 cmp sl, r3 8174: e59d3014 ldr r3, [sp, #20] 8178: e0833009 add r3, r3, r9 817c: e58d3014 str r3, [sp, #20] 8180: 1affffd6 bne 80e0 <main+0xe0> 8184: e2839001 add r9, r3, #1 8188: e59d3020 ldr r3, [sp, #32] 818c: e59d2010 ldr r2, [sp, #16] 8190: e3530001 cmp r3, #1 8194: e0822009 add r2, r2, r9 8198: e58d2010 str r2, [sp, #16] 819c: caffffc3 bgt 80b0 <main+0xb0> 81a0: e59db034 ldr fp, [sp, #52] ; 0x34 81a4: e2823001 add r3, r2, #1 81a8: e59d2028 ldr r2, [sp, #40] ; 0x28 81ac: e24bb002 sub fp, fp, #2 81b0: e15b0002 cmp fp, r2 81b4: e59d200c ldr r2, [sp, #12] 81b8: e0823003 add r3, r2, r3 81bc: e58d300c str r3, [sp, #12] 81c0: 1affffb4 bne 8098 <main+0x98> 81c4: e2832001 add r2, r3, #1 81c8: e59d301c ldr r3, [sp, #28] 81cc: e59d1008 ldr r1, [sp, #8] 81d0: e3530001 cmp r3, #1 81d4: e0812002 add r2, r1, r2 81d8: e58d2008 str r2, [sp, #8] 81dc: caffffa1 bgt 8068 <main+0x68> 81e0: e59db030 ldr fp, [sp, #48] ; 0x30 81e4: e2823001 add r3, r2, #1 81e8: ea000020 b 8270 <main+0x270> 81ec: e3a05001 mov r5, #1 81f0: eaffffd2 b 8140 <main+0x140> 81f4: e3a07001 mov r7, #1 81f8: e3a0b000 mov fp, #0 81fc: eaffffd4 b 8154 <main+0x154> 8200: e3a09001 mov r9, #1 8204: eaffffd7 b 8168 <main+0x168> 8208: e3a03000 mov r3, #0 820c: e3a09001 mov r9, #1 8210: e58d3020 str r3, [sp, #32] 8214: eaffffdc b 818c <main+0x18c> 8218: e3a03001 mov r3, #1 821c: eaffffe1 b 81a8 <main+0x1a8> 8220: e3a03000 mov r3, #0 8224: e3a02001 mov r2, #1 8228: e58d301c str r3, [sp, #28] 822c: eaffffe6 b 81cc <main+0x1cc> 8230: e3a02000 mov r2, #0 8234: e3a03001 mov r3, #1 8238: e58d2018 str r2, [sp, #24] 823c: e3520001 cmp r2, #1 8240: e1a00002 mov r0, r2 8244: e59d2000 ldr r2, [sp] 8248: e0823003 add r3, r2, r3 824c: e58d3000 str r3, [sp] 8250: caffff72 bgt 8020 <main+0x20> 8254: e2830001 add r0, r3, #1 8258: e28dd03c add sp, sp, #60 ; 0x3c 825c: e8bd4ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, lr} 8260: e12fff1e bx lr 8264: e3a00001 mov r0, #1 8268: e12fff1e bx lr 826c: e3a03001 mov r3, #1 8270: e59d2024 ldr r2, [sp, #36] ; 0x24 8274: e24bb002 sub fp, fp, #2 8278: e15b0002 cmp fp, r2 827c: e59d2004 ldr r2, [sp, #4] 8280: e0823003 add r3, r2, r3 8284: e58d3004 str r3, [sp, #4] 8288: 1affff70 bne 8050 <main+0x50> 828c: e2833001 add r3, r3, #1 8290: e59d2018 ldr r2, [sp, #24] 8294: eaffffe8 b 823c <main+0x23c> Disassembly of section .ARM.attributes: 00000000 <.ARM.attributes>: 0: 00001341 andeq r1, r0, r1, asr #6 4: 61656100 cmnvs r5, r0, lsl #2 8: 01006962 tsteq r0, r2, ror #18 c: 00000009 andeq r0, r0, r9 10: 01090108 tsteq r9, r8, lsl #2
$ cat tmp.hexS00A0000746D702E68657831S11380006400A0E3FFFFFFEA010050E3940000DAFCS11380100030A0E3F04F2DE93CD04DE200308DE577S1138020020050E38100000A023040E218308DE57ES113803003B0A0E10030A0E304308DE5033040E25AS11380400130C3E3040040E2003063E024308DE5F6S113805001005BE30B30A0E1830000DA0020A0E321S113806030B08DE508208DE5020053E36B00000A73S1138070022043E21C208DE502B0A0E10020A0E331S11380800C208DE5032043E20120C2E3043043E2E7S1138090033062E028308DE501005BE30B30A0E1A2S11380A05C0000DA0020A0E334B08DE510208DE5FBS11380B0020053E35300000A022043E220208DE52ES11380C002A0A0E10020A0E314208DE5032043E2F8S11380D00120C2E3043043E2033062E02C308DE53AS11380E001005AE30A30A0E1440000DA0090A0E362S11380F0020053E33E00000A02B043E20B60A0E139S11381000070A0E3038043E20180C8E3043043E24BS1138110038068E0010056E30640A0E1320000DA83S11381200050A0E3010044E2B6FFFFEB024044E24AS1138130010054E3005085E0F9FFFFCA015085E2D5S1138140026046E2080056E1057087E0F0FFFF1A7ES1138150017087E201005BE30B30A0E1079089E046S1138160E2FFFFCA019089E22C309DE502A04AE2B9S113817003005AE114309DE5093083E014308DE5A5S1138180D6FFFF1A019083E220309DE510209DE583S1138190010053E3092082E010208DE5C3FFFFCAECS11381A034B09DE5013082E228209DE502B04BE227S11381B002005BE10C209DE5033082E00C308DE58CS11381C0B4FFFF1A012083E21C309DE508109DE5F1S11381D0010053E3022081E008208DE5A1FFFFCADES11381E030B09DE5013082E2200000EA0150A0E3B6S11381F0D2FFFFEA0170A0E300B0A0E3D4FFFFEADES11382000190A0E3D7FFFFEA0030A0E30190A0E3D0S113821020308DE5DCFFFFEA0130A0E3E1FFFFEA57S11382200030A0E30120A0E31C308DE5E6FFFFEA67S11382300020A0E30130A0E318208DE5010052E303S11382400200A0E100209DE5033082E000308DE5CES113825072FFFFCA010083E23CD08DE2F04FBDE81BS11382601EFF2FE10100A0E31EFF2FE10130A0E378S113827024209DE502B04BE202005BE104209DE571S1138280033082E004308DE570FFFF1A013083E291S10B829018209DE5E8FFFFEA58S90380007C
$ ../gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/arm-none-eabi-objcopy -I srec -O binary tmp.hex tmp.bin
$ ./bin2src tmp.bin > tmp.s # This is the command shown above
$ cat tmp.s.textmain:.byte 0x64,0x00,0xa0,0xe3,0xff,0xff,0xff,0xea.byte 0x01,0x00,0x50,0xe3,0x94,0x00,0x00,0xda.byte 0x00,0x30,0xa0,0xe3,0xf0,0x4f,0x2d,0xe9.byte 0x3c,0xd0,0x4d,0xe2,0x00,0x30,0x8d,0xe5.byte 0x02,0x00,0x50,0xe3,0x81,0x00,0x00,0x0a.byte 0x02,0x30,0x40,0xe2,0x18,0x30,0x8d,0xe5.byte 0x03,0xb0,0xa0,0xe1,0x00,0x30,0xa0,0xe3.byte 0x04,0x30,0x8d,0xe5,0x03,0x30,0x40,0xe2.byte 0x01,0x30,0xc3,0xe3,0x04,0x00,0x40,0xe2.byte 0x00,0x30,0x63,0xe0,0x24,0x30,0x8d,0xe5.byte 0x01,0x00,0x5b,0xe3,0x0b,0x30,0xa0,0xe1.byte 0x83,0x00,0x00,0xda,0x00,0x20,0xa0,0xe3.byte 0x30,0xb0,0x8d,0xe5,0x08,0x20,0x8d,0xe5.byte 0x02,0x00,0x53,0xe3,0x6b,0x00,0x00,0x0a.byte 0x02,0x20,0x43,0xe2,0x1c,0x20,0x8d,0xe5.byte 0x02,0xb0,0xa0,0xe1,0x00,0x20,0xa0,0xe3.byte 0x0c,0x20,0x8d,0xe5,0x03,0x20,0x43,0xe2.byte 0x01,0x20,0xc2,0xe3,0x04,0x30,0x43,0xe2.byte 0x03,0x30,0x62,0xe0,0x28,0x30,0x8d,0xe5.byte 0x01,0x00,0x5b,0xe3,0x0b,0x30,0xa0,0xe1.byte 0x5c,0x00,0x00,0xda,0x00,0x20,0xa0,0xe3.byte 0x34,0xb0,0x8d,0xe5,0x10,0x20,0x8d,0xe5.byte 0x02,0x00,0x53,0xe3,0x53,0x00,0x00,0x0a.byte 0x02,0x20,0x43,0xe2,0x20,0x20,0x8d,0xe5.byte 0x02,0xa0,0xa0,0xe1,0x00,0x20,0xa0,0xe3.byte 0x14,0x20,0x8d,0xe5,0x03,0x20,0x43,0xe2.byte 0x01,0x20,0xc2,0xe3,0x04,0x30,0x43,0xe2.byte 0x03,0x30,0x62,0xe0,0x2c,0x30,0x8d,0xe5.byte 0x01,0x00,0x5a,0xe3,0x0a,0x30,0xa0,0xe1.byte 0x44,0x00,0x00,0xda,0x00,0x90,0xa0,0xe3.byte 0x02,0x00,0x53,0xe3,0x3e,0x00,0x00,0x0a.byte 0x02,0xb0,0x43,0xe2,0x0b,0x60,0xa0,0xe1.byte 0x00,0x70,0xa0,0xe3,0x03,0x80,0x43,0xe2.byte 0x01,0x80,0xc8,0xe3,0x04,0x30,0x43,0xe2.byte 0x03,0x80,0x68,0xe0,0x01,0x00,0x56,0xe3.byte 0x06,0x40,0xa0,0xe1,0x32,0x00,0x00,0xda.byte 0x00,0x50,0xa0,0xe3,0x01,0x00,0x44,0xe2.byte 0xb6,0xff,0xff,0xeb,0x02,0x40,0x44,0xe2.byte 0x01,0x00,0x54,0xe3,0x00,0x50,0x85,0xe0.byte 0xf9,0xff,0xff,0xca,0x01,0x50,0x85,0xe2.byte 0x02,0x60,0x46,0xe2,0x08,0x00,0x56,0xe1.byte 0x05,0x70,0x87,0xe0,0xf0,0xff,0xff,0x1a.byte 0x01,0x70,0x87,0xe2,0x01,0x00,0x5b,0xe3.byte 0x0b,0x30,0xa0,0xe1,0x07,0x90,0x89,0xe0.byte 0xe2,0xff,0xff,0xca,0x01,0x90,0x89,0xe2.byte 0x2c,0x30,0x9d,0xe5,0x02,0xa0,0x4a,0xe2.byte 0x03,0x00,0x5a,0xe1,0x14,0x30,0x9d,0xe5.byte 0x09,0x30,0x83,0xe0,0x14,0x30,0x8d,0xe5.byte 0xd6,0xff,0xff,0x1a,0x01,0x90,0x83,0xe2.byte 0x20,0x30,0x9d,0xe5,0x10,0x20,0x9d,0xe5.byte 0x01,0x00,0x53,0xe3,0x09,0x20,0x82,0xe0.byte 0x10,0x20,0x8d,0xe5,0xc3,0xff,0xff,0xca.byte 0x34,0xb0,0x9d,0xe5,0x01,0x30,0x82,0xe2.byte 0x28,0x20,0x9d,0xe5,0x02,0xb0,0x4b,0xe2.byte 0x02,0x00,0x5b,0xe1,0x0c,0x20,0x9d,0xe5.byte 0x03,0x30,0x82,0xe0,0x0c,0x30,0x8d,0xe5.byte 0xb4,0xff,0xff,0x1a,0x01,0x20,0x83,0xe2.byte 0x1c,0x30,0x9d,0xe5,0x08,0x10,0x9d,0xe5.byte 0x01,0x00,0x53,0xe3,0x02,0x20,0x81,0xe0.byte 0x08,0x20,0x8d,0xe5,0xa1,0xff,0xff,0xca.byte 0x30,0xb0,0x9d,0xe5,0x01,0x30,0x82,0xe2.byte 0x20,0x00,0x00,0xea,0x01,0x50,0xa0,0xe3.byte 0xd2,0xff,0xff,0xea,0x01,0x70,0xa0,0xe3.byte 0x00,0xb0,0xa0,0xe3,0xd4,0xff,0xff,0xea.byte 0x01,0x90,0xa0,0xe3,0xd7,0xff,0xff,0xea.byte 0x00,0x30,0xa0,0xe3,0x01,0x90,0xa0,0xe3.byte 0x20,0x30,0x8d,0xe5,0xdc,0xff,0xff,0xea.byte 0x01,0x30,0xa0,0xe3,0xe1,0xff,0xff,0xea.byte 0x00,0x30,0xa0,0xe3,0x01,0x20,0xa0,0xe3.byte 0x1c,0x30,0x8d,0xe5,0xe6,0xff,0xff,0xea.byte 0x00,0x20,0xa0,0xe3,0x01,0x30,0xa0,0xe3.byte 0x18,0x20,0x8d,0xe5,0x01,0x00,0x52,0xe3.byte 0x02,0x00,0xa0,0xe1,0x00,0x20,0x9d,0xe5.byte 0x03,0x30,0x82,0xe0,0x00,0x30,0x8d,0xe5.byte 0x72,0xff,0xff,0xca,0x01,0x00,0x83,0xe2.byte 0x3c,0xd0,0x8d,0xe2,0xf0,0x4f,0xbd,0xe8.byte 0x1e,0xff,0x2f,0xe1,0x01,0x00,0xa0,0xe3.byte 0x1e,0xff,0x2f,0xe1,0x01,0x30,0xa0,0xe3.byte 0x24,0x20,0x9d,0xe5,0x02,0xb0,0x4b,0xe2.byte 0x02,0x00,0x5b,0xe1,0x04,0x20,0x9d,0xe5.byte 0x03,0x30,0x82,0xe0,0x04,0x30,0x8d,0xe5.byte 0x70,0xff,0xff,0x1a,0x01,0x30,0x83,0xe2.byte 0x18,0x20,0x9d,0xe5,0xe8,0xff,0xff,0xea
$ ../gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/arm-none-eabi-gcc -o tmp2.out tmp.s -nostdlibd:/gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00008000
$ ../gcc-arm-none-eabi-4_9-2014q4-20141203-win32/bin/arm-none-eabi-objdump -D tmp2.out
tmp2.out: file format elf32-littlearm
Disassembly of section .text:
00008000 <main>: 8000: e3a00064 mov r0, #100 ; 0x64 8004: eaffffff b 8008 <main+0x8> 8008: e3500001 cmp r0, #1 800c: da000094 ble 8264 <main+0x264> 8010: e3a03000 mov r3, #0 8014: e92d4ff0 push {r4, r5, r6, r7, r8, r9, sl, fp, lr} 8018: e24dd03c sub sp, sp, #60 ; 0x3c 801c: e58d3000 str r3, [sp] 8020: e3500002 cmp r0, #2 8024: 0a000081 beq 8230 <main+0x230> 8028: e2403002 sub r3, r0, #2 802c: e58d3018 str r3, [sp, #24] 8030: e1a0b003 mov fp, r3 8034: e3a03000 mov r3, #0 8038: e58d3004 str r3, [sp, #4] 803c: e2403003 sub r3, r0, #3 8040: e3c33001 bic r3, r3, #1 8044: e2400004 sub r0, r0, #4 8048: e0633000 rsb r3, r3, r0 804c: e58d3024 str r3, [sp, #36] ; 0x24 8050: e35b0001 cmp fp, #1 8054: e1a0300b mov r3, fp 8058: da000083 ble 826c <main+0x26c> 805c: e3a02000 mov r2, #0 8060: e58db030 str fp, [sp, #48] ; 0x30 8064: e58d2008 str r2, [sp, #8] 8068: e3530002 cmp r3, #2 806c: 0a00006b beq 8220 <main+0x220> 8070: e2432002 sub r2, r3, #2 8074: e58d201c str r2, [sp, #28] 8078: e1a0b002 mov fp, r2 807c: e3a02000 mov r2, #0 8080: e58d200c str r2, [sp, #12] 8084: e2432003 sub r2, r3, #3 8088: e3c22001 bic r2, r2, #1 808c: e2433004 sub r3, r3, #4 8090: e0623003 rsb r3, r2, r3 8094: e58d3028 str r3, [sp, #40] ; 0x28 8098: e35b0001 cmp fp, #1 809c: e1a0300b mov r3, fp 80a0: da00005c ble 8218 <main+0x218> 80a4: e3a02000 mov r2, #0 80a8: e58db034 str fp, [sp, #52] ; 0x34 80ac: e58d2010 str r2, [sp, #16] 80b0: e3530002 cmp r3, #2 80b4: 0a000053 beq 8208 <main+0x208> 80b8: e2432002 sub r2, r3, #2 80bc: e58d2020 str r2, [sp, #32] 80c0: e1a0a002 mov sl, r2 80c4: e3a02000 mov r2, #0 80c8: e58d2014 str r2, [sp, #20] 80cc: e2432003 sub r2, r3, #3 80d0: e3c22001 bic r2, r2, #1 80d4: e2433004 sub r3, r3, #4 80d8: e0623003 rsb r3, r2, r3 80dc: e58d302c str r3, [sp, #44] ; 0x2c 80e0: e35a0001 cmp sl, #1 80e4: e1a0300a mov r3, sl 80e8: da000044 ble 8200 <main+0x200> 80ec: e3a09000 mov r9, #0 80f0: e3530002 cmp r3, #2 80f4: 0a00003e beq 81f4 <main+0x1f4> 80f8: e243b002 sub fp, r3, #2 80fc: e1a0600b mov r6, fp 8100: e3a07000 mov r7, #0 8104: e2438003 sub r8, r3, #3 8108: e3c88001 bic r8, r8, #1 810c: e2433004 sub r3, r3, #4 8110: e0688003 rsb r8, r8, r3 8114: e3560001 cmp r6, #1 8118: e1a04006 mov r4, r6 811c: da000032 ble 81ec <main+0x1ec> 8120: e3a05000 mov r5, #0 8124: e2440001 sub r0, r4, #1 8128: ebffffb6 bl 8008 <main+0x8> 812c: e2444002 sub r4, r4, #2 8130: e3540001 cmp r4, #1 8134: e0855000 add r5, r5, r0 8138: cafffff9 bgt 8124 <main+0x124> 813c: e2855001 add r5, r5, #1 8140: e2466002 sub r6, r6, #2 8144: e1560008 cmp r6, r8 8148: e0877005 add r7, r7, r5 814c: 1afffff0 bne 8114 <main+0x114> 8150: e2877001 add r7, r7, #1 8154: e35b0001 cmp fp, #1 8158: e1a0300b mov r3, fp 815c: e0899007 add r9, r9, r7 8160: caffffe2 bgt 80f0 <main+0xf0> 8164: e2899001 add r9, r9, #1 8168: e59d302c ldr r3, [sp, #44] ; 0x2c 816c: e24aa002 sub sl, sl, #2 8170: e15a0003 cmp sl, r3 8174: e59d3014 ldr r3, [sp, #20] 8178: e0833009 add r3, r3, r9 817c: e58d3014 str r3, [sp, #20] 8180: 1affffd6 bne 80e0 <main+0xe0> 8184: e2839001 add r9, r3, #1 8188: e59d3020 ldr r3, [sp, #32] 818c: e59d2010 ldr r2, [sp, #16] 8190: e3530001 cmp r3, #1 8194: e0822009 add r2, r2, r9 8198: e58d2010 str r2, [sp, #16] 819c: caffffc3 bgt 80b0 <main+0xb0> 81a0: e59db034 ldr fp, [sp, #52] ; 0x34 81a4: e2823001 add r3, r2, #1 81a8: e59d2028 ldr r2, [sp, #40] ; 0x28 81ac: e24bb002 sub fp, fp, #2 81b0: e15b0002 cmp fp, r2 81b4: e59d200c ldr r2, [sp, #12] 81b8: e0823003 add r3, r2, r3 81bc: e58d300c str r3, [sp, #12] 81c0: 1affffb4 bne 8098 <main+0x98> 81c4: e2832001 add r2, r3, #1 81c8: e59d301c ldr r3, [sp, #28] 81cc: e59d1008 ldr r1, [sp, #8] 81d0: e3530001 cmp r3, #1 81d4: e0812002 add r2, r1, r2 81d8: e58d2008 str r2, [sp, #8] 81dc: caffffa1 bgt 8068 <main+0x68> 81e0: e59db030 ldr fp, [sp, #48] ; 0x30 81e4: e2823001 add r3, r2, #1 81e8: ea000020 b 8270 <main+0x270> 81ec: e3a05001 mov r5, #1 81f0: eaffffd2 b 8140 <main+0x140> 81f4: e3a07001 mov r7, #1 81f8: e3a0b000 mov fp, #0 81fc: eaffffd4 b 8154 <main+0x154> 8200: e3a09001 mov r9, #1 8204: eaffffd7 b 8168 <main+0x168> 8208: e3a03000 mov r3, #0 820c: e3a09001 mov r9, #1 8210: e58d3020 str r3, [sp, #32] 8214: eaffffdc b 818c <main+0x18c> 8218: e3a03001 mov r3, #1 821c: eaffffe1 b 81a8 <main+0x1a8> 8220: e3a03000 mov r3, #0 8224: e3a02001 mov r2, #1 8228: e58d301c str r3, [sp, #28] 822c: eaffffe6 b 81cc <main+0x1cc> 8230: e3a02000 mov r2, #0 8234: e3a03001 mov r3, #1 8238: e58d2018 str r2, [sp, #24] 823c: e3520001 cmp r2, #1 8240: e1a00002 mov r0, r2 8244: e59d2000 ldr r2, [sp] 8248: e0823003 add r3, r2, r3 824c: e58d3000 str r3, [sp] 8250: caffff72 bgt 8020 <main+0x20> 8254: e2830001 add r0, r3, #1 8258: e28dd03c add sp, sp, #60 ; 0x3c 825c: e8bd4ff0 pop {r4, r5, r6, r7, r8, r9, sl, fp, lr} 8260: e12fff1e bx lr 8264: e3a00001 mov r0, #1 8268: e12fff1e bx lr 826c: e3a03001 mov r3, #1 8270: e59d2024 ldr r2, [sp, #36] ; 0x24 8274: e24bb002 sub fp, fp, #2 8278: e15b0002 cmp fp, r2 827c: e59d2004 ldr r2, [sp, #4] 8280: e0823003 add r3, r2, r3 8284: e58d3004 str r3, [sp, #4] 8288: 1affff70 bne 8050 <main+0x50> 828c: e2833001 add r3, r3, #1 8290: e59d2018 ldr r2, [sp, #24] 8294: eaffffe8 b 823c <main+0x23c>
Disassembly of section .ARM.attributes:
00000000 <.ARM.attributes>: 0: 00001341 andeq r1, r0, r1, asr #6 4: 61656100 cmnvs r5, r0, lsl #2 8: 01006962 tsteq r0, r2, ror #18 c: 00000009 andeq r0, r0, r9 10: 01090108 tsteq r9, r8, lsl #2
Cannot it help you?
Best regards,
Yasuhiko Koumoto.
Thanks for your instructions. I'll try this and let you know the result.
i, I reccommend GCC ARM Embedded in Launchpad as the dis-assembler (i.e. objdump) because some the other dis-assembler could not dis-assemble successfully the elf code generated by my procedure. It seems to be good.
I approve this solution
Can you explain this process in a simple way pls.
Hello,
the basic idea are the folowings.1) to generate a source code from the hex file. If you can use an ICE, it would be very easy.2) to modify the source code as you like.3) to compile the modified source code.4) to convert the compiled binary to a hex file.That's all.
Best regards,Yasuhiko Koumoto.