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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#if !defined(USE_NASM) && !defined(USE_AS86)
#define USE_AS86
#endif
#ifdef USE_AS86
#define CON(x) *x
#define BCON(x) *x
#define WCON(x) *x
#define LOC(x) x
#define BLOC(x) byte ptr x
#define WLOC(x) word ptr x
#define JMP(x) jmp x
#define STRDECL(s) .ascii s
#define SEGCS seg cs
#define SEGES seg es
#define ALIGN(x) .align x
#define SPACE(x) .space x
#endif
#ifdef USE_NASM
#define CON(x) x
#define BCON(x) byte x
#define WCON(x) word x
#define LOC(x) [x]
#define BLOC(x) byte [x]
#define WLOC(x) word [x]
#define JMP(x) jmp short x
#define STRDECL(s) db s
#define SEGCS cs
#define SEGES es
#define ALIGN(x) align x, db 0
#define SPACE(x) times x db 0
#endif
ROMLOAD equ 0x5000
start:
cli
xor ax, ax
mov ss, ax
mov sp, CON(0x7C00)
mov si, sp
mov es, ax
mov ds, ax
sti
cld
mov di, CON(0x600)
mov cx, CON(0x100)
rep
movsw
db 0xEA
dw jump
dw 0
jump:
mov si, CON(Hlaska)
call print
; rozmery prvniho HD
mov ah, CON(8)
mov dl, CON(0x80)
int 0x13
jc chyba
; dh - H, cx - CS
; prvi stopa obsahuje bootrom, tak ji natahneme do RAM
mov ah, CON(2)
mov al, cl
and al, CON(0x3F)
dec al
mov dx, CON(0x80)
mov cx, CON(2)
mov bx, CON(ROMLOAD)
mov es, bx
xor bx, bx
int 0x13
jc chyba
; hromada kodu podle zdrojaku netboot
xor di, di
mov es, di
mov di, CON(0x380)
push di
mov cx, CON(10)
cld
rep
stosw
pop di
#ifdef USE_AS86
mov word ptr [ di ], CON(0x5a5a)
mov byte ptr [ di + 2 ], CON(0x50)
mov word ptr [ di + 0x10 ], CON(0xFFFF)
mov word ptr [ di + 0x12 ], CON(0xFFFF)
#endif
#ifdef USE_NASM
mov word [ di ], CON(0x5a5a)
mov byte [ di + 2 ], CON(0x50)
mov word [ di + 10h ], CON(0xFFFF)
mov word [ di + 12h ], CON(0xFFFF)
#endif
; navratova adresa, kdyby nezabrala ROM
SEGCS
mov WLOC(OfsErr), CON(RomErr)
push cs
push WCON(chyba)
mov ax, CON(ROMLOAD)
mov es, ax
push es
; kouzelny jump....
SEGES
mov si, [ 0x1a ]
SEGES
#ifdef USE_AS86
push word ptr [ si + 0x1a ] ; ...do bootrom v RAM
#endif
#ifdef USE_NASM
push word [ si + 0x1a ] ; ...do bootrom v RAM
#endif
retf
chyba:
SEGCS
mov si, LOC(OfsErr)
call print
mov si, CON(CRLF)
call print
JMP(chyba)
print:
lodsb
cmp al,CON(0)
je navrat
push si
mov bx,CON(7)
mov ah,CON(0x0E)
int 0x10
pop si
JMP(print)
navrat:
ret
Hlaska: db 13, 10
STRDECL('HD Net Loader v1.0 (c) poli 1999')
db 13, 10, 0
CRLF: db 13, 10, 0
OfsErr: dw Error
Error: STRDECL('Error load from HD !')
db 0
RomErr: STRDECL('ROM Error !')
db 0
mbrend:
ret
#ifdef USE_AS86
org 510
#endif
#ifdef USE_NASM
times 510-($-$$) db 0
#endif
dw 0xAA55
|