WHAT IS THIS?
=============
Sample protected-mode code, in increasing order of complexity:
* Basic 32-bit protected mode.
* Access to text-mode video memory. * Linear (flat) memory.
* Return to real mode. * PM interrupts/exceptions.
* Test for Virtual 8086 mode. * PM text-output subroutine.
* CPU detection (386 or better). * Software interrupt validation.
* "Unreal" mode (flat real, big real).
* Copying code to alternate memory location and running it there.
* Enabling A20 gate. * Running code in extended memory.
* Simple task state segment (TSS) use.
* Preemptive multitasking via timer interrupt.
* Ring 0 (kernel/system mode) code to/from Ring 3 (user mode) code.
* Syscalls. * Reprogramming 8259 interrupt chip.
* Interface/linking to C-language code. * Beginnings of a libc.
* More elaborate syscalls/exception handler.
* Scrolling video and cursor movement.
PM1.ASM is heavily commented, and tries to serve as a tutorial.
The .ASM files are written in x86 assembly language and should be
assembled with NASM (the free x86 assembler) like this:
nasm -o pmXXX.com pmXXX.asm
I am also including the PM12C.C file, which needs DJGPP, the free
32-bit C compiler for MS-DOS.
A pre-compiled version of NASM 0.97 that I downloaded from the Internet
gave me a lot of grief. The problems went away after I downloaded the
NASM sources and compiled them myself under DJGPP. Be warned.
These programs assume a 386 or better CPU (386 SX/DX, 486 SX/DX, Pentium,
Pentium II, non-Intel clone processors, etc.).
WHERE IS THIS?
==============
http://www.execpc.com/~geezer/os/pm.zip
WHAT CAN I DO WITH THIS?
========================
Anything you want, so long as you don't
- take credit for something you didn't do, or
- blame me for the results.
WHY DOESN'T IT WORK?
====================
See KNOWN BUGS, below.
"My computer freezes up!"
pm10 and later programs do not include code to return to real mode: after
doing their thing, they freeze. Press the reset button or cycle power to
reboot.
"It doesn't freeze up but nothing gets printed."
These apps put text on the top line of the screen by writing directly to
video memory. If the cursor is at the bottom of the screen when you type
pm1 (or whatever), the output of the program will get scrolled off the
top of the screen after it returns to DOS. Try
cls
pm1 (or whatever)
(thanks to Mark for the heads-up on this).
"These programs freeze up my computer without printing anything."
pm6 will crash if extended memory is in use (e.g. by SMARTDRV). If the
crash is happening in other situations, please let me know about it.
"The computer just reboots."
Again, this shouldn't happen (and again, let me know if it does). Bad
protected-mode code often makes the CPU triple-fault, which causes the
computer to reset itself. Hopefully, this code is simple enough that it
shouldn't have any bugs.
"Windows 95 says 'MS-DOS mode' and terminates the program."
These programs won't run under Windows. MS-DOS mode might work, but it's
better to reboot the computer, wait for 'Starting Windows 95...' and quickly
press F8. Then chose 'Safe mode command prompt only' and run these files.
"EMM386 privileged operation error..."
Same problem as Windows (CPU is in Virtual 8086 mode). If you are loading
EMM386.EXE in CONFIG.SYS, comment it out. Or use the F8 boot option
described above. The EMM386 that comes with Win95 lets you press 'C' to
disable EMM386 and continue, which may or may not work.
"Nothing happens, no 'Hello' or reboot -- it just returns to DOS."
pm3.asm through pm6.asm return to DOS if Virtual 8086 mode is detected
(Windows DOS box or EMM386). pm4.asm through pm6.asm return to DOS if an
8088 or 80286 CPU is detected (though this hasn't been tested). Type
test pm3
and look at the output. If it says
Program 'pm3' returned errorlevel 1.
then the CPU is in Virtual 8086 mode (Windows DOS box or EMM386 in use).
If you type 'test pm4' and get
Program 'pm4' returned errorlevel 2.
this means the CPU is not a 386 or better.
WHERE'D YOU LEARN TO DO THIS?
=============================
Freedows '98 -- Copyright (C) 1997 Joachim Breitsprecher
<j.breitsprecher@schwaben.de>
Benn Vosseteig posted some spiffy Ring 0-to-Ring 3
code on the OS development board at
http://milkyway.isa.net.au/os-dev/cgi-bin/blueboard.exe
Linux -- Copyright (C) 1991, 1992 Linus Torvalds
I recommend the 'Historic' kernel (version 0.01), available from
http://www.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz
INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986, available from
http://www.execpc.com/~geezer/os/386intel.zip
and many other sites.
Robert Collins' "Intel Secrets" web site:
http://www.x86.org
Josh McDonald's OS/2000
http://www.effect.net.au/os-dev/
KNOWN BUGS
==========
One task of pm8 seems to die if run indefinitely instead of only 18 times
(maybe this is some kind of weird resonance).
FEEDBACK
========
...is welcome.
Christopher Giese <geezer[AT]execpc.com>
没有合适的资源?快使用搜索试试~ 我知道了~
自己动手写造作系统(源代码)随书光盘
共909个文件
h:179个
c:166个
asm:151个
需积分: 9 69 下载量 112 浏览量
2007-09-24
12:03:44
上传
评论
收藏 2.64MB RAR 举报
温馨提示
自己动手写造作系统(源代码)随书光盘.rar<br><br>这个《自己动手写造作系统》还是挺有意思的,如果我还在大学,可能就一点点自己玩儿了。该书比较大,有要的同志可以自己找,也可以发信息给我,我给你传过去。
资源详情
资源评论
资源推荐
收起资源包目录
自己动手写造作系统(源代码)随书光盘 (909个子文件)
RULES.ASI 11KB
EMUVARS.ASI 5KB
PM1.ASM 25KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
loader.asm 23KB
C0.ASM 21KB
PM11.ASM 17KB
SETARGV.ASM 16KB
pmtest9.asm 16KB
PM12A.ASM 15KB
loader.asm 15KB
PM10.ASM 15KB
PM8.ASM 14KB
PM9.ASM 13KB
pmtest8.asm 12KB
PM6.ASM 12KB
PM5.ASM 12KB
PM7.ASM 12KB
PM9A.ASM 11KB
disboot.asm 11KB
PM4.ASM 10KB
pmtest5.asm 10KB
boot.asm 10KB
PM3.ASM 10KB
kernel.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
boot.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
kernel.asm 9KB
boot.asm 9KB
boot.asm 9KB
pmtest7.asm 9KB
kernel.asm 9KB
loader.asm 9KB
kernel.asm 8KB
kernel.asm 8KB
kernel.asm 8KB
PM2.ASM 8KB
kernel.asm 8KB
pmtest4.asm 8KB
kernel.asm 7KB
kernel.asm 7KB
boot.asm 7KB
pm2.asm 7KB
pmtest2.asm 7KB
pmtest3.asm 6KB
pmtest6.asm 6KB
klib.asm 5KB
klib.asm 5KB
klib.asm 5KB
klib.asm 5KB
klib.asm 5KB
klib.asm 5KB
klib.asm 5KB
klib.asm 4KB
klib.asm 4KB
klib.asm 4KB
共 909 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
lsyer
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0