- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 x86 程序集中创建一个简单的命令系统。命令系统是第二阶段,加载于0x1000:0000。要查看我的引导加载程序,请单击 on this stackoverflow question .
这是第二阶段的命令系统:
[BITS 16]
[ORG 0x0000]
mov ax, cs
mov ds, ax
xor cx, cx
mov bx, welcome_msg
call str_prt
call new_line
mov bx, creator_msg
call str_prt
call new_line
mov bx, boot_msg
call str_prt
call new_line
mov bx, [buffer]
call new_line
mov ah, 0x0e
mov al, 0x0a
int 0x10
mov al, 0x0d
int 0x10
mov al, '>'
int 0x10
loop:
in al, 64h
test al, 1
je loop
xor ah, ah
int 0x16
call key_scan
jmp loop
key_scan:
cmp al, 0x08
je back_space
cmp al, 0x0d
je enter
cmp cx, 0x0015
je end
mov ah, 0x0e
int 0x10
mov bx, buffer
add bx, cx
mov [bx], al
inc cx
jmp end
back_space:
cmp cx, 0x00
je end
dec cx
mov ah, 0x0e
mov al, 0x08
int 0x10
mov al, 0x20
int 0x10
mov al, 0x08
int 0x10
jmp end
enter:
xor cx, cx
mov ah, 0x0e
mov al, 0x0a
int 0x10
mov al, 0x0d
int 0x10
call pro_com
call clear_buffer
mov ah, 0x0e
mov al, '>'
int 0x10
end:
ret
str_prt:
pusha
str:
mov ah, 0x0e
mov al, [bx]
cmp al, '$'
je str_end
int 0x10
add bx, 1
jmp str
str_end:
popa
ret
new_line:
push ax
mov ah, 0x0e
mov al, 0x0a
int 0x10
mov al, 0x0d
int 0x10
pop ax
ret
clear_buffer:
push ax
push bx
push cx
mov bx, buffer
xor cx, cx
xor ax, ax
start:
cmp cx, 0x41
je end_buff
mov [bx], ax
inc bx
inc cx
jmp start
end_buff:
pop cx
pop bx
pop ax
ret
pro_com:
push bx
push ax
mov bx, buffer
mov al, [bx]
cmp al, 'h'
jne help_end
inc bx
mov al, [bx]
cmp al, 'e'
jne help_end
inc bx
mov al, [bx]
cmp al, 'l'
jne help_end
inc bx
mov al, [bx]
cmp al, 'p'
jne help_end
call com_help
jmp pro_end
help_end:
mov bx, buffer
mov al, [bx]
cmp al, 'd'
jne dir_end
inc bx
mov al, [bx]
cmp al, 'i'
jne dir_end
inc bx
mov al, [bx]
cmp al, 'r'
jne dir_end
call com_dir
jmp pro_end
dir_end:
mov bx, not_found
call str_prt
call new_line
pro_end:
pop ax
pop bx
ret
com_help:
push bx
call new_line
mov bx, help1_msg
call str_prt
call new_line
call new_line
pop bx
ret
com_dir:
push ax
push bx
push cx
push dx
mov bx, drive_num
mov dl, [bx]
mov cl, 0x09
mov al, 0x01
mov ch, 0x00
mov cl, 0x09
mov dh, 0x00
com_dir_loop:
call read_dir
cmp cl, 0x12
je false1
inc cx
jmp com_dir_loop
false1:
pop dx
pop cx
pop bx
pop ax
ret
read_dir:
push ax
push bx
mov bx, 0x1000
mov es, bx
mov bx, 0xe00
call read_disc
clc
mov bx, 0x0e00
mov al, [bx]
cmp al, 'F'
jne read_dir_end
;print file name
mov bx, 0x0e01
call str_prt
call new_line
;----
read_dir_end:
pop bx
pop ax
mov bx, 0x1000
mov es, bx
ret
read_disc:
mov ah, 0x02
int 0x13
ret
buffer times 20 db 0
drive_num:
db 0
welcome_msg:
db 'Welcome to matriXos$'
creator_msg:
db 'Created by Vishnu Shankar.B$'
boot_msg:
db 'Booting command line interface...$'
not_found:
db 'Command cannot be resolved!$'
help1_msg:
db 'Help not avilable!$'
jmp $
times 3584 - ($ - $$) db 0
命令“dir”(com_dir)应该读取并打印以字母“F”开头的字符串,该字符串放在每个扇区 9 - 18(磁道 0)(CHS)的开头。我已在十六进制编辑器的帮助下将字符串放置到位。
我将代码转换为图像文件。它在 Bochs 模拟器中工作正常,但是当我将镜像文件刻录到闪存驱动器上并在计算机中启动它时,它会打印垃圾。
有人可以告诉我出了什么问题吗?
提前致谢。
最佳答案
在我的previous answer ,我碰巧删除了引导加载程序中将 DL 设置为零的行。您的引导加载程序执行了以下操作:
mov dl,0x0 ;Drive = 0 (Floppy)
这需要删除。我现在在之前的回答中通过以下评论给出了这样做的原因:
This hard codes the boot drive to the Floppy A:. If you boot off of USB, hard drive, or Floppy B: your code won't work because the drive number likely won't be zero in those cases. The BIOS passes the actual boot drive that was used to load your bootloader. That value is in the register DL. This is the value you should be using for BIOS disk functions. Since DL already contains the boot drive, we just use it as-is.
重用DL中传递给引导加载程序的值以进行驱动器读写,同时也将此值传递给第二阶段!由于引导加载程序实际上不会破坏 DL 的内容,因此您只需将 DL 移动到 drive_num 变量中即可。您可以在第二阶段设置 DS 寄存器后立即执行此操作,如下所示:
[BITS 16]
[ORG 0x0000]
mov ax, cs
mov ds, ax
mov [drive_num], dl ; drive_num = the boot drive the BIOS booted from
如果您修改了引导加载程序,导致其破坏了DX或DL寄存器的内容,那么您应该考虑在引导加载程序启动后将其推送到堆栈上,并且然后在跳转到第二阶段之前将其弹出(恢复)。
在我在上一个答案中向您展示的引导加载程序中,我是这样启动的:
xor ax, ax
mov ds, ax ; DS=0
cli ; Turn off interrupts for SS:SP update
; to avoid a problem with buggy 8088 CPUs
mov ss, ax ; SS = 0x0000
mov sp, 0x7c00 ; SP = 0x7c00
; We'll set the stack starting just below
; where the bootloader is at 0x0:0x7c00. The
; stack can be placed anywhere in usable and
; unused RAM.
sti ; Turn interrupts back on
设置堆栈后,我们可以通过执行以下操作保存DX寄存器:
xor ax, ax
mov ds, ax ; DS=0
cli ; Turn off interrupts for SS:SP update
; to avoid a problem with buggy 8088 CPUs
mov ss, ax ; SS = 0x0000
mov sp, 0x7c00 ; SP = 0x7c00
; We'll set the stack starting just below
; where the bootloader is at 0x0:0x7c00. The
; stack can be placed anywhere in usable and
; unused RAM.
sti ; Turn interrupts back on
push dx ; Save DX register (which includes DL) on stack
现在它已被保存,我们可以在跳转到第二阶段之前恢复它的值。这段代码:
jmp 0x1000:0000 ; Jump to 0x1000, start of second stage
现在会这样做:
pop dx ; Restore DX register (which includes DL)
jmp 0x1000:0000 ; Jump to 0x1000, start of second stage
这有效地将DL(引导驱动器)传递到我们的第二阶段,即使我们可能在执行引导加载程序期间破坏其内容。然后,我们的第二阶段能够重用该值来执行自己的 BIOS 磁盘读写操作。
关于assembly - INT 0x13/AH = 0x02 适用于软盘镜像,但不适用于在闪存驱动器上刻录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34202607/
前言:这个问题是关于我正在与我的大学教授合作的一个项目。这不是为了成绩,但我在这位教授中的声誉确实很重要。因此,虽然我在这个项目上的成功对我来说很重要,但我并不认为向 Stack Overflow 寻
因此,与上一次相同的大学项目,这一次我遇到了未定义方法的麻烦。我的代码的完整性如下 package { import flash.display.MovieClip; import flash.eve
我只是想问问这是不是一个熟悉的现象。我们有一个带有文本框的小型 Flash 应用程序。 在 OSX Lion 下,flash < 10.3 .. 工作正常 使用 OSX Lion 和 Flash 10
对于某些人来说,这个问题可能很微不足道,但我不记得哪个是正确的名字对于这款闪光灯 slider ,其产品来自 here 原来的名字不是slider而是别的东西... 第二个问题:你知道像这样免费的fl
我目前正在使用 flash CS5 构建一个 iOS 应用程序,我需要一些关于几个功能的帮助: 是否可以添加应用内购买?如果是,它是如何工作的? 是否可以在应用程序中添加 iAd 广告?如果是这样,如
有没有什么简单的方法可以从 Flash IDE 中获取路径(一系列点)到 ActionScript 代码中? 例如,如果您想为要用作碰撞对象的游戏世界绘制轮廓,而现在在 AS3 中,您希望获得所绘制路
我有一个 Beagle 板 OMAP3530-GP,我已将内核和 rootfs 复制到 SD 卡的两个分区中并想启动它。 SD卡分区1:FAT32启动分区 具有相同顺序的以下文件: MLO u-boo
大学毕业后,我终于有时间回去练习我的 Flash 工作了,我需要一些帮助来让声音循环播放并根据正在播放的动画部分进行更改。 这也是我问的一个老问题的部分后续问题,所以如果你不明白,请看这里以获得更多关
我的问题是我的项目编译时间越来越长。 我的当务之急是如何加快编译速度?我现在用的是SSD硬盘和四核CPU。您认为购买 I7 核心会加快编译速度吗? 我担心它不会,因为 Flash CS5 不会利用多核
我尝试获取 mp3 flash player在所有浏览器上使用我的 javascript。一开始一切顺利,但很快意识到我的代码不适用于 MSIE。 在尝试找出后,我在引用代码中找到了这个: eva
我有 3 个问题来阐明我的 AIR 应用程序工作流程: 我在使用 Flash CS5 制作游戏时可以使用 Spark 组件吗? 当我使用 Flash Builder 时,我可以在我的 AIR for
我正在使用 YQL 尝试为我正在进行的项目查找乐队照片。如果找到图像,它会在 XML 响应中返回,然后我的 Flash 代码将其发布。但是如果没有找到,我不太确定如何告诉 Flash 不做任何事情。这
我从 Rails 3.2 升级到 4.0,现在重定向后我的 flash 消息都不起作用。 我检查过以确保我显示 Flash 消息的方式没有问题。不涉及重定向的 Flash 消息工作正常。 sessio
几个月来我一直试图解决这个问题...... 在 Flash 9 中,我尝试加载流式 MP3 文件并计算其轨道长度。我可以做到这一点,但是当 mp3 的 channel 是单声道时,时间是原始音轨长度的
我有这个代码: def create login(params[:email], params[:password]) if current_user flash[:notice] =
我正在尝试在Windows 7上使用JTAG ST-Link/V2写入STM32L476的闪存。无需上传软件,我只需将数据写入可读取和删除的非 volatile 位置。 作为一个硬件方面的新手,并且仅
当我尝试通过 fastboot system.img(从我的自定义 AOSP 构建)刷入 Sony Xperia Z3 时,出现以下错误: # fastboot flash system system
我正在内存非常受限的嵌入式 Linux 设备上通过 HTTP 将一个大文件 ( 1Gb ) 流式传输到我在 Qt 中的服务器。当我第一次收到 header 时,我确定将数据写入文件系统的何处,创建一个
我使用 Play 创建了一个 HTTP 实时流传输系统!框架和 FFMPEG。文件在不同的带宽上进行编码,并随后进行分段以传送到当前的 iOS 设备。 但是,我想扩展到网站上的嵌入式播放器(跨平台)和
我在 AS3 中有一个可用的麦克风录音脚本,我已经能够成功地使用它通过 AMF 将 .wav 文件保存到服务器。这些文件可以在任何音频播放器中正常播放,没有奇怪的效果。 作为引用,这是我为捕获麦克风的
我是一名优秀的程序员,十分优秀!