x86 - 汇编程序 : Using "Flat assembler" how do I produce EXE files (compile, 链接..)?

标签 x86 assembly fasm

我正在使用 FASM 编译一小段代码:

  mov ah,4ch
  mov al,00
  int 21h 

我点击运行 -> 编译,我得到的是一个 .BIN 文件。 抱歉,我问的是白痴问题,但为什么我没有得到 OBJ 或 EXE 文件,这个 BIN 是什么?

最佳答案

BIN 是一个二进制文件,您需要检查用于传递给 FASM 的命令行选项。根据documentation默认格式是平面二进制文件。引用文档第 2.4 节:

Default output format is a flat binary file, it can also be selected by using 
format binary directive. This directive can be followed by the as keyword and 
the quoted string specifying the default file extension for the output file. 
Unless the output file name was specified from the command line, assembler will
use this extension when generating the output file.

所以我认为你的代码应该是这样的:

.use32
.format pe console
mov ah,4ch
mov al,00
int 21h 

编辑:我在点击保存后才意识到,它使用了 16 位寄存器...

.use16
.format MZ
mov ah,4ch
mov al,00
int 21h

关于x86 - 汇编程序 : Using "Flat assembler" how do I produce EXE files (compile, 链接..)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2302695/

相关文章:

assembly - x86_64 指令流水线 : Instruction execution order

windows - masm FPU 到 fasm FPU 无​​法转换并且不起作用

x86 - 如何读取Intel处理器的PMC(性能监控计数器)?

assembly - x86 中的 IN 和 OUT 指令有何用途?

c++ - g++ 转储程序集输出不起作用

linux - 如何将字符串数组作为参数传递给函数?

delphi - FASM - 将字符串传递给 Delphi DLL

assembly - 为什么我的数据部分在编译后的二进制文件中出现两次? Ubuntu、x86、nasm、gdb、reaelf

assembly - 为什么 `add cl, 2` 以 x86 十六进制打印 `80 c1 02`?

assembly - 软件中断VS系统调用