DEV Community

海前 王
海前 王

Posted on

arm assembled

.text
.global _start

_start:
    ldr r1, =src      // Load address of source string
    ldr r0, =dst      // Load address of destination buffer
    ldr r3, =len      // Load length of string

move:
    cmp r3, #0        // Compare length to 0
    beq end           // If length is 0, branch to end
    ldrb r2, [r1]     // Load byte from source
    strb r2, [r0]     // Store byte to destination
    adds r1, r1, #1   // Increment source address
    adds r0, r0, #1   // Increment destination address
    subs r3, r3, #1   // Decrement length
    b move            // Branch to move

end:
    // Exit system call
    mov r0, #0        // Return code 0
    mov r7, #1        // System call number for exit (1 in ARM)
    swi 0             // Software interrupt to make system call

.data
src:
    .asciz "hello world"  // Source string
len = .-src               // Calculate length of the source string
dst:
    .space 20             // Reserve space for the destination string

Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay