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 "uart.h"

void stringreverse(char array[3]);

int main(void) {


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

    printf("Greeting message: %s\n", 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.

3 Years
Discussion Span
Last Post by Aws_1

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.

Edited by Schol-R-LEA

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.