hi guyz, currently i am using cortex m4, and i have to make a string reverse function that print the strings back ward.
this is what i have done so far....*

#include "derivative.h"
#include <stdint.h>  
#include "clock.h"
#include <stdio.h>
#include"freedom.h"
#include "uart.h"

void stringreverse(char array[3]);

int main(void) {

    clock_initialise();

    char string[] = {'H', 'E','\0'};    


    printf("Greeting message: %s\n", string );

    stringreverse(string);

    printf("%s\n", string);



return 0; 

i dont know if this the right c program to test the function, but i seriously dont know how implement the function in assembly language.
i would be appreciated if u guyz helped me.
thanks.

I don't know ARM assembly from prior experience, but I would start by looking up the Cortex M4 documentation, if you haven't already done so, and get familiarized with the relevant instructions, especially those involving memory access. Assuming you are using characters in the ASCII range, you'll specifically want the LDRB and STRB instructions, or some variants thereof. Also, if you know that it will be exactly two 8-bit unsigned char values (since you don't want to touch the zero-delimiter at the end of the string), the REV16 instruction should do the actual swap with a single operation.

thnx alot for your help, i will try that

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.