英文:
Interrupt 10h 0x4F05 in assembly: Why does the operation fail?
问题
mov ax, 0x4F05
xor bh, bh
mov dx, 1022
int 0x10
当我调用int 10h的功能4F05h时,这个显示一个操作错误。
ah为1,根据文档意味着发生了错误。
我激活了视频模式:8107h,使用了4F02。
我不明白为什么会出错。
我尝试过改变dx的值或改变视频模式,尝试其他的,也在谷歌上搜索了但没有明确的答案。
<details>
<summary>英文:</summary>
mov ax, 0x4F05
xor bh, bh
mov dx, 1022
int 0x10
When I call function 4F05h of int 10h, this one reveals an error in the operation.
ah is 1 which means there is an error according to the documentation
I activated the video mode: 8107h with 4F02
I don't understand why it gives me an error
I tried to change the value of dx or change the video mode, put another one, I also searched on google but nothing conclusive
</details>
# 答案1
**得分**: 4
首先;有两个显示窗口,你需要告诉它你要改变哪个窗口。通过将 `bl` 设置为 0("窗口 A")或 1("窗口 B")来实现。
注意 1:Ralph Brown 的中断列表是错误的 - 它说 `bl` 是一个输出参数,但它实际上是一个输入参数。请使用(适当版本的)实际 VBE 规范作为参考。
其次;不同的视频卡有不同的窗口粒度,但通常是 64 KiB。`dx` 中的值以“窗口粒度单位”表示;这意味着你的 `mov dx,1022` 可能是“将窗口设置为从字节偏移 `1022*64*1024 = 66977792` 开始的位置在视频内存中”。这需要在帧缓冲区的某处;假设(见注意 2)你正在使用“1280 x 1024,8 位索引颜色”,则 `dx` 的最大合理值为 `(1280*1024*1 - 1) / window_granularity`,或者对于 64 KiB 窗口粒度,`dx` 的最高值将是 19(允许访问帧缓冲区中偏移量从 0x130000 到 0x13FFFF 的位置,偏移量为 0x13FFFF 的字节是帧缓冲区中存在的最后一个字节)。
注意 2:VBE 标准早期版本中的固定模式编号在 VBE 2.0 中已被弃用(1994 年),因此“模式 0x107” 理论上可能是任何视频模式。
当然,所有这些意味着(对于稍微可移植的代码),你不能只是对任何值使用硬编码的值。你必须搜索你想要的模式(使用函数 0 中的模式编号列表和函数 1 中每个模式的详细信息),并且你必须使用从函数 1 获取的视频模式信息数据结构中的“WinGranularity”字段来计算 `dx` 的值。
<details>
<summary>英文:</summary>
First; there are 2 display windows and you need to tell it which window you're changing. This is done by setting `bl` to either 0 ("window A") or 1 ("window B").
Note 1: Ralph Brown's Interrupt List is wrong - it says `bl` is an output parameter when it's an input parameter. Use (the appropriate version of) the actual VBE spec as a reference.
Second; different video cards have different window granularity, but it's often 64 KiB. The value in `dx` is in "units of window granularity"; which means your `mov dx,1022` is possibly like "set the window to start at byte offset `1022*64*1024 = 66977792` in video memory". This needs to be somewhere in the frame buffer; and assuming (see note 2) you're using "1280 x 1024 with 8-bit indexed color" the maximum sane value for `dx` would be `(1280*1024*1 - 1) / window_granularity`, or, with 64 KiB window granularity the highest value for `dx` would be 19 (giving access to offsets from 0x130000 to 0x13FFFF in the frame buffer, with the byte at offset 0x13FFFF being the last byte that exists in the frame buffer).
Note 2: The fixed mode numbers from early versions of the VBE standard were deprecated in VBE 2.0 (in 1994), so "mode 0x107" could (in theory) be any video mode.
Of course all of this means that (for slightly portable code) you can't just use hard-coded values for anything. You have to search for the mode you want (using the list of mode numbers from Function 0 and the details of each mode from Function 1), and you have to use the "WinGranularity" field from the video mode info data structure obtained from Function 1 to calculate values for `dx`.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论