.code16
.section ".bstext", "ax"
.global bootsect_start
bootsect_start:
cli
movw %cs, %ax#ax = code section address
movw%ax, %ds#ds = code section address
movw%ax, %es#es = code section address
movw0x4000, %ax#toplimit of stack
movw%ax, %ss#ss = toplimit of stack
xorw%sp, %sp#sp = 0
movw0xB800, %ax
movw%ax, %es#es = address of VGA
xorw%di, %di#di = 0, initial address
movw0x0000, %ax#ax = black space
movw0x0250, %bx#the destination of loop
cloop:stosw#store, di automatically + 2
cmp%di, %bx#check if arrive the destination
jb cloop
xorw%di, %di#di = 0, initial print address
movw$output, %si#si = output addr, init hello word addr
movw0x004C, %bx#the destination of loop
ploop:
lodsb#al -> word, si automatically + 1
movb0x07, %ah#ah -> white word
stosw#print word in colour
cmp%di, %bx
jb ploop
eloop:
jmp eloop
.section ".bsdata", "ax" #data section
output: .ascii "helloworld by whitestarmeow, PB15111598"
length:
.int 2000
strlen:
.int 39
.section ".signature", "a"
.globl sig
sig: .word 0xAA55
.section ".bstext", "ax"
.global bootsect_start
bootsect_start:
cli
movw %cs, %ax#ax = code section address
movw%ax, %ds#ds = code section address
movw%ax, %es#es = code section address
movw0x4000, %ax#toplimit of stack
movw%ax, %ss#ss = toplimit of stack
xorw%sp, %sp#sp = 0
movw0xB800, %ax
movw%ax, %es#es = address of VGA
xorw%di, %di#di = 0, initial address
movw0x0000, %ax#ax = black space
movw0x0250, %bx#the destination of loop
cloop:stosw#store, di automatically + 2
cmp%di, %bx#check if arrive the destination
jb cloop
xorw%di, %di#di = 0, initial print address
movw$output, %si#si = output addr, init hello word addr
movw0x004C, %bx#the destination of loop
ploop:
lodsb#al -> word, si automatically + 1
movb0x07, %ah#ah -> white word
stosw#print word in colour
cmp%di, %bx
jb ploop
eloop:
jmp eloop
.section ".bsdata", "ax" #data section
output: .ascii "helloworld by whitestarmeow, PB15111598"
length:
.int 2000
strlen:
.int 39
.section ".signature", "a"
.globl sig
sig: .word 0xAA55