Content originally posted in LPCWare by Risto on Sun Oct 03 11:22:42 MST 2010
[SIZE=4]Hello there,[/SIZE]
[SIZE=4]I'm having some trouble with LPCxpresso and debugging a few lines of assembler code. (I want to use assembly for some educational puposes to get familar with Cortex M3 Instruction Set)[/SIZE]
[SIZE=4]What I've done:[/SIZE]
[SIZE=4]- Started LPCxpreso IDE and created a new Project "assembly_trouble" for LPC1343[/SIZE]
[SIZE=4]- under folder /src deleted cr_startup_lpc13.c and main.c[/SIZE]
[SIZE=4]- created a new file assembly.asm und /src folder[/SIZE]
[SIZE=4]- filled assembly.asm with the following (experimental) assembler code:[/SIZE]
[SIZE=2].equ STACK_TOP, 0x10002000[/SIZE]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055].text[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[SIZE=2].syntax unified[/SIZE]
[SIZE=2].thumb[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055].global[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] _start[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055].type[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] start, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]%function[/COLOR][/SIZE][/COLOR][/SIZE][/B][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]_start:[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055].word[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] STACK_TOP, start[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]start:[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[SIZE=2]movs r0, #20[/SIZE]
[SIZE=2]movs r1, #40[/SIZE]
[SIZE=2]PUSH {r0}[/SIZE]
[SIZE=2]PUSH {r1}[/SIZE]
[SIZE=2]adds r0, r1[/SIZE]
[SIZE=2]movs r1, r0[/SIZE]
[SIZE=2]POP {r1}[/SIZE]
[SIZE=2]POP {r0}[/SIZE]
[SIZE=2]movs r0, #10[/SIZE]
[SIZE=2]movs r1, #0[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]loop:[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[SIZE=2]adds r1, r0[/SIZE]
[SIZE=2]subs r0, #1[/SIZE]
[SIZE=2]bne loop[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]deadloop:[/COLOR][/SIZE][/COLOR][/SIZE][/B]
[SIZE=2]b deadloop[/SIZE]
[SIZE=2].end[/SIZE][/LEFT]
[SIZE=4]- Under "Properties for assembler_trouble" -> C/C++ Build -> Settings -> MCU Linker -> Target I've unchecked "Manage Linker script".[/SIZE]
[SIZE=4]- Build 'assembly_trouble' [Debug][/SIZE]
[SIZE=4]Console Messages:[/SIZE]
[LEFT][SIZE=2]**** Build of configuration Debug for project assembly_trouble ****[/SIZE][/LEFT]
[LEFT][SIZE=2]make all [/SIZE]
[SIZE=2]Building file: ../src/assembly.asm[/SIZE]
[SIZE=2]Invoking: MCU Assembler[/SIZE]
[SIZE=2]arm-none-eabi-gcc -c -x assembler-with-cpp -D__REDLIB__ -DDEBUG -D__CODE_RED -g3 -mcpu=cortex-m3 -mthumb -o"src/assembly.o" "../src/assembly.asm"[/SIZE]
[SIZE=2]Finished building: ../src/assembly.asm[/SIZE][/LEFT]
[LEFT][SIZE=2]Building target: assembly_trouble.axf[/SIZE]
[SIZE=2]Invoking: MCU Linker[/SIZE]
[SIZE=2]arm-none-eabi-gcc -nostdlib -Xlinker -Map=assembly_trouble.map -Xlinker --gc-sections -mcpu=cortex-m3 -mthumb -o"assembly_trouble.axf" ./src/assembly.o [/SIZE]
[SIZE=2]Finished building target: assembly_trouble.axf[/SIZE][/LEFT]
[LEFT][SIZE=2]make --no-print-directory post-build[/SIZE]
[SIZE=2]Performing post-build steps[/SIZE]
[SIZE=2]arm-none-eabi-size assembly_trouble.axf; # arm-none-eabi-objcopy -O binary assembly_trouble.axf assembly_trouble.bin ; checksum -p LPC1343 -d assembly_trouble.bin;[/SIZE]
[SIZE=2]text data bss dec hex filename[/SIZE][/LEFT]
[SIZE=2]36 0 0 36 24 assembly_trouble.axf[/SIZE]
[SIZE=4]- Added Breakpoint to movs r0, #20 right after the start lable[/SIZE]
[SIZE=4]- Unchecked "Stop on startup at:" in Debug Configurations[/SIZE]
[SIZE=4]- Debug 'assembly_trouble' [Debug][/SIZE]
[SIZE=4]Now the Trouble begins when starting to debug. Have a look at Disassembly while debugging:[/SIZE]
[LEFT][SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]movs r0, #20[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x00008008 <start>: movs r0, #10[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]movs r1, #40[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x0000800a <start+2>: movs r1, #0[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]PUSH {r0}[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x0000800c <start+4>: adds r1, r1, r0[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]PUSH {r1}[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x0000800e <start+6>: subs r0, #1[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]adds r0, r1[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x00008010 <start+8>: bne.n 0x800c <start+4>[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]movs r1, r0[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x00008012 <start+10>: b.n 0x8012 <start+10>[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]POP {r1}[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x00008014 <start+12>: ; <UNDEFINED> instruction: 0xffffffff[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]PUSH {r0}[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x00008016 <start+14>: ; <UNDEFINED> instruction: 0xffffffff[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]movs r0, #10[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x00008018 <start+16>: ; <UNDEFINED> instruction: 0xffffffff[/SIZE]
[SIZE=2][COLOR=#000080][SIZE=2][COLOR=#000080]movs r1, #0[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2]0x0000801a <start+18>: ; <UNDEFINED> instruction: 0xffffffff[/SIZE][/LEFT]
[LEFT][SIZE=4]Code actually executed is not correct. Whats wrong in here ? [/SIZE]
[SIZE=4]I've attached my LPC Xpresso Project as ZIP File[/SIZE][/LEFT]
[LEFT][SIZE=2][SIZE=4]Risto[/SIZE][/SIZE][/LEFT]