使用AT&T汇编语法改写linux0.00的boot.s

BOOTSEG = 0x07c0
SYSSEG = 0x1000
SYSLEN =
17

.code16
.align
2
.text
.globl _start
_start:
ljmp $BOOTSEG, $go
go:
movw %cs, %ax
movw %ax, %ds
movw %ax, %ss
movw %ax, %es
movw $0x0400, %sp
load_system:
movw $0x0000, %dx
movw $0x0002, %cx
movw $SYSSEG, %ax
movw %ax, %es
xorw %bx, %bx
movw $0x200+SYSLEN, %ax
int $0x13
jnc ok_load
die:
ljmp $BOOTSEG, $die
ok_load:
cli
movw $SYSSEG, %ax
movw %ax, %ds
xorw %si, %si
xorw %ax, %ax
movw %ax, %es
xorw %di, %di
movw $0x1000, %cx
cld
rep movsw

movw $BOOTSEG, %ax
movw %ax, %ds
lidt idt_48
lgdt gdt_48

movw $0x0001, %ax
lmsw %ax
ljmp $
8, $0

gdt:
.word
0, 0, 0, 0

.word 0x07FF
.word 0x0000
.word 0x9A00
.word 0x00c0

.word 0x07ff
.word 0x0000
.word 0x9200
.word 0x00c0

idt_48:
.word
0
.word
0, 0
gdt_48:
.word 0x7ff
.word 0x7c00+gdt,
0
.org
510
.word 0xaa55

 

/*
AS =as
LD =ld
LDFLAGS =-m elf_i386 -Ttext 0 -e startup_32 -s -x -M

all: Image

Image: boot system
objcopy -O binary boot.o Image
objcopy -O binary system head
cat head >> Image

head.o: head.s

system: head.o
$(LD) $(LDFLAGS) head.o -o system > System.map

boot: boot.s
$(AS) -o boot.o boot.s

clean:
rm -f Image System.map core boot *.o system
*/

 

posted @ 2010-07-15 12:41  penink  阅读(612)  评论(0)    收藏  举报