Day 03 - Cross the Barrier of 512 Bytes

The outcome of today’s work is almost the same as Day 01, but the underneath improvement is big.

The program we run on Day 01 and Day 02 are so short that 512 Bytes are sufficiently large. For a decently long program, 512 Bytes are definitely not enough. In today’s code, we deliberately store the print-out message in the next 512-Byte sector after the startup sector.

Let’s see the source code. (Actually, we don’t need to do anything special…)

Source Code

bits 16
org 0x7c00

; these piece of codes are almost the same as previous

disk:
    db 0x0
CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start

times 510 - ($-$$) db 0
dw 0xaa55

; Compare to previous two days codes, the following code are in the second 512-byte sector.
copy_target:
bits 32

hello: db "Hello more than 512 bytes world!!", 0
boot2:
    mov esi, hello
    mov ebx, 0xb8000
.loop:
    lodsb
    or al,al
    jz halt
    or eax, 0x0F00       ; Setting font color to white (F)
    mov word [ebx], ax
    add ebx, 2
    jmp .loop
halt:
    cli
    hlt

times 1024 - ($-$$) db 0

Result

../../../../_images/result2.png