自己编写操作系统的笔记5
2009-03-27 14:21
239 查看
对于保护模式和boot sector理解还是不够深。今天仅仅打算在昨天的基础上打出hello protect mode,发现不能输出……一个字都没输出,仅仅看出jmp $的样子。还是寻址没有弄明白啊。
先上代码,继续研究:
运行到jmp $处我想调试一下,所以就暂停(我用的是vmware),然后用ultra Edit打开内存文件,发现hello这句话在7cc4处。然后看到mov ax,msg的跳转指向的正是这里,可是没有输出,实在是太奇怪了。大概还是不了解这些跳转的详细内容吧
先上代码,继续研究:
Title protect.asm include protect.inc .386p ;------------------------------------------------------- code segment use16 assume cs:code org 07c00h Start: xor eax,eax ;设置GDT基址 mov ax,code mov ds,ax shl eax,4 add eax,offset GDT mov dword ptr GDTPTR.base,eax xor eax,eax ;设置代码段基址 mov ax,code shl eax,4 mov codes.Basel,ax shr eax,16 mov codes.Basem,AL mov codes.Baseh,AH xor eax,eax ;设置数据段基址 mov ax,code shl eax,4 add eax,offset msg mov datas.Basel,ax shr eax,16 mov datas.Basem,al mov datas.Baseh,ah lgdt Fword PTR GDTPTR cli OpenA20 SetCR0ToProtect Jump16 <code_sel>,<OFFSET begin> ;不了解 begin: SetCR0ToReal JUMP16 <seg real>,<offset real> real: CloseA20 sti mov ax,code mov ds,ax mov cs,ax mov es,ax call dispstr jmp $ ;循环 dispstr: mov ax,msg ;以下几行参见原书注释 mov bp,ax mov cx,19 mov ax,01301h mov bx,000ch mov dl,0 int 10h ret GDT Label Byte space Descriptor<> codes Descriptor<0FFFFh,,,DA_C,0> code_sel=codes-GDT datas Descriptor<0FFFFh,,,DA_DRW,0> data_sel=datas-GDT GDTLEN=$-GDT GDTPTR fdesc<GDTLEN-1,> msg: db "Hello,Protect Mode!" ;所要打印字符串 MSGLEN=$-msg db 510-($-offset Start) dup(0) dw 0AA55h code ends end start
运行到jmp $处我想调试一下,所以就暂停(我用的是vmware),然后用ultra Edit打开内存文件,发现hello这句话在7cc4处。然后看到mov ax,msg的跳转指向的正是这里,可是没有输出,实在是太奇怪了。大概还是不了解这些跳转的详细内容吧
相关文章推荐
- 自己编写操作系统的笔记7
- 自己编写操作系统的笔记6
- 自己编写操作系统的笔记3
- 《自己动手编写操作系统》笔记
- 自己编写操作系统的笔记1
- 自己编写操作系统的笔记2
- 自己编写操作系统的笔记4
- IOS开发笔记 (3)---objective c 自己编写测试示例
- 自己写操作系统 笔记1
- 【学习笔记】自己动手写操作系统--pmtest3
- 《30天编写自己的操作系统》 关于如何让虚拟机从U盘启动
- 【学习笔记】自己动手写操作系统--pmtest1
- 遗传算法与直接搜索工具箱学习笔记 二-----编写自己的目标函数
- 自己动手写操作系统--笔记之安装DOS
- 自己动手写操作系统之第一部分笔记
- 操作系统编写视频教程(自己写操作系统)
- 自己动手写操作系统 笔记
- 自己动手编写操作系统
- Servlet学习笔记(七)—— 自己定义过滤器的编写改进:自己定义实现FilterChain
- 【学习笔记】自己动手写操作系统——pmtest2