【问题标题】:dos assembly can't write filedos程序集无法写入文件
【发布时间】:2013-01-11 02:41:32
【问题描述】:

我写了一个 16 位的 .com 文件来创建一个文件

但它不会创建任何文件。

我在 Windows 7 32 位上试过。在dosbox里面。

源代码在这里

如何写入文件?

org 100h

        call open_new_file
        mov ah, 40h;write
        mov bx, [new_file_handle]
        mov cx,2;write 2 bytes
        mov dx, temp
        int 21h

        mov ah, 3eh;close file
        mov bx, [new_file_handle]
        int 21h

        mov ah, 00
        int 16h;wait key

        mov ax, 4c00h
        int 21h;exit

open_new_file:
        push bp
        mov bp, sp
        mov ah, 3dh;open file
        mov al, 02h;write only
        mov dx, new_file_name ;out.kty
        int 21h
        mov [new_file_handle], ax
        leave
        ret


temp:
        dw 0xffaa

new_file_handle:
        dw 0
new_file_name:
        db "out.bin", 0

谢谢!

【问题讨论】:

    标签: assembly dos createfile dosbox


    【解决方案1】:

    看起来int 21, 3D 是“打开文件”。你的意思是int 21, 3C 是“创建还是截断”?

    如果您检查了返回值,您可能会看到 CF=1 指示错误。我猜AX 会是... 2?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-11
      • 2013-08-06
      • 2013-03-07
      • 2016-12-10
      • 2015-07-18
      相关资源
      最近更新 更多