程序集:重定位被截断以使r_x86_64_16符合'.data'

时间:2017-10-25 17:59:54

标签: assembly nasm

我的汇编代码有问题。此代码用于从文件中打印文本。

%define B_LENGTH 80
%define STDOUT 0x0001
SECTION .text
global _start
_start:
mov bp,STDOUT
mov ax, 0x3D00
mov dx,file_name
int 0x21
jc error
mov bx,ax
read_next:
mov ah,0x3F
mov dx,buffer
mov cx, B_LENGTH
int 0x21
jc error
xor ax,ax
jz end_reading
mov cx, ax
mov ah,0x40
xchg bp,bx
int 0x21
xchg bp,bx
jmp read_next
end_reading:
mov ah, 0x3E
int 0x21
mov al,0
endprog:
mov ah,4Ch
int 0x21
error:
mov al,1
jmp short endprog
SECTION .data
file_name db 'text.txt'
buffer times B_LENGTH db 0

对于编译我使用

nasm -felf64 task.asm -o task.o
ld -o task task.o

我在编译后看到了什么

task.o: In function '_start':
task.asm: (.text+0xa): relocation truncated to fit: R_X86_64_16 against '.data'
task.o: In function 'read_next':
task.asm: (.text+0x17): relocation truncated to fit: R_X86_64_16 against '.data'

你能帮我理解这个错误的原因吗?

0 个答案:

没有答案