DosBox 启动 MBR,dl 中的错误值用于 int 13h

如何解决DosBox 启动 MBR,dl 中的错误值用于 int 13h

我有一个自定义 MBR,我用 NASM 将其编译为二进制文件,我可以在 qemu 和 bochs 中正常启动它。

我正在尝试使用 boot mbr.bin 在 DosBox 中启动此 MBR。只要 MBR 很小并且不调用 int 13h 来从磁盘读取扇区,这就能正常工作。

如果我尝试读取下一个扇区,它会失败,从而导致某种磁盘读取错误。我想这与 dl 的值没有设置为“启动驱动器”有关。我尝试将 dl 手动设置为 0 和 80h,但都不起作用。

有谁知道 dl 的值应该是什么,以便使用 int 13h 命令使 boot 在 DosBox 中工作?或者是否有其他方法可以动态获取该值?

编辑;这是初始代码:

CPU 386
BITS 16
org 7C00h

; Calculate the full size of the code from start of segment $$ to the end label at the bottom (end - $$)
%define SECTORS_TO_LOAD ((end - $$) / 512) + ((end - $$) % 512 > 0) - 1

main:
    jmp 0x0000:setcs
    ; Some error messages
    disk_err db "Error reading disk",0
    sector_err db "Error reading sector",0

setcs:
    ; Base setup

    cld

    xor ax,ax      ; Set ES=DS=0 - this can be changed later for rep operations
    mov ds,ax
    mov es,ax

    mov ss,ax
    mov sp,0x7c00

    ; Clear the screen
    mov ah,0x07    ; Function 0x07: scroll window
    mov al,0x00    ; Clear entire window
    mov bh,0x07    ; White on black
    mov cx,0x00    ; Specifies top left of screen as (0,0)
    mov dh,0x18    ; 18h = 24 rows of chars
    mov dl,0x4f    ; 4fh = 79 cols of chars
    int 0x10    ; Video interrupt


    ; Move cursor to position 0,0
    mov ah,0x02    ; Function 0x02: set cursor position
    mov dh,0x00    ; Row 0
    mov dl,0x00    ; Col 0
    mov bh,0x00    ; Page 0
    int 0x10    ; Video interrupt


    ; Load the calculated numbers of sector from the disk
    ; For this function call,dl should be set to the disk number to read from. The BIOS sets dl to
    ; the disk number of the MBR and dl was not changed,so we don't have to set it.

    ;mov dl,0x80

    mov ax,SECTORS_TO_LOAD ; Number of sectors to read
    mov bx,next_sector ; The memory address to read to
    xor ch,ch      ; Cylinder 0
    mov cl,0x02        ; Start at sector 2 (sector 1 is the first part of the MBR)
    xor dh,dh      ; Head 0
    mov ah,0x02        ; Read mode

    int 0x13        ; Read interrupt
    jc .disk_error      ; Check carry bit for error

    cmp al,SECTORS_TO_LOAD ; The interrupt sets 'al' to the number of sectors actually read
    jne .sectors_error

    ; After a succesful load,the layout in memory will be the same as the layout in our ASM files,; so we can jump to a defined label without worrying about offsets and exact addresses.
    jmp after_load

.disk_error:
    push disk_err   ; Print a disk error message
    call print
    cli     ; Halt all interrupts and operations
    hlt

.sectors_error:
    push sector_err ; Same as above,different message
    call print
    cli
    hlt


; The print function prints a string onto the screen in text mode
print:
    push bp     ; Basic stack setup
    mov bp,sp
    pusha       ; Push everything - this function doesn't
            ; return anything

    mov si,[bp+4]  ; Grab the pointer to the data
    mov bh,0   ; Page 0
    mov bl,0   ; Foreground color,irrelevant - in text mode
    mov ah,0x0E    ; Function 0x0E: print character in TTY
.char:
    mov al,[si]    ; Get current char from pointer position
    inc si      ; Keep incrementing si until a null char
    or al,0
    je .return
    int 0x10    ; Video interrupt
    jmp .char
.return:
    popa        ; Restore registers
    mov sp,bp  ; Restore stack
    pop bp
    ret 2       ; Remove param from stack on return

times 510-($-$$) db 0

; MBR signature
db 55h,0AAh

next_sector:

之后,在 next_sector 下,它有一些 incbins 和一些其他代码,包括标签 after_load

我得到的错误是第一个; “读取磁盘时出错”,显示正常。这样看来es,ds等都设置对了。

注意注释掉的 mov dl,0x80 - 这是我尝试让它工作的尝试之一。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)> insert overwrite table dwd_trade_cart_add_inc > select data.id, > data.user_id, > data.course_id, > date_format(
错误1 hive (edu)> insert into huanhuan values(1,'haoge'); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive> show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 <configuration> <property> <name>yarn.nodemanager.res