poc
This commit is contained in:
commit
3fe0dccba6
|
@ -0,0 +1,2 @@
|
||||||
|
*.o
|
||||||
|
*.bin
|
|
@ -0,0 +1,12 @@
|
||||||
|
boot.bin: boot.o
|
||||||
|
ld -o $@ --oformat binary -Ttext 0x7c00 $<
|
||||||
|
|
||||||
|
boot.o: boot.s
|
||||||
|
as -o $@ $<
|
||||||
|
|
||||||
|
.PHONY: boot disasm
|
||||||
|
boot: boot.bin
|
||||||
|
qemu-system-i386 -drive file=$^,index=0,if=floppy,format=raw
|
||||||
|
|
||||||
|
disasm: boot.bin
|
||||||
|
objdump -D -b binary -mi8086 $^
|
|
@ -0,0 +1,39 @@
|
||||||
|
.code16
|
||||||
|
|
||||||
|
.global _start # the linker needs to find it
|
||||||
|
_start:
|
||||||
|
# enter mode 13h
|
||||||
|
mov $0x13, %ax
|
||||||
|
int $0x10
|
||||||
|
|
||||||
|
mov $0xA000, %ax # ES = vga memory
|
||||||
|
mov %ax, %es
|
||||||
|
|
||||||
|
mov $0x7c0, %ax # DS = the bootsector
|
||||||
|
mov %ax, %ds
|
||||||
|
|
||||||
|
# %eax - position in sector
|
||||||
|
# it has to take up all of eax because of as's lack of real support
|
||||||
|
# for 16bit
|
||||||
|
# %ebx - position in vga mem
|
||||||
|
mov $0, %eax
|
||||||
|
mov $0, %ebx
|
||||||
|
loop:
|
||||||
|
movb %ds:(%eax), %cl
|
||||||
|
movb %cl, %es:(%ebx)
|
||||||
|
|
||||||
|
inc %bx
|
||||||
|
mov $16, %cl # if we've crossed a 16 pixel boundary, skip to the next line
|
||||||
|
and %bx, %cx
|
||||||
|
jz not_eol
|
||||||
|
add $304, %bx
|
||||||
|
not_eol:
|
||||||
|
inc %ax # only iterate 512 times
|
||||||
|
cmp $512, %ax
|
||||||
|
jl loop
|
||||||
|
|
||||||
|
incb %es:319
|
||||||
|
hlt
|
||||||
|
|
||||||
|
.fill 510-(.-_start), 1, 0x90 # fill with 0x90 (NOPs)
|
||||||
|
.word 0xaa55 # boot sector magic
|
Loading…
Reference in New Issue