当前位置:首页 > 芯闻号 > 充电吧
[导读]The following code is the smallest possible example of booting code from a floppy.; boot.asm hang:  

The following code is the smallest possible example of booting code from a floppy.

; boot.asm
hang:
    jmp hang
 
    times 512-($-$$) db 0

The CPU starts in real mode and the BIOS loads this code at address 0000:7c00. The "times 512..." stuff is NASM's way of saying fill up 512 bytes with zeros. And partcopy is going to expect that (200 in Hex = 512 in Decimal). Change it and you'll see Partcopy choke.

Often, you will see a so-called boot signature (0xAA55) at the end. Older versions of BIOSes looked for this in order to identify a boot sector on a disk. It is evidently unnecessary nowadays. If it's needed, the last line would be replaced with (or some version of it)

; boot.asm
hang:
    jmp hang
 
    times 510-($-$$) db 0 ; 2 bytes less now
    db 0x55
    db 0xAA

But the thing I'd really like to point out is how once you've booted, and the cursor is happily blinking on a blank screen, you might notice two things. One is that the floppy motor will turn off and the other is that you can press Ctrl-Alt-Del to reboot. The point is that interrupts (such as INT 0x09) as still being generated.

For kicks try clearing the interrupts flag:

;boot.asm
     cli
 hang:
     jmp hang
 
     times 510-($-$$) db 0
     db 0x55
     db 0xAA

You may notice that the floppy motor doesn't turn off and you can't reboot with Ctrl-Alt-Del.

If you try to reduce this even more by removing the loop and merely pad out the sector with zeros, the BIOS will have something to say about it. On my machine, it was "Operating System Not Found". I have yet to try filling the sector with zeros except for adding a boot signature.

Not exactly something you would show your girlfriend, but I wanted to show just what the bare minimum is before I elaborate. Unless I'm irritating anyone, in which case I'll desist.

Creating disk image

The code is assembled in NASM and copied to floppy using partcopy,dd,or debug. Then you simply boot from the floppy.

Windows

nasmw boot.asm -f bin -o boot.bin
partcopy boot.bin 0 200 -f0 
OR
debug boot.bin
-W 100 0 0 1
-Q

Unix

nasm boot.asm -f bin -o boot.bin
dd if=boot.bin of=/dev/fd0
本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
换一批
延伸阅读

Windows Embedded Compact 7(简称WinCE)是一种专为嵌入式系统设计的操作系统,具有体积小、效率高、可定制性强的特点。在WinCE中设置自动运行软件,通常是为了满足设备在启动后自动执行特定任务的...

关键字: 嵌入式系统 软件 操作系统

今天,小编将在这篇文章中为大家带来Windows 11系统的有关报道,通过阅读这篇文章,大家可以对Windows 11系统具备清晰的认识,主要内容如下。

关键字: Windows 操作系统

全新随插即用方案简化虚拟化实时IIoT平台的设置

关键字: 计算机模块 IIoT 操作系统

目前,HarmonyOS NEXT星河预览版已经正式面向开发者开放申请,面向鸿蒙原生应用及元服务开发者提供的集成开发环境——DevEco Studio也迎来功能更细化的4.1版本。

关键字: HarmonyOS 操作系统

华为P40是一款备受关注的高端智能手机,搭载了华为自研的鸿蒙操作系统。鸿蒙系统作为华为自主研发的操作系统,具有高度的可定制性和扩展性,能够为用户带来全新的使用体验。本文将详细介绍华为P40鸿蒙系统的升级方法,帮助用户更好...

关键字: 华为P40 智能手机 操作系统

安装Linux操作系统并不复杂,下面是一个大致的步骤指南,以帮助您完成安装。1. 下载Linux发行版:首先,您需要从Linux发行版官方网站下载最新的ISO镜像文件。

关键字: Linux 操作系统 ISO镜像

计算机是由一堆硬件组成的,为了有限的控制这些硬件资源,于是就有了操作系统的产生,操作系统是软件子系统的一部分,是硬件基础上的第一层软件。

关键字: Linux 操作系统 计算机

Linux操作系统是一套免费使用和自由传播的类Unix操作系统,通常被称为GNU/Linux。它是由林纳斯·托瓦兹在1991年首次发布的,并基于POSIX和UNIX的多用户、多任务、支持多线程和多CPU的操作系统。Lin...

关键字: Linux 操作系统

华为鸿蒙系统作为华为推出的全新一代操作系统,自发布以来备受关注。本文将对华为鸿蒙系统的实际体验进行详细评测,旨在帮助读者了解该系统的优缺点。

关键字: 华为 鸿蒙系统 操作系统

随着华为鸿蒙OS系统的发布,越来越多的人开始关注这一全新的操作系统。鸿蒙OS系统的界面设计作为用户体验的重要组成部分,也备受关注。本文将详细介绍鸿蒙操作系统界面的设计理念、特点以及与其他系统的对比。

关键字: 华为鸿蒙 操作系统 界面设计
关闭
关闭