|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[BITS 16]
[org 0x8000]
JMP short Start
print_string: ; Expects null terminated message in si
for_print_string_0:
MOV al,[si]
OR al,al
JZ end_for_print_string_0
INC si
CALL print_char
JMP for_print_string_0
end_for_print_string_0:
RETN
print_char:
MOV ah,0x0E ; Specifies that we want to write a character to the screen
MOV bl,0x02 ; Specifies output text color. Not required, but useful to know
MOV bh,0x00 ; Page number. Leave this alone.
INT 0x10 ; Signal video interrupt to BIOS
RETN
|
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
execute_sector:
PUSH ebp
MOV ebp, esp
PUSH ax
PUSH bx
PUSH cx
PUSH dx
MOV ax, [10 + ebp] ; base address
MOV es, ax
MOV al, [8 + ebp] ; num
MOV cl, [6 + ebp] ; offset
MOV ah, 2 ; Function read
XOR ch, ch ; cylinder
XOR dh, dh ; head
MOV dl, 0x81 ; drive
INT 0x13
XOR si, si
PUSH es
PUSH bx
RETF
|
|
45
46
47
48
49
50
51
52
53
|
Start:
XOR ax, ax
MOV ds, ax
MOV ax, 0x1000
MOV es, ax
XOR bx, bx
for_start_0:
MOV si, str
CALL print_string
|
|
54
55
56
57
58
|
PUSH 0x7c0; Base address, offset is 0
PUSH 1 ; num
PUSH 1 ; offset
XOR bx, bx;
;CALL execute_sector
|
|
59
|
;JMP for_start_0
|
|
60
|
JMP $
|
|
61
62
63
64
65
66
67
|
str: db 'Hi! I',0x27,'m the second binary!',0x0A,0x0D,0x00
TIMES 510 - ($ - $$) db 0
|