Arm/chrcpy

From ASMBits

arm/swapPrevious

Write a function that will copy one character from a string to a second string. Your function will be passed four parameters: The first two parameters specify the source string and character position. The third and fourth parameters specify the destination string and character position. Copy the character. (Don't consider null-termination, overflows, etc.)

int chrcpy (char *src, int src_pos, char *dst, int dst_pos);

Expected solution length: Around 5 lines.

Sample Input

chrcpy("hello", 1, "bye", 1)

Sample Output

"bye" -> "bee"

Write your solution here

x
 
1
.data
2
Src: .string "hello"
3
.align 2   // Insert padding so it's easier to read.
4
Dst: .string "bye"
5
6
.text
7
.global _start
8
_start:
9
    ldr r0, =Src
10
    ldr r1, =1
11
    ldr r2, =Dst
12
    ldr r3, =1
13
    bl chrcpy
14
    1: b 1b    // Done
15
16
// Copy a character from one string to another
17
chrcpy:
18
    
19
    
Upload a source file...