在linux debian系统上写个hello world版的bootloader
来源:互联网 发布:软件项目经理责任制 编辑:程序博客网 时间:2024/05/22 02:27
根据http://viralpatel.net/taj/tutorial/hello_world_bootloader.php这篇文章来做的。
准备:
nasm
qemu
安装nasm和qemu:
sudo apt-get install nasm
sudo apt-get install qemu
编写bootloader文件,命名为mybootloader.asm:
[BITS 16];Tells the assembler that its a 16 bit code[ORG 0x7C00];Origin, tell the assembler that where the code will;be in memory after it is been loadedMOV SI, HelloString ;Store string pointer to SICALL PrintString;Call print string procedureJMP $ ;Infinite loop, hang it here.PrintCharacter:;Procedure to print character on screen;Assume that ASCII value is in register ALMOV AH, 0x0E;Tell BIOS that we need to print one charater on screen.MOV BH, 0x00;Page no.MOV BL, 0x07;Text attribute 0x07 is lightgrey font on black backgroundINT 0x10;Call video interruptRET;Return to calling procedurePrintString:;Procedure to print string on screen;Assume that string starting pointer is in register SInext_character:;Lable to fetch next character from stringMOV AL, [SI];Get a byte from string and store in AL registerINC SI;Increment SI pointerOR AL, AL;Check if value in AL is zero (end of string)JZ exit_function ;If end then returnCALL PrintCharacter ;Else print the character which is in AL registerJMP next_character;Fetch next character from stringexit_function:;End labelRET;Return from procedure;DataHelloString db 'Hello World', 0;HelloWorld string ending with 0TIMES 510 - ($ - $$) db 0;Fill the rest of sector with 0DW 0xAA55;Add boot signature at the end of bootloader
编译mybootloader.asm:
nasm mybootloader.asm -f bin -o boot.bin
运行qemu, 加载bootloader:
qemu-system-i386 boot.bin
结果如图:
0 0
- 在linux debian系统上写个hello world版的bootloader
- “Hello World”在Linux系统上的运行过程
- Writing Hello World Bootloader
- 在Debian中建立Beaglebone black的应用开发环境之五:来一个hello world
- NET Core 2.0 在WIN7系统 的Hello World
- Android系统的"Hello World"
- 从hello world理解Linux的编译系统
- 从hello world理解Linux的编译系统
- NASM 在linux 环境下 的hello world 程序
- linux 驱动程序的hello world
- Linux 下的“Hello world!”
- Linux下的“Hello world!”
- Linux上的"Hello world"
- linux系统中运行hello world
- 在Linux下打印出Hello World!
- 在linux下输出hello world
- 在eclipse下创建maven版的hello world
- 驱动版的“Hello World”
- leveldb资料整理
- java异常处理<2>__笔记(18)
- 柔性数组
- 微信公众平台之CURL应用access_token
- 找出链表的中间结点 C语言实现
- 在linux debian系统上写个hello world版的bootloader
- leveldb项目实践
- android studio获取sha1的值mac版
- Ubuntu14.04使用VNC无法显示图形界面问题的解决
- hdoj Chopsticks 1500 (DP)筷子配对
- UniBeast:在任何支持基于英特尔处理器的PC上安装OS X优胜美地
- mysql5.5 主从备份设置
- python学习之4 文本文件读写
- JavaScript2