请问一个跳转的问题
我用汇编写了2个文件,分别为loader.s与boot.s内容分别如下:
loader.s
.section .data
valuestr:
.asciz "aa"
.section .text
.global _start
.code16
_start:
movw %cs, %ax
movw %ax, %es
movw %ax, %ds
movw $loadstr, %bp
movw len2, %cx
movb $0x05, %dh
movb $0x08, %dl
movb $0x01, %al
movb $0x13, %ah
movb $0x01, %bl
movb $0x00, %bh
int $0x10
#1:
# jmp 1b
mov $0x9000, %ax
mov %ax, %es
load_boot:
mov $0x0201, %ax
mov $0x0002, %cx
mov $0x0000, %dx
mov $0x0000, %bx
int $0x13
jnc ok_load_boot
mov $0x0000, %dx
mov $0x0000, %ax
int $0x13
jmp load_boot
ok_load_boot:
movw %cs, %ax
movw %ax, %es
movw %ax, %ds
movw $okmsgstr, %bp
movw len1, %cx
movb $0x06, %dh
movb $0x08, %dl
movb $0x01, %al
movb $0x13, %ah
movb $0x01, %bl
movb $0x00, %bh
int $0x10
noequal:
.code32
jmp 0x90000
loadstr:
.asciz "start load"
len2:
.int . - loadstr
okmsgstr:
.asciz "boot load ok and read ok"
len1:
.int . - okmsgstr
.org 0x1fe, 0x90
.word 0xaa55
boot.s
.section .text
.global _start
.code16
_start:
movw $0x9000, %ax
movw %ax, %ds
movw %ax, %es
# pushl $0
# pushl $0
# pushl $0
# pushl $L6
# pushl $main
# ret
L6:
movw $msgstr,%bp
movw len, %cx
movb $0x07, %dh
movb $0x08, %dl
movb $0x01, %al
movb $0x13, %ah
movb $0x01, %bl
movb $0x00, %bh
int $0x10
1:
jmp 1b
msgstr:
.asciz "Hello babyos(print by BIOS int 0x10:0x13, mode 0x01)!"
len:
.int . - msgstr
.org 0x1fe, 0x90
.word 0xaa55
两个文件编译链接后的大小都是512个字节。分别把它们写到模拟软盘的两个扇区中(0扇区与1扇区)
运行时,loader.s读取1扇区,并将它加载到内存0x90000处,然后调用jmp 0x90000指令。应该就可以执行boot.s
的代码。按道理应该打印出字符串"Hello babyos(print by BIOS int 0x10:0x13, mode 0x01)!" 但是在vmware中,
将模拟软盘作为启动盘,启动后,其他的字符串都打印出来了,就是boot.s中的字符串没有打印出来,请问代码哪里有问题。感觉是跳转的问题。
谢谢!
makefile:
objects = boot.o loader.o
all:myimage2.flp
#main.s:main.c
# gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -S -o $*.s $<
$(objects):%o:%s
as $< -o $@
#boot:$(objects)
loader:loader.o
ld --oformat binary -N -Ttext 0x7c00 -o $@ loader.o
#ld --oformat binary -N -o $@ loader.o
boot:boot.o
ld --oformat binary -N -Ttext 0x9000 -o $@ boot.o
image:loader boot
cat loader boot > $@
myimage2.flp:image
./createimage image $@
clean:
rm *.o
rm boot
rm image
rm loader
rm myimage2.flp
编译环境
ubuntu 64位