LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 920|回复: 1

汇编的问题[BIOS中断显示]

[复制链接]
发表于 2005-8-15 13:21:59 | 显示全部楼层 |阅读模式
很简单的hello world,使用BIOS中断,用AT&T格式写的
es:bp=字符串地址
al=写方式
cx=字符串长度
dh/dl=起始行/列
bh/bl=页号/属性

编译通过,连接出错:
hello.o(.text+0xa): In function `_start':
: relocation truncated to fit: R_386_16 .data
hello.o(.text+0xe): In function `_start':
: relocation truncated to fit: R_386_16 .data
make: *** [all] Error 1

代码如下
.data
msg:    .string "Hello World\n"
len:    .int   12
.text
.global _start
_start:
        movw    $0x1301, %ax
        movw    $0x0007, %bx
        movw    $len, %cx
        movw    $msg,%bp
        int     $0x13
                                                                                                               
        movl    $0,%ebx #退出
        movl    $1,%eax
        int     $0x80
发表于 2005-8-15 16:13:02 | 显示全部楼层
1. movw $len,%cx 和 movw $msg,%bp 改为 movl $len,%ecx, movl $msg,%ebp,可以连接通过
2. bios 中断服务在保护模式下不可用,切记切记
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表