Hello Where can I find some example programs only in asm to be compiled inder Keil MDK? I can't compile simple programs as:
STACK_TOP EQU 0x20002000 ; constant for SP starting value AREA |Header Code|, CODE DCD STACK_TOP ; Stack top DCD Start ; Reset vector ENTRY ; Indicate program execution start here Start ; Start of main program ; initialize registers MOV r0, #10 ; Starting loop counter value MOV r1, #0 ; starting result ; Calculated 10+9+8+...+1 loop ADD r1, r0 ; R1R1 + R0 SUBS r0, #1 ; Decrement R0, update fl ag (“S†sufï¬ x) BNE loop ; If result not zero jump to loop ; Result is now in R1 deadloop B deadloop ; Inï¬ nite loop END ; End of ï¬ le
Keil gives an error: Error: L6320W: Ignoring --entry command. Cannot find argument 'Reset_Handler'.
How to change this program? How to change linker control string?
I tried also to add startup code fo nxp1766 but then i still have an error that label __main is missing.
Could You help me and give me some simple programs just to compile it properly?
Why not study, experiment and learn to understand what's happening with the startup code. Leave the 'main' in C to begin with and remove it when you understand how to.
I compiled above program from command line and it is working. In Keil i can't compile it. It still needs Reset_Handler label even if I changed Start to Reset_Handler.
1 - Find an example program from Keil for your processor. 2 - Change the 'main' function to a do nothing. 3 - Compile the project. 4 - Now examine, understand and learn from the startup.
Simple.
There is no pure assembler project in Keil MDK.
Another problem. I don't know why the board executes only specified number of instructions. Here is the example:
STACK_TOP EQU 0x10000200 ; constant for SP starting value AREA |Header Code|, CODE DCD STACK_TOP ; Stack top DCD Start ; Reset vector ENTRY ; Indicate program execution start here Start ; Start of main program MOV R1, #10 MOVW R3, #0xC040 ;P2.2, P2.3, P2.4, P2.5, and P2.6 function mode is located at FP2DIR (0×2009_C040). MOVT R3, #0x2009 MOVW R2, #0x007C ;P2.2 -> Bit[2] * P2.3 -> Bit[3]* P2.4 -> Bit[4]* P2.5 -> Bit[5]* P2.6 -> Bit[6] -> Output dir : 1 STR R2, [R3] loop B loop END
This program executes correctly. It defines the GPIO ports as output. On board leds are off (after reset state normally all leds are on). Then I modified the program by adding the same line
STACK_TOP EQU 0x10000200 ; constant for SP starting value AREA |Header Code|, CODE DCD STACK_TOP ; Stack top DCD Start ; Reset vector ENTRY ; Indicate program execution start here Start ; Start of main program MOV R1, #10 MOV R1, #10 MOVW R3, #0xC040 ;P2.2, P2.3, P2.4, P2.5, and P2.6 function mode is located at FP2DIR (0×2009_C040). MOVT R3, #0x2009 MOVW R2, #0x007C ;P2.2 -> Bit[2] * P2.3 -> Bit[3]* P2.4 -> Bit[4]* P2.5 -> Bit[5]* P2.6 -> Bit[6] -> Output dir : 1 STR R2, [R3] loop B loop END
So normally the program does the same but now leds are still on so the instruction STR R2, [R3] is not executing. Where is the problem? I'm using keil compilers as follows:
"C:\Program Files\keil\ARM\BIN40\armasm" --device darmp1 -o .\blinky.o .\blinky.s "C:\Program Files\keil\ARM\BIN40\armlink" --device darmp1 --rw_base 0x10000000 --ro_base 0x0 --map -o .\blinky.elf .\blinky.o "C:\Program Files\keil\ARM\BIN40\fromelf" --bin --output .\blinky.bin .\blinky.elf "C:\Program Files\keil\ARM\BIN40\fromelf" --i32 --output .\blinky.hex .\blinky.elf
"There is no pure assembler project in Keil MDK."
Who suggested there was?
The startup code is in assembler - So there would be the starting point.
View all questions in Keil forum