2021-02-24

How do I transfer a number from a register to a label?

So I have 2 files and one of them calls functions while the other holds the string functions. I'm trying to do a similar version to strcpy and it isn't quite working.

copies a string into another memory location

It isn't specified where I have to put it, but I was thinking of an empty label. I have been looking online and trying different things, but I can't seem to find a way to store something inside a label. I get errors or nothing happens.

Function is file 1:

/*
    strcpy()
    Assumes string is in stack
    Copies string into copy and then puts it back into stack
*/
strcpy:
    POP     {R3}            @ Puts string in R3
    LDR     R3, =copy       @ Copy str into label
    PUSH    {R3}
    BX      LR

File 2


.global _start

_start:
    @ Load string then string len into stack
    LDR     r1, =str
    PUSH    {r1}
    BL      strcpy
    @ Print string
    MOV     R0, #1
    POP     {R1}
    MOV     R2, #7
    MOV     R7, #4
    SWI     0
    
    
_exit:
    MOV     R7, #1
    SWI     0
    
.data
copy:    .space     21


from Recent Questions - Stack Overflow https://ift.tt/3kjmsCR
https://ift.tt/eA8V8J

No comments:

Post a Comment