Linux汇编写引导扇区
最近再看《Orange‘s一个操作系统的实现》,里面用的是intel的汇编语法,自己比较习惯AT&T的语法了,自己研究了好长时间才将代码修改成功。
.code16
.section.text
.globl_start
_start:
movw%cs,%ax
movw%ax,%ds
movw%ax,%es
callDispStr
loop1:jmploop1
DispStr:
movw$BootMessage,%ax
movw%ax,%bp
movw$0x10,%cx
movw$0x1301,%ax
movw$0xc,%bx
movb$0,%dl
int$0x10
ret
BootMessage:.ascii "Hello, OS world!"
.org510
.word0xAA55
.code16指示as生成16位的代码。While `as' normally writes only "pure" 32-bit i386 code or 64-bit x86-64 code depending on the default configuration, it also supports writing code to run in real mode or in 16-bit protected mode code segment.
编译的话 as -o boot.o boot.s ;
ld -Ttext=0x7c00 --oformat binary -o boot.bin boot.o;
这样就ok了~~