GNU/Linux xterm-256color bash 145 views

**
Nombre: kefa.s
Autor: Karla Itzel Vázquez Cruz
Fecha: 09-04-2025
Descripción: Conversión de Kelvin a Fahrenheit
Plataforma: Raspberry Pi OS 64-bit
Asciinema: kefa.s


Versión en C:

Versión en ARM64 RaspbianOS Linux:

.section .data
msg_input:     .asciz "Ingresa la temperatura en Kelvin: "
msg_result:    .asciz "\nTemperatura en Fahrenheit: "
buffer:        .skip 10
newline:       .asciz "\n"

.section .text
.global _start

_start:
    // Mostrar mensaje de entrada
    mov     x0, 1
    ldr     x1, =msg_input
    mov     x2, 32
    mov     x8, 64
    svc     0

    // Leer entrada del usuario
    mov     x0, 0
    ldr     x1, =buffer
    mov     x2, 10
    mov     x8, 63
    svc     0

    // Convertir ASCII a entero (x2)
    ldr     x1, =buffer
    mov     x2, 0
    mov     x4, #10
ascii_to_int:
    ldrb    w3, [x1], 1
    cmp     w3, #'0'
    blt     done_ascii
    cmp     w3, #'9'
    bgt     done_ascii
    sub     x3, x3, '0'
    mul     x2, x2, x4
    add     x2, x2, x3
    b       ascii_to_int
done_ascii:

    // Fahrenheit = ((Kelvin - 273) * 9 / 5) + 32
    sub     x3, x2, 273
    mov     x4, #9
    mul     x3, x3, x4
    mov     x4, #5
    udiv    x3, x3, x4
    add     x3, x3, 32

    // Limpiar buffer de salida
    mov     x10, 0
    ldr     x11, =buffer
    mov     x12, #10
clear_loop:
    strb    w10, [x11], 1
    subs    x12, x12, 1
    b.ne    clear_loop

    // Convertir resultado (x3) a ASCII
    mov     x5, x3
    ldr     x6, =buffer+9
    mov     x7, 10
int_to_ascii:
    mov     x8, x5
    udiv    x5, x5, x7
    msub    x9, x5, x7, x8
    add     x9, x9, '0'
    strb    w9, [x6, -1]!
    cmp     x5, 0
    bne     int_to_ascii

    // Mostrar mensaje resultado
    mov     x0, 1
    ldr     x1, =msg_result
    mov     x2, 31
    mov     x8, 64
    svc     0

    // Mostrar número convertido
    mov     x0, 1
    mov     x1, x6
    ldr     x2, =buffer+9
    sub     x2, x2, x6
    mov     x8, 64
    svc     0

    // Salto de línea y salida limpia
    mov     x0, 1
    ldr     x1, =newline
    mov     x2, 1
    mov     x8, 64
    svc     0

    mov     x0, 0
    mov     x8, 93
    svc     0

More recordings by Itzel

Browse all

CONTADOR DE A'S 1:07

by Itzel

DECIMAL A HEXADECIMAL 1:38

by Itzel

KELVIN A CELSIOUS 1:54

by Itzel

CELSIUS A KELVIN 1:46

by Itzel