~cypheon/xos

xos/boot0.asm -rw-r--r-- 666 bytes
567db604 — Johann Rudloff Implement scanning and allocation of physical memory. 7 years ago
                                                                                
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
BITS 16

%define LOAD 0x7c00
%define NEXTLOAD 0x8000

[ORG LOAD]

start:
  ; set all segments to zero
  xor ax, ax
  mov es, ax
  mov ds, ax
  mov ss, ax

  mov ax, LOAD
  mov sp, ax

  mov si, greeting
  call print

  ; load next stage
  mov ax, 0x0206  ; ah=2: read sector, al=2: load 6 sectors
  mov cx, 0x0002
  mov dx, 0x0080  ; dl=0x80: first disk

  ; es:bx will be the destination for the read
  mov bx, NEXTLOAD
  int 13h

  ; jump to stage1
  jmp 0x0000:NEXTLOAD

greeting: db 'xos boot loader stage 0 ...', 0xa, 0xd, 0

print:
  mov ah, 0x0e
.repeat:
  lodsb
  cmp al, 0
  je .done
  int 0x10
  jmp .repeat
.done:
  ret

times 510-($-$$)-64 db 0
parttbl: