summaryrefslogtreecommitdiffstats
path: root/bootsect.s
blob: 5e24681699ae267866fd7bf737cd6ac67ecb7af7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    org     0x7c00  ; boot sector

entry:
    ; now loading from disk
    mov     cx, 3       ; retry count
    mov     ax, 0x0000
    mov     ds, ax
    mov     ax, 0x9050
    mov     es, ax      ; set es, the destination
    mov     bx, 0
loaddisk:
    mov     si, cx
    mov     ah, 0x02    ; function: read disk sectors
    mov     al, 8       ; sector count
    mov     dh, 0       ; head
    mov     dl, 0       ; drive number
    mov     ch, 0       ; track 
    mov     cl, 2       ; sector offset
    int     0x13
    jnc     loadok
    mov     bl, al
    call    putcharhex
    mov     cx, si
    loop    loaddisk

    ; load failed
    mov     ah, 0x0e
    mov     al, 'X'
    int     0x10
    jmp     $

    ; load OK
loadok:
    mov     ah, 0x0e
    mov     al, 'P'
    int     0x10
    mov     al, 'R'
    int     0x10
    mov     al, 'E'
    int     0x10
    mov     al, 'Y'
    int     0x10
    mov     al, 'O'
    int     0x10
    mov     al, 'T'
    int     0x10
    mov     ax, 0x9050
    mov     ds, ax
    mov     es, ax
    mov     ss, ax
    db      0xEA
    dd      0x90500000

%include "basic.s"