File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,16 +36,54 @@ section .text:
3636 pop ax ; Recover AX value from stack
3737 pop bx ; Recover BX value from stack
3838
39+ mov [ disk_index ], dl
40+ mov bx , kernel_address
41+ mov dh , 2
42+ call _read_disk
3943
4044 jmp $ ; Stops the processor
4145
4246
4347; Data Section
4448%include "functions/io.asm"
49+ %include "functions/disk_mng.asm"
4550
4651 msg: db "Hello, There!\nPlease enter your message: " , 0x0 ; Printable string
4752
4853 buffer: times 4 db 0 ; Defines input buffer
4954
50- times 510 - ($ - $$) db 0 ; Fills binary with 0 to keep the offset of 512
51- dw 0xAA55 ; Magic Word
55+ kernel_address: equ 0x1000
56+ disk_index: db 0
57+
58+ Global Descriptor Table
59+ GDT_start:
60+ GDT_null:
61+ dd 0x0
62+ dd 0x0
63+
64+ GDT_code:
65+ dw 0xffff
66+ dw 0x0
67+ db 0x0
68+ db 0b10011010
69+ db 0b11001111
70+ db 0x0
71+
72+ GDT_data:
73+ dw 0xffff
74+ dw 0x0
75+ db 0x0
76+ db 0b10010010
77+ db 0b11001111
78+ db 0x0
79+
80+ GDT_end:
81+
82+ GDT_descriptor:
83+ dw GDT_end - GDT_start - 1
84+ dd GDT_start
85+
86+ times 510 - ($ - $$) db 0 ; Fills binary with 0 to keep the offset of 512
87+ dw 0xAA55 ; Magic Word
88+ times 512 db 'A' ; sector 2 = 512 bytes
89+ times 512 db 'B' ; sector 3 = 512 bytes
Original file line number Diff line number Diff line change 1+ global _read_disk
2+
3+ section .text:
4+ _read_disk:
5+ pusha
6+ push dx
7+
8+ mov ah , 0x02
9+ mov al , dh
10+ mov cl , 0x02
11+ mov ch , 0x00
12+ mov dh , 0x00
13+
14+ int 0x13
15+ jc disk_error
16+
17+ pop dx
18+ cmp al , dh
19+ jne sectors_error
20+ popa
21+ ret
22+
23+
24+ disk_error:
25+ push DISK_ERROR
26+ call _printform at
27+
28+ sectors_error:
29+ push SECTORS_ERROR
30+ call _printform at
31+
32+ DISK_ERROR: db "Disk read error" , 0
33+ SECTORS_ERROR: db "Incorrect number of sectors read" , 0
Original file line number Diff line number Diff line change @@ -46,7 +46,9 @@ section .text:
4646 mov al , [ bx ] ; Moves addresses value to AL
4747
4848 cmp al , 0x6e ; If character is 'n'
49- call _newline ; Call new line
49+ je _newline ; Call new line
50+ cmp al , 0x30 ; If character is '0'
51+ je _done_printf ; Exits if was \0
5052
5153 inc bx ; Incriment BX
5254 jmp _print_next_char ; Jump to next char
Original file line number Diff line number Diff line change 11#! /bin/bash
22
33nasm -f bin -o boot.bin boot.asm
4- qemu-system-x86_64 boot.bin
4+ qemu-system-x86_64 -fda boot.bin
You can’t perform that action at this time.
0 commit comments