Repository navigation
Expand file tree
/
Copy pathc_init.s
More file actions
94 lines (80 loc) · 1.44 KB
/
Copy pathc_init.s
File metadata and controls
94 lines (80 loc) · 1.44 KB
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
.code16
.extern __bss_start__
.extern __bss_end__
.text
.global _start
_start:
mov %cs, %ax
mov %ax, %ds
mov %ax, %es
# setup stack
mov %ax, %ss
mov $0xffff, %sp
# call disp_str
call init_bss_asm
call p
# call disp_str2
jmp .
#disp_str:
# mov $BootMessage, %ax
# mov %ax,%bp
# mov $16,%cx
# mov $0x1301,%ax
# mov $0x00c,%bx
# mov $0,%dl
# int $0x10
# ret
#BootMessage:.ascii "Hello, c-env world!"
#disp_str2:
# mov $str2, %ax
# mov %ax,%bp
# mov $5,%cx
# mov $0x1301,%ax
# mov $0x00c,%bx
# mov $0,%dl
# int $0x10
# ret
#str2:.ascii "after"
# init bss
init_bss_asm:
movw $__bss_end__, %di /* Destination */
movw $__bss_start__, %si /* Source */
movw $0x0, %ax
movw %ax, %gs
jmp 2f
1:
movw %si, %ax
movb $0x1, %gs:(%eax)
add $1, %si
2:
cmpw %di, %si
jne 1b
ret
# movw 16(%ebp), %ecx /* Counter */
#1:
# cmp $0, %ecx /* Loop counter */
# jz MemCpy.2
# movb %ds:(%esi), %al
# inc %esi
# movb %al, %es:(%edi)
# inc %edi
# dec %ecx
# jmp MemCpy.1
#2:
# mov 8(%ebp), %eax
# pop %ecx
# pop %edi
# pop %esi
# mov %ebp, %esp
# pop %ebp
# ret
#.bss
#_bss_start_:.word __bss_start__
#_bss_end_:.word __bss_end__
.data
#LABEL_STACK:
#.space 512, 0
#.section ss
# mov %ax, %es
#.org 510
#.word 0xaa55