Presentation is loading. Please wait.

Presentation is loading. Please wait.

Disassembling Instructions. MSP430 Disassembly2 How to Disassemble MSP430 Code 1.Begin with a “PC” pointing to the first word in program memory. 2.Retrieve.

Similar presentations


Presentation on theme: "Disassembling Instructions. MSP430 Disassembly2 How to Disassemble MSP430 Code 1.Begin with a “PC” pointing to the first word in program memory. 2.Retrieve."— Presentation transcript:

1 Disassembling Instructions

2 MSP430 Disassembly2 How to Disassemble MSP430 Code 1.Begin with a “PC” pointing to the first word in program memory. 2.Retrieve instruction word and increment PC by 2. 3.Find and list the corresponding instruction mnemonic using the opcode (most significant 4-9 bits). 4.When appropriate, append “.b” or “.w” using the b/w bit (0=word, 1=byte). 5.If double operand instruction (Table 5), decode and list source operand. 6.If single or double operand instruction (Tables 3 and 5), decode and list destination operand. 7.If jump instruction, sign extend the 10-bit PC offset, multiply by 2, and add to the current PC. List that address. Instruction Disassembly BYU CS 124

3 R0 MSP430 Disassembly3 How to Disassemble MSP430 Code 1. Begin with a “PC” pointing to the first word in program memory. 2. Retrieve instruction word and increment PC by 2. Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R0

4 R0 MSP430 Disassembly4 How to Disassemble MSP430 Code 3. List the instruction mnemonic using the opcode (bits 12-15). 4. Append “.b” or “.w” using the b/w bit when appropriate (0=w, 1=b). Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: 4130 BYU CS 124.w mov

5 R0 MSP430 Disassembly5 How to Disassemble MSP430 Code 5. If double operand instruction, decode and list source operand. (If necessary, fetch operand from memory and increment PC by 2.) Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124.wmov0x0400 #

6 R0 MSP430 Disassembly6 How to Disassemble MSP430 Code 6. If single or double operand instruction, decode and list destination operand. Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124.wmov0x0400 #,r1

7 R0 MSP430 Disassembly7 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R0 …Retrieve instruction word, increment PC by 2, list mnemonic, and operand size. 0x0400mov.w#,r mov.w

8 R0 MSP430 Disassembly8 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R …Retrieve immediate source operand and increment PC by 2. mov.w 0x5a80 0x0400mov.w#,r1 #

9 R0 MSP430 Disassembly9 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R …Retrieve absolute destination operand and increment PC by 2. mov.w 0x120 0x5a80 # 0x0400 mov.w#,r1,&

10 R0 MSP430 Disassembly10 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R …Retrieve instruction word, increment PC by 2, list mnemonic, and operand size. mov.w0x5a80 #,&0x120 0x0400 mov.w#,r mov.b

11 R0 MSP430 Disassembly11 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Use constant generator R2 for source operand. #8 mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 mov.b

12 mov.b R0 MSP430 Disassembly12 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Use register mode for destination operand. mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 #8,r15

13 R0 MSP430 Disassembly13 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R …Retrieve instruction word, increment PC by 2, list mnemonic, (but no operand size is used.) call mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 mov.b #8,r15.w

14 MSP430 Disassembly14 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Retrieve immediate destination operand from memory and increment PC by 2. call 0xc012 R0 mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 mov.b #8,r15 #.w

15 mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 R0 MSP430 Disassembly15 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R …Retrieve instruction word, increment PC by 2, and list mnemonic. call # 0xc012 mov.b #8,r jmp

16 R0 MSP430 Disassembly16 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Calculate destination address by sign extending the least significant 10 bits, multiplying by 2, and adding the current PC. jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r (-4  2) + 0xc012 = 0xc00a.w

17 MSP430 Disassembly17 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Retrieve instruction word, increment PC by 2, list mnemonic, and operand size jmp0xc00a R0 mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r sub.w

18 R0 MSP430 Disassembly18 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Use constant generator R3 for immediate source operand jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r sub.w #1.w

19 MSP430 Disassembly19 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Use register mode for destination operand jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r sub.w,r15 #1 R0.w

20 R0 MSP430 Disassembly20 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS 124 R …Retrieve instruction word, increment PC by 2, and list mnemonic. jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r sub #1,r15.w jne

21 R0 MSP430 Disassembly21 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Calculate destination address by sign extending the least significant 10 bits, multiplying by 2, and adding the current PC. jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r sub #1,r15.w jne 0xc012 (-2  2) + 0xc016 = 0xc012.w

22 MSP430 Disassembly22 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Retrieve instruction word, increment PC by 2, and list mnemonic jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r15 jne sub #1,r15.w 0xc012 mov.w R0.w

23 R0 MSP430 Disassembly23 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Use indirect register auto-increment mode for source operand jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r15 jne sub #1,r15.w 0xc012

24 R0 MSP430 Disassembly24 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Use register mode for destination operand. (Pop the stack into the PC – ret instruction.) jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r15 jne sub #1,r15.w 0xc012 (ret).w

25 R0 MSP430 Disassembly25 How to Disassemble MSP430 Code Instruction Disassembly 0xc000: xc002: xc004: 40b2 0xc006: 5a80 0xc008: xc00a: 427f 0xc00c: 12b0 0xc00e: c012 0xc010: 3ffc 0xc012: 831f 0xc014: 23fe 0xc016: BYU CS …Continue the disassembly process jmp0xc00a mov.w0x5a80 #,&0x120 0x0400 mov.w#,r1 call # 0xc012 mov.b #8,r15 jne sub #1,r15.w 0xc012 (ret).w


Download ppt "Disassembling Instructions. MSP430 Disassembly2 How to Disassemble MSP430 Code 1.Begin with a “PC” pointing to the first word in program memory. 2.Retrieve."

Similar presentations


Ads by Google