-
Notifications
You must be signed in to change notification settings - Fork 0
/
space_loader.asm
86 lines (64 loc) · 1.48 KB
/
space_loader.asm
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
; MACROS --------------------------------
%define int_video int 0x10
%define int_io int 0x13
; BOOTLOADER ------------------------
mov ax, 0x07C0
mov ds, ax
; store the drive
mov [drive], dl
; setup the stack
mov ax, 0x0050
cli
mov ss, ax
mov sp, 16384 ;16kb of stack
sti
mov si, msg_loading
call video_writeString
; load the code
mov bx, target
mov es, bx
mov bx, 0
mov dh, 00 ;read head 0
mov dl, [drive]
mov ch, 00 ;read track 0
mov cl, 02 ;read sector 02
mov al, 10 ;read n sectors
mov ah, 02 ;read function code
read_code:
int_io
jc error
mov si, msg_success
call video_writeString
mov bx,target
mov ds, bx
mov es, bx
jmp target:0x0000
error:
mov si, msg_error
call video_writeString
jmp read_code
; writes a char at the current position
; al is the char
video_writeChar:
mov ah, 0x0e
int_video
ret
; print the null terminated string in si
video_writeString:
lodsb
test al,al
jz video_writeString_end
call video_writeChar
jmp video_writeString
video_writeString_end:
ret
; BOOTLOADER STORAGE -------------------
drive db 0
target equ 0x07E0
msg_loading db 'Loading space...', 0xd, 0xa, 0
msg_error db 'Error!', 0xd, 0xa, 0
msg_success db 'Success! Jumping to it!', 0xd, 0xa, 0
; PADDING AND BOOT SIGNATURE --------------------------------------------------
times 510-($-$$) db 0
db 0x55
db 0xAA