File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ _start:
12
12
mov fs , ax
13
13
mov gs , ax
14
14
15
- # TODO explain
15
+ # clear the direction flag (e.g. go forward in memory when using
16
+ # instructions like lodsb )
16
17
cld
17
18
18
19
@@ -29,6 +30,7 @@ enable_a20:
29
30
out 0x92 , al
30
31
31
32
enter_protected_mode:
33
+ # clear interrupts
32
34
cli
33
35
push ds
34
36
push es
@@ -118,6 +120,9 @@ println:
118
120
print:
119
121
cld
120
122
print_loop:
123
+ # note: if direction flag is set (via std )
124
+ # this will DECREMENT the ptr , effectively
125
+ # reading/printing in reverse.
121
126
lodsb al , BYTE PTR [ esi ]
122
127
test al , al
123
128
jz print_done
Original file line number Diff line number Diff line change @@ -56,7 +56,11 @@ load_next_kernel_block_from_disk:
56
56
push ecx
57
57
push esi
58
58
mov ecx , 512 / 4
59
+ # move with zero extension
60
+ # because we are moving a word ptr
61
+ # to esi , a 32 - bit register.
59
62
movzx esi , word ptr [ dap_buffer_addr ]
63
+ # move from esi to edi ecx times.
60
64
rep movsd [ edi ], [ esi ]
61
65
pop esi
62
66
pop ecx
@@ -256,7 +260,7 @@ gdt_64_pointer:
256
260
257
261
long_mode:
258
262
# call load_elf with kernel start address , size , and memory map as arguments
259
- movabs rdi , 0x400000
263
+ movabs rdi , 0x400000 # move absolute 64 - bit to register
260
264
mov rsi , _kib_kernel_size
261
265
lea rdx , _memory_map
262
266
movzx rcx , word ptr mmap_ent
You can’t perform that action at this time.
0 commit comments