Browse Source

read from disk

greatbridf 4 years ago
parent
commit
84095c6cd7
2 changed files with 21 additions and 19 deletions
  1. 6 2
      bochs.conf
  2. 15 17
      src/boot.s

+ 6 - 2
bochs.conf

@@ -1,9 +1,13 @@
 megs: 4
 
-floppya: 1_44=build/boot.img, status=inserted
+# floppya: 1_44=build/boot.img, status=inserted
+ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
+ata0-master: type=disk, path="build/boot.img", mode=flat, cylinders=0, heads=0, spt=0, model="Generic MyDisk", biosdetect=auto, translation=auto
 
-boot: floppy
+boot: disk
 
 mouse: enabled=0
 
 display_library: x, options="gui_debug"
+
+magic_break: enabled=1

+ 15 - 17
src/boot.s

@@ -11,37 +11,35 @@ real_start:
     movw %ax, %ds
     movw %ax, %es
     movw %ax, %ss
+
+# perform a temporary stack
     movw $(stack_base-_start), %ax
     movw %ax, %bp
     movw %ax, %sp
 
-    call print_hello
+    call read_data
 
 die:
     hlt
     jmp die
 
-print_hello:
-    push %bp
-    mov %sp, %bp
-
-    mov $(string_hello-_start), %ax
-    push %bp
-    mov %ax, %bp
-    movw $0x1301, %ax
-    movw $0x000f, %bx
-    movw $12, %cx
-    movw $0, %dx
-    int $0x10
-    pop %bp
-
-    mov %bp, %sp
-    pop %bp
+read_data:
+    movw $(read_data_pack-_start), %si
+    mov $0x42, %ah
+    mov $0x80, %dl
+    int $0x13
     ret
 
 string_hello:
 .string "Hello World!"
 
+read_data_pack:
+    .byte 0x10, 0
+    .word 2      # block count
+    .word 0x0000 # offset address
+    .word 0x0050 # segment address
+    .long  0     # LBA to read
+
 stack_edge:
 .space 128
 stack_base: