0%

OS写作2

现在开始 32 位 protected mode!所以和 real 的区别是什么呢?

operating system - What is the true difference between a real mode program and a protected mode program? - Stack Overflow

跟 BIOS 和 OS 有关?

下一步是准备 global descriptor table (GDT) which defines memory segments and their protected-mode attributes

似乎是这两个mode互相转换中?32 无法使用 BIOS 了!这个也是区别!

适应没有 BIOS 的生活

暂时回到 BIOS 是可能的,但是这个不稳定也不安全所以不能这样使用。现在所有的一切都得自己加油了,各种驱动,不过从显示字母开始罢……

display 有 graphic 和 text mode。

Video Graphics Array (VGA),每个字母 80*25 dimension。这样的话以后就可以直接调用这个 letter,不用一个一个 pix 的 render。每个字母会占两个 byte,第一个是 ASCII,第二个是 foreground and background colour。

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
[ bits 32]
; Define some constants
VIDEO_MEMORY equ 0xb8000 ; equ def constant
WHITE_ON_BLACK equ 0x0f
; prints a null - terminated string pointed to by EDX
print_string_pm:
pusha
mov edx , VIDEO_MEMORY ; Set edx to the start of vid mem.

print_string_pm_loop :
mov al , [ ebx ]
; Store the char at EBX in AL
mov ah , WHITE_ON_BLACK ; Store the attributes in AH
cmp al , 0; if ( al == 0) , at end of string , so
je done
; jump to done
mov [ edx ] , ax ;Store char and attributes at current character cell.
add ebx , 1 ;Increment EBX to the next char in string.
add edx , 2 ;Move to next character cell in vid mem.

jmp print_string_pm_loop
; loop around to print the next char.
print_string_pm_done :
popa
ret
; Return from the function

assembly - What's the difference between equ and db in NASM? - Stack Overflow

GDT

Global Descriptor Table