我试图使用c中的printf在nasm中访问和打印在下面的数据部分中找到的arr元素,但是每次我得到(.text + 0x4e):对`printf的未定义引用。 谁能告诉我这个问题?
xor rcx, rcx
print_array:
cmp rcx, r8
jz exit
mov rax, [arr+rcx]
inc r8
push rax ; caller-save register
push rsi ; caller-save register
mov rdi, char_format ; set 1st parameter (format)
mov rsi, r8 ; set 2nd parameter (current_number)
xor rax, rax ; because printf is varargs
call printf ; printf(format, current_number)
pop rsi ; restore caller-save register
pop rax ; restore caller-save register
jmp print_array
exit:
mov rax, 0
pop rbp
section .data
arr: dd 30, 10, 6, 4, 8, 15, 1, 60, 7, 19, 17, 13, 11
ent: dd "enter the number of items", 10
char_format: db "%c", 10, 0
decimal_format: db "%d", 10, 0
string_format: db "%s", 10, 0