From 062465da06231607f36c0ea6adf38ee5583ee13e Mon Sep 17 00:00:00 2001 From: me505 <62057938+me505@users.noreply.github.com> Date: Tue, 6 Sep 2022 01:56:14 +0530 Subject: [PATCH 1/3] Small optimizations in the 6th tutorial source --- 6.asm | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 6.asm diff --git a/6.asm b/6.asm new file mode 100644 index 0000000..5d6981d --- /dev/null +++ b/6.asm @@ -0,0 +1,61 @@ +[org 0x7c00] + + +; defines the constant code and data segments +CODE_SEG equ GDT_code - GDT_start +DATA_SEG equ GDT_data - GDT_start + +cli +lgdt [GDT_descriptor] + +mov eax, cr0 +or eax, 1 +mov cr0, eax + + +; far jump to our labe; +jmp CODE_SEG:start_protected_mode + +jmp $ + +GDT_start: ; must be at the end of real mode code + GDT_null: + dd 0x0 + dd 0x0 + + GDT_code: + dw 0xffff + dw 0x0 + db 0x0 + db 0b10011010 + db 0b11001111 + db 0x0 + + GDT_data: + dw 0xffff + dw 0x0 + db 0x0 + db 0b10010010 + db 0b11001111 + db 0x0 + +GDT_end: + +GDT_descriptor: + dw GDT_end - GDT_start - 1 ; size + dd GDT_start ; location + + +[bits 32] +start_protected_mode: + mov al, 'A' + mov ah, 0x0f + mov [0xb8000], ax + jmp $ + + +times 510-($-$$) db 0 +dw 0xaa55 + + + From dc3ec32932a2c8b5a324d855ecca5f38592db7f3 Mon Sep 17 00:00:00 2001 From: me505 <62057938+me505@users.noreply.github.com> Date: Tue, 6 Sep 2022 02:01:35 +0530 Subject: [PATCH 2/3] Sorry for that, i am new to github --- 6.asm | 61 ----------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 6.asm diff --git a/6.asm b/6.asm deleted file mode 100644 index 5d6981d..0000000 --- a/6.asm +++ /dev/null @@ -1,61 +0,0 @@ -[org 0x7c00] - - -; defines the constant code and data segments -CODE_SEG equ GDT_code - GDT_start -DATA_SEG equ GDT_data - GDT_start - -cli -lgdt [GDT_descriptor] - -mov eax, cr0 -or eax, 1 -mov cr0, eax - - -; far jump to our labe; -jmp CODE_SEG:start_protected_mode - -jmp $ - -GDT_start: ; must be at the end of real mode code - GDT_null: - dd 0x0 - dd 0x0 - - GDT_code: - dw 0xffff - dw 0x0 - db 0x0 - db 0b10011010 - db 0b11001111 - db 0x0 - - GDT_data: - dw 0xffff - dw 0x0 - db 0x0 - db 0b10010010 - db 0b11001111 - db 0x0 - -GDT_end: - -GDT_descriptor: - dw GDT_end - GDT_start - 1 ; size - dd GDT_start ; location - - -[bits 32] -start_protected_mode: - mov al, 'A' - mov ah, 0x0f - mov [0xb8000], ax - jmp $ - - -times 510-($-$$) db 0 -dw 0xaa55 - - - From 253d91308978c90d565da5b6f79df9cd74b1e20c Mon Sep 17 00:00:00 2001 From: me505 <62057938+me505@users.noreply.github.com> Date: Tue, 6 Sep 2022 02:02:18 +0530 Subject: [PATCH 3/3] Small optimization --- 6/6.asm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/6/6.asm b/6/6.asm index dc983a5..5d6981d 100644 --- a/6/6.asm +++ b/6/6.asm @@ -1,23 +1,23 @@ [org 0x7c00] - - -mov [BOOT_DISK], dl - +; defines the constant code and data segments CODE_SEG equ GDT_code - GDT_start DATA_SEG equ GDT_data - GDT_start cli lgdt [GDT_descriptor] + mov eax, cr0 or eax, 1 mov cr0, eax + + +; far jump to our labe; jmp CODE_SEG:start_protected_mode -jmp $ - - +jmp $ + GDT_start: ; must be at the end of real mode code GDT_null: dd 0x0 @@ -42,8 +42,8 @@ GDT_start: ; must be at the end of real mode code GDT_end: GDT_descriptor: - dw GDT_end - GDT_start - 1 - dd GDT_start + dw GDT_end - GDT_start - 1 ; size + dd GDT_start ; location [bits 32] @@ -53,7 +53,9 @@ start_protected_mode: mov [0xb8000], ax jmp $ -BOOT_DISK: db 0 times 510-($-$$) db 0 dw 0xaa55 + + +