Я начал с этого кода. Он имеет значение с плавающей запятой, жестко закодированное и печатается, как ожидалось:
Код: Выделить всё
// print_a_float.s
.global main
.extern printf
.section .data
output_str:
.asciz "Value is %f.\n"
value:
.double 1.2345
.section .text
main:
// Prolog
stp x29, x30, [sp, -16]!
mov x29, sp
print:
ldr x0, =output_str // Address of output_str into x0
ldr x1, =value // Address of value into x1
ldr d0, [x1] // Value in address of x1 into d0
bl printf
// Cleanup
mov x0, #0 // Exit code
ldp x29, x30, [sp], 16 // Restore SP and PC
ret

When Я получаю значение с плавающей запятой от пользователя через сканирование, код не работает.
Код: Выделить всё
// print_a_float_2.s
.global main
.extern scanf
.extern printf
.section .data
input_str:
.asciz "Input a float: "
input_fmt:
.asciz "%f"
value:
.double 0
output_str:
.asciz "You entered %f.\n"
.section .text
main:
// Prolog
stp x29, x30, [sp, -16]!
mov x29, sp
// Get value from user
ldr x0, =input_str
bl printf
ldr x0, =input_fmt
ldr x1, =value
bl scanf
print:
// Now print value
ldr x0, =output_str
ldr x1, =value
ldr d0, [x1]
bl printf
// Cleanup
mov x0, #0
ldp x29, x30, [sp], 16
ret

Здесь значение действительно содержит 1.2345 введен пользователем, а d0 - нет.
Посоветуйте, пожалуйста?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -via-scanf
Мобильная версия