jean281426459940 0 Posted September 18, 2013 Share Posted September 18, 2013 Hey guys! I have a bit of experience with the MSP430 and have written small bits of code of it using assembly. I want to do something simple to start off (moving a value to a register). How would I write the following code (written for MSP430) in ARM architecture (specifically with the Tiva C)? #include <msp430.h> ORG 0F800h ; Program Start RESET mov #0280h, SP ; Initialize stackpointer mov #5000,R15 ; Store 5000 in R15 ORG 0FFFEh DW RESET END Thank you all! Quote Link to post Share on other sites
Lyon 3 Posted September 18, 2013 Share Posted September 18, 2013 HI, Well, while it is possible to do such small program as you do for MSP430, you must take into account the major differences between MSP430 and Cortex-M4: the latest imposes some discipline in program writing. This is due to hardware realization of the inside circuitry of Cortex. First flash location is at address 0 and in this location must reside the address of stack pointer, even if it is not used. The second location is the address of startup routine; this must be also present; at startup the processor uses these two locations and then goes further, so you must provide them. This address and the rest of interrupt vectors must have the last bit set to 1, making it odd number, despite even alignment - this last bit is internal signal for thumb interrupt - as requested by ARM. Note this is compiler's job, but directed by you. Next, after these two locations, there must be the rest of interrupt vectors locations, properly initialized. You need these also - otherwise you will be soon in trouble, at the first mistake. You must know also this processor is provided with a unusual big and complex debug and diagnostic machine - so fault interrupts must be really initialized and a code body provided for them. So this is why in general, you must use two files for every small program (and Valvano is best to follow and learn from): - one is a startup.S, which is written only once; - the other one is main.S which is your program. I understand your pain - this is not so simple - and using IAR is an add-on, since no example - of coarse you must read/learn IAR documentation - however an example written in IAR assembler can be found in TIVA/boot_loader/bl_startup_ewarm.S - you can copy/paste from that file a lot... Hope this will help you, chicken, spirilis, bluehash and 1 other 4 Quote Link to post Share on other sites
Bingo600 0 Posted September 21, 2013 Share Posted September 21, 2013 Have a look here He's got some small examples http://users.ece.utexas.edu/~valvano/arm/ /Bingo Vin255 and bluehash 2 Quote Link to post Share on other sites
Vin255 0 Posted March 26, 2014 Share Posted March 26, 2014 @ Bingo: many many thanks for the link. very helpful. regards Vin255 Quote Link to post Share on other sites
justinmreina 2 Posted October 25, 2016 Share Posted October 25, 2016 Here is my example, which took nearly a full dedicated hour to complete, sheesh! Tiva assembly is precise and complete, but has subtle yet important differences from MSP430 assembly, take a peek! Full project attached in ZIP as well Assembly Routines (asmExampleFile.asm) .global asmRAMVal, asmFlashVal, asmFcn1, asmFcn2 .bss asmRAMVal, 4h .data asmFlashVal .word 6h .text asmFcn1: nop movw r0, #1266 bx lr asmFcn2: nop movw r0, #1267 bx lr C Usage of Assembly Routines (main.c) //ASM Routines extern void asmFcn1(void); extern void asmFcn2(void); //ASM Varaiables extern uint16_t asmRAMVal; extern uint16_t asmFlashVal; int main(void) { asmFcn1(); // Asm function-file calls asmFcn2(); ram_var = asmFlashVal; //Asm variable usage asmRAMVal = 0xE234; return EXIT_SUCCESS; } ref_asm.zip bluehash and agaelema 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.