x86 asm 图形设置的分辨率高于 640x480?

发布于 2024-08-04 07:53:18 字数 745 浏览 5 评论 0原文

我刚刚开始使用汇编语言(感觉像学习新东西),并且遇到了一些问题(到目前为止),我一直在浏览的所有教程都没有回答,或者太旧而无法知道。

1)我尝试了一些搜索(也许我只是不知道正确的关键字),但我找不到用于更改屏幕分辨率等的图形模式的更新列表。我发现的最好的是:< a href="http://www.skynet.ie/~darkstar/assembler/tut6.html" rel="nofollow noreferrer">汇编器教程,我几乎不认为 640x480 是最佳分辨率的汇编语言可以使用。 有人知道我可以使用更新的教程吗?

编辑:中断 10h 很旧,并且不太支持超过 640x480

2) 是否可以“mov” “从一个变量到另一个变量的值而不先将其移动到寄存器?示例:

jmp start
  n1     dw 0
  n2     dw 0
  res    dw 0
start:
  mov n1,5
  mov n2,6
  mov res,n1
  add res,n2
...etc...

编辑:这是不可能的。如果不使用寄存器,就无法从一个内存转到另一个内存。

3)针对问题 1,有没有办法检测用户当前使用的图形模式,以便我可以更改它,然后再将其更改回来? (我假设有,但我不确定如何做到这一点。)

编辑:需要查询操作系统的图形设置。

I've just started using assembly language (felt like learning something new), and have run into a few questions (so far) that all the tutorials I've been looking through don't answer, or are too old to know.

1) I've tried a few searches (maybe I just don't know the right keywords), but I can't find an updated list of graphics modes for changing screen resolutions, etc. The best I've found is: Assembler Tutorial, and I'd hardly think that 640x480 is the best resolution assembly language can use. Does anyone know of a more updated tutorial I can use?

Edit: Interrupt 10h is old, and doesn't quite support more than 640x480

2) Is it possible to "mov" a value from a variable to another variable without moving it to a register first? Example:

jmp start
  n1     dw 0
  n2     dw 0
  res    dw 0
start:
  mov n1,5
  mov n2,6
  mov res,n1
  add res,n2
...etc...

Edit: It is not possible. You cannot go from memory to memory without using registers.

3) Going with question 1, is there a way to detect what graphics mode a user is currently using, so that I can change it, and change it back after? (I assume there is, but am not sure how to do it.)

Edit: Need to query OS for graphics settings.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蹲在坟头点根烟 2024-08-11 07:53:18

对于问题#1 和#3,请查看VESA BIOS 扩展。这是处理 90 年代流行的“Super VGA”模式的标准。

至于#2,一般来说答案是否定的,你不能将内存移动到内存。但这并不完全正确:有 MOVS(移动字符串),它将字节、字或双字从 DS:SI 移动到 ES:DI。通常该指令与 REP 前缀结合使用来移动内存块。另外,假设您设置了堆栈,您可以通过压入和弹出来在内存之间移动,而不会破坏寄存器:

PUSH [mem1]
POP  [mem2]

For questions #1 and #3, look into the VESA BIOS Extensions. This was something of a standard for dealing with "Super VGA" modes, popular in the 90s.

As for #2, in general the answer is no, you can't MOV memory to memory. But it's not strictly true: there is MOVS (move string), which moves a byte, word, or dword from DS:SI to ES:DI. Usually this instruction is used in conjunction with a REP prefix to move blocks of memory. Also, assuming you have a stack set up, you can move memory-to-memory without clobbering a register by pushing and popping:

PUSH [mem1]
POP  [mem2]
沙与沫 2024-08-11 07:53:18

关于您的第一个问题,中断 10 非常古老,并且可能不会在 640x480 分辨率之外使用。现在使用软件堆栈的不同部分;即,您必须询问 Windows 才能获取当前的屏幕分辨率。

Regarding your first question, interrupt 10 is very old, and likely not used beyond resolutions of 640x480. A different part of the software stack is now used; i.e., you would have to interrogate Windows to get the current screen resolution.

帅的被狗咬 2024-08-11 07:53:18

这篇相当冗长的文章包含大量关于如何在 Windows 中使用汇编程序驱动 DirectX 的详细信息。 DirectX 是当今图形的关键 API 系列,使用 DOS 时代的中断并直接对 VGA 帧缓冲区进行编程不会有太大帮助。

This rather verbose post contains a lot of details of how to use assembler to drive DirectX in Windows. DirectX is the key API family for graphics these days, you won't come far using DOS-era interrupts and programming the VGA framebuffer directly.

温柔一刀 2024-08-11 07:53:18

中断10h基本上是一个操作系统函数调用(实际上它运行BIOS代码)。在内部,它读取/写入视频内存以及显卡上的各种寄存器。要了解中断 10 小时“内”发生了哪些事情,请检查此 出来。

当您在Windows下运行DOS程序时,它是在虚拟DOS机中运行的。 Windows 实际上并不让它接触显卡,而是让它使用虚拟显卡。通常这仅扩展到 VGA 屏幕模式(有时仅是文本模式),即您拥有的是虚拟 VGA 卡(不是现代显卡)。因此,在 Windows 下的 16 位汇编语言中,您无法使用现代显卡的全部功能。

是的,当然,汇编语言可以让你做显卡能做的任何事情。但前提是:

  • 您的程序可以不受限制地访问图形硬件(例如,您正在编写 Windows 或 Linux 设备驱动程序,或者在纯 DOS 或您自己的内核中执行),或者
  • 您的程序通过适当的操作系统接口。

如果您仍然对汇编语言感兴趣,我建议您尝试编写一个玩具内核。这样做,你会学到很多东西。

如果您想了解更多信息,请发表评论。

Interrupt 10h is basically an operating system function call (actually it runs BIOS code). Internally, it reads/writes video memory as well as various registers on the graphics card. To get an idea of what sort of stuff happens "within" interrupt 10h, check this out.

When you run a DOS program under Windows, it is run in a virtual DOS machine. Windows doesn't actually let it touch the graphics card but lets it play with a virtual one. Usually this only extends as far as VGA screen modes (and sometimes only text mode), i.e. what you have is a virtual VGA card (not a modern graphics card). For this reason, in 16-bit assembly language under Windows, you just can't use the full capabilities of modern graphics cards.

Yes, sure, assembly language can let you do anything the graphics card can do. But only if either:

  • your program has unrestricted access to the graphics hardware (e.g. you're writing a Windows or Linux device driver, or are executing in pure DOS, or your own kernel), or
  • your program goes through the appropriate operating system interface.

If you're still interested in assembly language, I would suggest you try to write a toy kernel. Doing this, you'll learn a mountain of things.

Leave a comment if you want further information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文