+ -
当前位置:首页 → 问答吧 → NASM汇编问题

NASM汇编问题

时间:2011-03-23

来源:互联网

使用文件现列出:
/************2.asm***********/
global shiyan
[bits 32]
[SECTION .data]
shiyan db "helloworld!
/************kernel.asm*********/
extern shiyan
[bits 32]
global _start
_start: mov ax,shiyan
mov bp,ax
mov cx,11
mov ax,01301h
mov bx,0ch
mov dl,0
int 10h
jmp $
/*****************************
我打算在kernel.asm中使用2.asm中的变量 shiyan
但在执行连接命令时出现了问题,是用命令如下
nasm -f elf -o 2.o 2.asm
nasm -f elf -o kernel.o kernel.asm
ld -o kernel.bin kernel.o 2.o
最后一条指令出现错误,提示为
kernel.o: In function `_start':
kernel.asm:(.text+0x2): relocation truncated to fit: R_386_16 against symbol `shiyan' defined in .data section in 2.o
为什么呢?感觉应该可以的哈

作者: chenxiancool   发布时间: 2011-03-23

shiyan db "helloworld! => shiyan db "helloworld!"

作者: DelphiGuy   发布时间: 2011-03-23