简体   繁体   English

如何在FreeDOS中编写内联汇编

[英]How to write inline assembly in FreeDOS

I'm trying to write the following program to dump the interrupt vector table using FreeDOS in a virtual machine. 我正在尝试编写以下程序,以在虚拟机使用FreeDOS转储中断向量表 I know that DEBUG will allow me to write an assembly program, but how do I create the following IVTDUMP.COM file, save it and run it? 我知道DEBUG允许我编写汇编程序,但是如何创建以下IVTDUMP.COM文件,保存并运行它?

Note: I'd like to try and do it all straight from FreeDOS if possible. 注意:如果可能的话,我想直接从FreeDOS尝试全部操作。 I tried using the EDIT command but it errors out and I'm pretty sure I'm missing something. 我尝试使用EDIT命令,但出现错误,并且我很确定自己缺少某些内容。

for 
( 
   address=IDT_255_ADDR;
   address>=IDT_001_ADDR;
   address=address-IDT_VECTOR_SZ,vector--
)
{
   printf("%03d   %08p   ",vector,address);

   __asm
  {
     PUSH ES
     MOV AX,0
     MOV ES,AX
     MOV BX,address
     MOV AX,ES:[BX]
     MOV ipAddr,AX
     INC BX
     INC BX
     MOV AX,ES:[BX]
     MOV csAddr,AX
     POP ES
   };
   printf("[CS:IP]=[%04X,%04X]\n",csAddr,ipAddr);
}

Things like for, address and printf are not part of assembly. 诸如for,address和printf之类的内容不是程序集的一部分。 You will have to rewrite that to actual assembly code or copy the macros and assembler you want to use to your freedos environment. 您将不得不将其重写为实际的汇编代码,或者将要使用的宏和汇编器复制到freedos环境中。

If you want to use debug as included in freedos you can use the a command to start writing assembly instructions, the n command to give a name and w to write the code to the file. 如果要使用freedos中包含的debug,则可以使用a命令开始编写汇编指令,使用n命令指定名称,使用w将代码写入文件。

C:\debug
-a
06BC:0100 int 20
06BC:0102
-n ivtdump.com
-rcx 2
-w
Writing 0002 bytes.
-q

C:\

This sample program only exits the program through int 20. (The 2 after rcx indicates the length of the program to write to disk) 此示例程序仅通过int 20退出程序。(rcx后的2表示要写入磁盘的程序的长度)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM