2global copy_page_physical
3global get_instruction_pointer
6 push ebp ; Save stack base.
7 mov ebp, esp ; Set register base to register top.
8 pusha ; According to __cdecl, we must preserve the contents of EBX.
9 pushf ; push EFLAGS, so we can pop it and reenable interrupts
10 ; later, if they were enabled anyway.
11 cli ; Disable interrupts, so we aren't interrupted.
12 ; Load these in BEFORE we disable paging!
13 mov ebx, [ebp+8] ; Source address
14 mov ecx, [ebp+12] ; Destination address
16 mov edx, cr0 ; Get the control register...
17 and edx, 0x7fffffff ; and...
18 mov cr0, edx ; Disable paging.
20 mov edx, 1024 ; 1024*4bytes = 4096 bytes to copy
23 mov eax, [ebx] ; Get the word at the source address
24 mov [ecx], eax ; Store it at the dest address
25 add ebx, 4 ; Source address += sizeof(word)
26 add ecx, 4 ; Dest address += sizeof(word)
27 dec edx ; One less word to do
30 mov edx, cr0 ; Get the control register again
31 or edx, 0x80000000 ; and...
32 mov cr0, edx ; Enable paging.
34 popf ; Pop EFLAGS back.
35 popa ; Get the original value of EBX back.
36 mov esp, ebp ; Restore stack.
37 pop ebp ; Restore stack base.
41get_instruction_pointer: