GNU/Linux xterm-256color zsh 130 views

.section .data
buffer:  .skip 32

.section .rodata
float_2_5: .float 2.5        // constante en punto flotante

.section .text
.global _start

_start:
    // Convertir 32 a float
    mov w0, #32
    scvtf s0, w0             // s0 = 32.0

    // Cargar 2.5 correctamente en s1 desde .rodata
    adrp x1, float_2_5
    add x1, x1, :lo12:float_2_5
    ldr s1, [x1]             // s1 = 2.5

    // Multiplicación: s0 = s0 * s1
    fmul s0, s0, s1

    // Convertir resultado a entero (truncado)
    fcvtzu w0, s0            // sin signo: 80

    // Convertir entero a string
    ldr x1, =buffer
    bl itoa

    // Imprimir string
    mov x0, #1               // STDOUT
    ldr x1, =buffer
    bl strlen
    mov x2, x0
    mov x0, #1
    mov x8, #64              // syscall write
    svc 0

    // Salir
    mov x8, #93
    mov x0, #0
    svc 0

// -------- strlen ----------
strlen:
    mov x2, x1
.loop:
    ldrb w3, [x2], #1
    cmp w3, #0
    b.ne .loop
    sub x0, x2, x1
    ret

// -------- itoa ----------
itoa:
    mov x2, x0
    mov x3, x1
    add x4, x1, #10
    mov x5, #10
    strb w5, [x4]         // \n
    mov x5, #0
    strb w5, [x4, #1]     // \0
    mov x6, x4

.itoa_loop:
    mov x5, #10
    udiv x0, x2, x5
    msub x5, x0, x5, x2
    add x5, x5, #'0'
    sub x6, x6, #1
    strb w5, [x6]
    mov x2, x0
    cbnz x2, .itoa_loop

.copy_loop:
    ldrb w5, [x6], #1
    strb w5, [x1], #1
    cmp w5, #0
    b.ne .copy_loop
    ret