用于编写引导加载程序的高级程序集指南(Advanced assembly guide for writing a bootloader)

编程入门 行业动态 更新时间:2024-10-11 05:30:34
用于编写引导加载程序的高级程序集指南(Advanced assembly guide for writing a bootloader)

对于计算机体系结构项目,我想编写一些可引导的代码来做一些简单的事情(我想过一个蛇游戏,如果那不是太复杂的话)。 我认为编写一个小型引导程序来将控制权传递给C程序应该不会太难,但我找不到任何准确的信息。

我正在寻找一些正确描述保护模式的x86程序集的高级指南(我仍然无法判断我是否需要切换到它,我的第一直觉是我没有),计算机如何启动,从键盘读取并打印到屏幕。

我可以在汇编中编写并传递gcc来编写小程序,我只需要启动和接口信息。 任何信息都很受欢迎,包括书籍。

For a computer architecture project I want to write some bootable code to do something simple (I thought of a snake game, if that's not too complicated). I thought that writing a small bootloader to pass control to a C program shouldn't be too hard, but I can't find any accurate info.

I'm looking for some advanced guide for x86 assembly properly describing protected mode (I still can't tell if I need to switch to it, my first instinct is that I don't), how a computer boots, reading from the keyboard and printing to screen.

I can write in assembly and pass it gcc to write small programs, I just need the booting and interfacing information. Any info is appreciated, including books.

最满意答案

我会推荐这个网站。 你会发现那里(特别是在“简介”类别中)你需要知道的一切。

除非您切换到保护模式,否则您可以使用BIOS中断来打印到屏幕,从键盘读取等。例如, 中断0x10,功能0x0e 。 如果要使用其他程序,除了引导加载程序之外,您还需要手动将其加载到内存中。 有用于从硬盘(或模拟硬盘的pendrive)读取的BIOS功能,但您必须自己处理文件系统。 也许,在您的情况下,最好的解决方案是不使用任何解决方案,只需要在固定地址写入额外的程序,并使引导加载程序从该硬编码位置加载它。

此外,如果要在实模式下执行使用gcc编译的代码,则需要使用.code16gcc指令。 它将使气体生成代码能够在32位机器上以16位实模式执行。

I would recommend this website. You will find there (especially in the category "Introduction") everything you need to know.

Unless you swith to protected mode you can use BIOS interrupts in order to print to screen, read from keyboard, etc. For example interrupt 0x10, function 0x0e. If you want to use another program, apart from the bootloader, you will need to load it to memory manually. There are BIOS functions for reading from a hard disk (or a pendrive that emulates a hard disk), but you will have to handle filesystem yourself. Probably, in your case, the best solution will be not to use any and just have that additional program written at fixed address and make bootloader load it from that hardcoded position.

Moreover, if you want to execute code compiled with gcc in real mode you need to use .code16gcc directive. It will make gas genereate code able to be executed in 16 bit real mode on 32 bit machines.

更多推荐

本文发布于:2023-08-08 00:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466659.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   加载   高级   指南   Advanced

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!