简体   繁体   中英

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. 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?

Note: I'd like to try and do it all straight from FreeDOS if possible. I tried using the EDIT command but it errors out and I'm pretty sure I'm missing something.

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. You will have to rewrite that to actual assembly code or copy the macros and assembler you want to use to your freedos environment.

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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