【发布时间】:2014-11-13 03:28:35
【问题描述】:
我正在尝试将值输入到 x86-64 Intel 程序集中的数组中,但我不太明白。
我正在段 .bss 中创建一个数组。然后我尝试使用 r15 将数组的地址传递给另一个模块。在该模块中,我提示用户输入一个数字,然后将其插入到数组中。但它不起作用。
我正在尝试执行以下操作
segment .bss
dataArray resq 15 ; Array that will be manipulated
segment .text
mov rdi, dataArray ; Store memory address of array so the next module can use it.
call inputqarray ; Calling inputqarray module
在 inputqarary 里面我有:
mov r15, rdi ; Move the memory address of the array into r15 for safe keeping
push qword 0 ; Make space on the stack for the value we are reading
mov rsi, rsp ; Set the second argument to point to the new locaiton on the stack
mov rax, 0 ; No SSE input
mov rdi, oneFloat ; "%f", 0
call scanf ; Call C Standard Library scanf function
call getchar ; Clean the input stream
pop qword [r15]
然后我尝试通过做输出使用输入的值
push qword 0
mov rax, 1
mov rdi, oneFloat
movsd xmm0, [dataArray]
call printf
pop rax
不幸的是,我得到的输出只有 0.00000
【问题讨论】:
标签: arrays assembly x86-64 intel